19#include "../Utils_Fill.h"
28 cout <<
"=== Matrix: Example linear banded solver ============\n";
33 const double tol = 1.e-10;
38 const unsigned offdiag = 2;
40 const unsigned N = 511;
41 const double D = 12 * ( 1. / ( N - 1 ) ) * ( 1. / ( N - 1 ) );
55 cout <<
" Using dense matrix solver : " << N <<
"x" << N <<
" system \n";
56 cout <<
" Using the native dense routine\n";
63 catch (
const std::runtime_error &error )
65 cout <<
" \033[1;31;48m * FAILED THROUGH EXCEPTION BEING RAISED \033[0m\n";
69 cout <<
" * Not checking.\n";
71 cout <<
" Comparing the banded matrix solver solution : ";
72 cout << N <<
"x" << 2 * AB.
noffdiag() + 1 <<
" system \n";
74 cout <<
" Using the native banded routine\n";
79 banded_system.
solve();
81 catch (
const std::runtime_error &error )
83 cout <<
" \033[1;31;48m * FAILED THROUGH EXCEPTION BEING RAISED \033[0m\n";
88 if ( std::abs( BB.
two_norm() ) > tol )
91 cout <<
" \033[1;31;48m * Banded solver does not give same result as dense solver \033[0m\n";
95 cout <<
" Banded solver agrees with the dense solver.\n";
104 cout <<
"\033[1;31;48m * FAILED \033[0m\n";
109 cout <<
"\033[1;32;48m * PASSED \033[0m\n";
Specification of the linear system class.
Specification of the linear system class.
A spec for the CppNoddy Timer object.
A spec for a collection of utility functions.
A linear system class for vector right-hand sides.
void solve()
Solve the banded system.
A matrix class that constructs a BANDED matrix.
std::size_t noffdiag() const
Get the number of off-diagonal elements where the total INPUT band width is 2*noffdiag+1 since the ba...
A linear system class for vector right-hand sides.
void solve()
Solve the sparse system.
A matrix class that constructs a DENSE matrix as a row major std::vector of DenseVectors.
An DenseVector class – a dense vector object.
void sub(const DenseVector< _Type > &x)
Subtract a vector, element wise, equivalent to -=.
double two_norm() const
l2-norm.
A collection of OO numerical routines aimed at simple (typical) applied problems in continuum mechani...
void fill_band(CppNoddy::Sequential_Matrix_base< _Type > &A, const int &offset, const _Type &value)
Fill a diagonal band of a matrix.