15 template <
typename _Type>
17 const std::size_t& upper_offdiag_bands,
21 m_L(upper_offdiag_bands) {
30 template <
typename _Type>
36 template <
typename _Type>
40 m_storage = source.m_storage;
46 template <
typename _Type>
48 return m_storage.size();
51 template <
typename _Type>
57 template <
typename _Type>
60 problem =
" The multiply method of the BandedMatrix class has \n";
61 problem +=
" not been implemented. \n";
67 template <
typename _Type>
69 for(std::size_t row = 0; row < m_N; ++row) {
70 for(std::size_t col = std::max(0,
int(row) -
int(m_L)); col < row; ++col) {
72 std::swap(
operator()(row, col),
operator()(col, row));
78 template <
typename _Type>
83 for(std::size_t col = row1; col <= std::min(row1 + 2 * m_L, m_N - 1); ++col) {
84 std::swap(
operator()(row1, col),
operator()(row2, col));
89 template <
typename _Type>
92 for(
unsigned row = 0; row < m_N; ++row) {
95 max = std::max(max, temp.
one_norm());
101 template <
typename _Type>
104 for(
unsigned row = 0; row < m_N; ++row) {
107 max = std::max(max, temp.
two_norm());
113 template <
typename _Type>
116 for(
unsigned row = 0; row < m_N; ++row) {
119 max = std::max(max, temp.
inf_norm());
125 template <
typename _Type>
128 for(
unsigned row = 0; row < m_N; ++row) {
136 template <
typename _Type>
138 std::cout <<
"BANDED mtx size = " << nrows() <<
" x " << ncols()
139 <<
" with INPUT no. of bands = " << 2 * m_L + 1
140 <<
" and total bands STORED (for pivotting) = " << 3 * m_L + 1 <<
"\n";
141 std::cout.precision(4);
142 std::cout <<
"- start matrix \n";
143 for(std::size_t i = 0; i < nrows(); ++i) {
144 std::cout <<
" row " << i <<
" = ";
145 for(std::size_t j = 0; j < nrows(); ++j) {
148 if(((
int) j < (
int) i - (
int) m_L) || ((int) j > (
int) i + (int)(2*m_L))) {
149 std::cout << 0 <<
", ";
151 std::cout << operator()(i, j) <<
", ";
156 std::cout <<
"- end matrix \n";
161 return &(m_storage[0]);
167 return &
reinterpret_cast<double(&)[2]
>(m_storage[0])[0];
A matrix class that constructs a BANDED matrix.
Specification for a templated DenseVector class – a dense, dynamic, vector object.
The collection of CppNoddy exceptions.
A matrix class that constructs a BANDED matrix.
void transpose()
Transpose the matrix.
void scale(const _Type &mult)
Scale all entries in the matrix by a scalar.
DenseVector< _Type > multiply(const DenseVector< _Type > &X) const
Right multiply the matrix by a DENSE vector.
std::size_t m_L
Max number of (INPUT) bands above OR below the main diagonal.
double * base()
Allow direct access to the vector m_storage.
BandedMatrix & operator=(const BandedMatrix &source)
Assignment operator.
std::size_t m_N
The number of rows/cols in the matrix.
DenseVector< _Type > m_storage
A contiguous vector.
BandedMatrix()
Empty constructor .. should we stop this?
void row_swap(const std::size_t &row1, const std::size_t &row2)
Exchange rows in the matrix.
std::size_t nelts() const
Get the number of elements.
void dump() const
Output the matrix contents to std::cout.
An DenseVector class – a dense vector object.
double one_norm() const
l1-norm.
double inf_norm() const
Infinity norm.
double two_norm() const
l2-norm.
A generic runtime exception.
A base matrix class for sequential matrices.
A collection of OO numerical routines aimed at simple (typical) applied problems in continuum mechani...