24 template <
typename _Type>
29 typedef typename std::vector<DenseVector<_Type> >::iterator
row_iter;
30 typedef typename std::vector<DenseVector<_Type> >::const_iterator
row_citer;
31 typedef typename std::vector<DenseVector<_Type> >::reverse_iterator
row_riter;
32 typedef typename std::vector<DenseVector<_Type> >::const_reverse_iterator
row_criter;
46 const std::size_t & cols,
57 const std::size_t& cols,
64 int l = source.noffdiag();
66 int n = source.nrows();
67 for(
int row = 0; row < n; ++row) {
69 for(
int col = std::max(row - l, 0);
70 col < std::min(n, row + l + 1);
72 vecrow[ col ] = source(row, col);
74 m_matrix.push_back(vecrow);
92 const _Type&
operator()(
const std::size_t& row,
const std::size_t& col)
const;
94 _Type&
operator()(
const std::size_t& row,
const std::size_t& col);
96 const _Type&
get(
const std::size_t& row,
const std::size_t& col)
const;
98 _Type&
set(
const std::size_t& row,
const std::size_t& col);
108 for(std::size_t row = 0; row < m_nr; ++row) {
109 for(std::size_t col = 0; col < m_nc; ++col) {
110 temp(row, col) += A(row, col);
117 for(std::size_t row = 0; row < m_nr; ++row) {
118 for(std::size_t col = 0; col < m_nc; ++col) {
119 temp(row, col) -= A(row, col);
130 std::size_t
nelts()
const;
134 void scale(
const _Type& mult);
174 return m_matrix.begin();
180 return m_matrix.end();
186 return m_matrix.rbegin();
192 return m_matrix.rend();
198 return m_matrix.begin();
204 return m_matrix.end();
210 return m_matrix.rbegin();
216 return m_matrix.rend();
273 std::vector< DenseVector<_Type> > m_matrix;
286 template <
typename _Type>
288 const std::size_t& col)
const {
290 if((row > m_nr) || (row < 0)) {
291 std::string problem(
"The DenseMatrix.() has a range error.\n");
294 if((col > m_nc) || (col < 0)) {
295 std::string problem(
"The DenseMatrix.() has a range error.\n");
299 return m_matrix[ row ][ col ];
302 template <
typename _Type>
304 const std::size_t& col) {
306 if((row > m_nr) || (row < 0)) {
307 std::string problem(
"The DenseMatrix.() has a range error.\n");
310 if((col > m_nc) || (col < 0)) {
311 std::string problem(
"The DenseMatrix.() has a range error.\n");
315 return m_matrix[ row ][ col ];
318 template <
typename _Type>
320 (
const std::size_t& row,
const std::size_t& col)
const {
322 if((row > m_nr) || (row < 0)) {
323 std::string problem(
"The DenseMatrix.get has a range error.\n");
327 if((col > m_nc) || (col < 0)) {
328 std::string problem(
"The DenseMatrix.get has a range error.\n");
332 return m_matrix[ row ][ col ];
335 template <
typename _Type>
337 (
const std::size_t& row,
338 const std::size_t& col) {
340 if((row > m_nr) || (row < 0)) {
341 std::string problem(
"The DenseMatrix.set has a range error.\n");
344 if((col > m_nc) || (col < 0)) {
345 std::string problem(
"The DenseMatrix.set has a range error.\n");
349 return m_matrix[ row ][ col ];
352 template <
typename _Type>
355 if((row > m_nr) || (row < 0)) {
356 std::string problem(
"The DenseMatrix.get_row has a range error.\n");
360 return m_matrix[ row ];
363 template <
typename _Type>
366 if((row > m_nr) || (row < 0)) {
367 std::string problem(
"The DenseMatrix.get_row has a range error.\n");
371 return m_matrix[ row ];
374 template <
typename _Type>
379 template <
typename _Type>
Specification for a templated DenseVector class – a dense, dynamic, vector object.
A base matrix class to ensure a consistent interface between the inheriting dense/banded matrix class...
A matrix class that constructs a BANDED matrix.
A matrix class that constructs a DENSE matrix as a row major std::vector of DenseVectors.
std::vector< DenseVector< _Type > >::reverse_iterator row_riter
void assign(_Type elt)
Assign a value to the matrix but keep the same geometry.
std::size_t nelts() const
void dump() const
Output the matrix to std::cout.
std::vector< DenseVector< _Type > >::const_reverse_iterator row_criter
row_citer begin() const
Pass through of iterator calls.
DenseVector< _Type >::elt_iter elt_iter
double one_norm() const
Return the maximum one_norm of all rows.
DenseMatrix & operator=(const DenseMatrix &source)
Assignment operator.
row_iter begin()
Pass through of iterator calls.
void matrix_to_vector(DenseVector< double > &p, const std::size_t &padding=0) const
Conversion to contiguous data in row major format.
std::size_t nrows() const
DenseMatrix< _Type > operator*(const double &m) const
SIMD operator sugar.
row_citer end() const
Pass through of iterator calls.
row_iter max_in_col(const std::size_t &col, row_iter row_min, row_iter row_max) const
Find the maximum abs value in a column.
void set_col(const std::size_t &col, const DenseVector< _Type > &x)
Set a column of the matrix.
row_iter end()
Pass through of iterator calls.
row_riter rbegin()
Pass through of iterator calls.
DenseVector< double > matrix_to_vector(const std::size_t &padding=0) const
Conversion to contiguous data in row major format Inefficient ... the void method is preferred.
DenseVector< _Type >::elt_criter elt_criter
std::vector< DenseVector< _Type > >::iterator row_iter
Typedef iterator types.
_Type & operator()(const std::size_t &row, const std::size_t &col)
Access operator.
_Type & set(const std::size_t &row, const std::size_t &col)
Access operator.
DenseVector< _Type > multiply(const DenseVector< _Type > &x) const
Right multiply the matrix by a DENSE vector.
DenseMatrix(const BandedMatrix< _Type > &source)
Construct a dense matrix from its banded counterpart.
row_criter rend() const
Pass through of iterator calls.
void transpose()
Transpose the matrix.
row_riter rend()
Pass through of iterator calls.
double frob_norm() const
Return the sum of the two_norm of all rows.
DenseVector< _Type > get_col(const std::size_t &col) const
Get a column of the matrix.
const DenseVector< _Type > & operator[](const std::size_t &row) const
Operator overloading for ROW access.
void add(const DenseMatrix< _Type > &b)
Add a DENSE matrix to this object.
const _Type & operator()(const std::size_t &row, const std::size_t &col) const
Access operator.
double inf_norm() const
Return the maximum inf_norm of all rows.
DenseMatrix< _Type > operator-(const DenseMatrix< _Type > &A) const
DenseVector< _Type > & operator[](const std::size_t &row)
Operator overloading for ROW access.
void scale(const _Type &mult)
Scale all matrix elements by a scalar.
void sub(const DenseMatrix< _Type > &b)
Subtract a DENSE matrix from this object.
row_criter rbegin() const
Pass through of iterator calls.
std::vector< DenseVector< _Type > >::const_iterator row_citer
DenseMatrix()
Allow empty construction.
DenseVector< _Type >::elt_riter elt_riter
const _Type & get(const std::size_t &row, const std::size_t &col) const
Access operator.
double two_norm() const
Rreturn the maximum two_norm of all rows.
std::size_t ncols() const
DenseVector< _Type >::elt_citer elt_citer
DenseMatrix< _Type > operator+(const DenseMatrix< _Type > &A) const
An DenseVector class – a dense vector object.
std::vector< _Type >::const_reverse_iterator elt_criter
std::vector< _Type >::reverse_iterator elt_riter
std::vector< _Type >::const_iterator elt_citer
std::vector< _Type >::iterator elt_iter
An exception to indicate that a CppNoddy container has been accessed with index/indices outside the m...
A base matrix class for sequential matrices.
A collection of OO numerical routines aimed at simple (typical) applied problems in continuum mechani...