CppNoddy
0.92
|
A matrix class that constructs a DENSE matrix as a row major std::vector of DenseVectors. More...
#include <DenseMatrix.h>
Public Types | |
typedef std::vector< DenseVector< _Type > >::iterator | row_iter |
Typedef iterator types. More... | |
typedef std::vector< DenseVector< _Type > >::const_iterator | row_citer |
typedef std::vector< DenseVector< _Type > >::reverse_iterator | row_riter |
typedef std::vector< DenseVector< _Type > >::const_reverse_iterator | row_criter |
typedef DenseVector< _Type >::elt_iter | elt_iter |
typedef DenseVector< _Type >::elt_citer | elt_citer |
typedef DenseVector< _Type >::elt_riter | elt_riter |
typedef DenseVector< _Type >::elt_criter | elt_criter |
Public Member Functions | |
DenseMatrix () | |
Allow empty construction. More... | |
DenseMatrix (const std::size_t &rows, const std::size_t &cols, const _Type &fill) | |
Noddy Matrix constructor with a specified fill data. More... | |
DenseMatrix (const std::size_t &rows, const std::size_t &cols, const _Type *p) | |
Construct a Noddy Matrix from a contiguous set of data. More... | |
DenseMatrix (const BandedMatrix< _Type > &source) | |
Construct a dense matrix from its banded counterpart. More... | |
DenseMatrix (const DenseMatrix &source) | |
Copy constructor. More... | |
DenseMatrix & | operator= (const DenseMatrix &source) |
Assignment operator. More... | |
~DenseMatrix () | |
const _Type & | operator() (const std::size_t &row, const std::size_t &col) const |
Access operator. More... | |
_Type & | operator() (const std::size_t &row, const std::size_t &col) |
Access operator. More... | |
const _Type & | get (const std::size_t &row, const std::size_t &col) const |
Access operator. More... | |
_Type & | set (const std::size_t &row, const std::size_t &col) |
Access operator. More... | |
DenseMatrix< _Type > | operator* (const double &m) const |
SIMD operator sugar. More... | |
DenseMatrix< _Type > | operator+ (const DenseMatrix< _Type > &A) const |
DenseMatrix< _Type > | operator- (const DenseMatrix< _Type > &A) const |
std::size_t | nrows () const |
std::size_t | ncols () const |
std::size_t | nelts () const |
void | scale (const _Type &mult) |
Scale all matrix elements by a scalar. More... | |
void | transpose () |
Transpose the matrix. More... | |
double | one_norm () const |
Return the maximum one_norm of all rows. More... | |
double | two_norm () const |
Rreturn the maximum two_norm of all rows. More... | |
double | inf_norm () const |
Return the maximum inf_norm of all rows. More... | |
double | frob_norm () const |
Return the sum of the two_norm of all rows. More... | |
DenseVector< _Type > | multiply (const DenseVector< _Type > &x) const |
Right multiply the matrix by a DENSE vector. More... | |
void | dump () const |
Output the matrix to std::cout. More... | |
void | assign (_Type elt) |
Assign a value to the matrix but keep the same geometry. More... | |
row_iter | begin () |
Pass through of iterator calls. More... | |
row_iter | end () |
Pass through of iterator calls. More... | |
row_riter | rbegin () |
Pass through of iterator calls. More... | |
row_riter | rend () |
Pass through of iterator calls. More... | |
row_citer | begin () const |
Pass through of iterator calls. More... | |
row_citer | end () const |
Pass through of iterator calls. More... | |
row_criter | rbegin () const |
Pass through of iterator calls. More... | |
row_criter | rend () const |
Pass through of iterator calls. More... | |
DenseVector< _Type > & | operator[] (const std::size_t &row) |
Operator overloading for ROW access. More... | |
const DenseVector< _Type > & | operator[] (const std::size_t &row) const |
Operator overloading for ROW access. More... | |
void | add (const DenseMatrix< _Type > &b) |
Add a DENSE matrix to this object. More... | |
void | sub (const DenseMatrix< _Type > &b) |
Subtract a DENSE matrix from this object. More... | |
DenseMatrix< _Type > | multiply (const DenseMatrix< _Type > &b) const |
Right-multiply by a DENSE matrix and return the result. More... | |
void | set_col (const std::size_t &col, const DenseVector< _Type > &x) |
Set a column of the matrix. More... | |
DenseVector< _Type > | get_col (const std::size_t &col) const |
Get a column of the matrix. More... | |
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. More... | |
void | matrix_to_vector (DenseVector< double > &p, const std::size_t &padding=0) const |
Conversion to contiguous data in row major format. More... | |
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. More... | |
void | matrix_to_vector (DenseVector< double > &p, const std::size_t &padding) const |
void | matrix_to_vector (DenseVector< double > &p, const std::size_t &padding) const |
DenseVector< double > | matrix_to_vector (const std::size_t &padding) const |
DenseVector< double > | matrix_to_vector (const std::size_t &padding) const |
![]() | |
Sequential_Matrix_base () | |
An empty constructor. More... | |
virtual | ~Sequential_Matrix_base () |
virtual const _Type & | operator() (const std::size_t &row, const std::size_t &col) const =0 |
virtual _Type & | operator() (const std::size_t &row, const std::size_t &col)=0 |
virtual const _Type & | get (const std::size_t &row, const std::size_t &col) const =0 |
virtual _Type & | set (const std::size_t &row, const std::size_t &col)=0 |
virtual std::size_t | nrows () const =0 |
virtual std::size_t | ncols () const =0 |
virtual std::size_t | nelts () const =0 |
virtual void | scale (const _Type &mult)=0 |
virtual void | dump () const =0 |
A matrix class that constructs a DENSE matrix as a row major std::vector of DenseVectors.
This is generally a nice way to implement the matrix, but the data elements [i][j] are not necessarily in contiguous row_major format in memory because there is a system dependent padding at the end of each row vector. Thus, in general, &[i][j+1] - &[i][j] != &[i][0] - &[i-1][Nc] .. ie. the step may be larger from the end of row i-1 to the start of row i. Typically, the data must be copied into contiguous memory for use in external libraries that take base pointers & assume uniform steps between elements.
Definition at line 25 of file DenseMatrix.h.
typedef DenseVector<_Type>::elt_citer CppNoddy::DenseMatrix< _Type >::elt_citer |
Definition at line 34 of file DenseMatrix.h.
typedef DenseVector<_Type>::elt_criter CppNoddy::DenseMatrix< _Type >::elt_criter |
Definition at line 36 of file DenseMatrix.h.
typedef DenseVector<_Type>::elt_iter CppNoddy::DenseMatrix< _Type >::elt_iter |
Definition at line 33 of file DenseMatrix.h.
typedef DenseVector<_Type>::elt_riter CppNoddy::DenseMatrix< _Type >::elt_riter |
Definition at line 35 of file DenseMatrix.h.
typedef std::vector<DenseVector<_Type>>::const_iterator CppNoddy::DenseMatrix< _Type >::row_citer |
Definition at line 30 of file DenseMatrix.h.
typedef std::vector<DenseVector<_Type>>::const_reverse_iterator CppNoddy::DenseMatrix< _Type >::row_criter |
Definition at line 32 of file DenseMatrix.h.
typedef std::vector<DenseVector<_Type>>::iterator CppNoddy::DenseMatrix< _Type >::row_iter |
Typedef iterator types.
Definition at line 29 of file DenseMatrix.h.
typedef std::vector<DenseVector<_Type>>::reverse_iterator CppNoddy::DenseMatrix< _Type >::row_riter |
Definition at line 31 of file DenseMatrix.h.
CppNoddy::DenseMatrix< _Type >::DenseMatrix |
Allow empty construction.
Definition at line 17 of file DenseMatrix.cpp.
CppNoddy::DenseMatrix< _Type >::DenseMatrix | ( | const std::size_t & | rows, |
const std::size_t & | cols, | ||
const _Type & | fill | ||
) |
Noddy Matrix constructor with a specified fill data.
rows | The number of rows in the matrix. |
cols | The number of columns in the matrix. |
fill | The entry to be placed in all elements. |
Definition at line 21 of file DenseMatrix.cpp.
CppNoddy::DenseMatrix< _Type >::DenseMatrix | ( | const std::size_t & | rows, |
const std::size_t & | cols, | ||
const _Type * | p | ||
) |
Construct a Noddy Matrix from a contiguous set of data.
This will be nasty if you pass the wrong pointer, but is useful in interfacing with external libraries. This assumes the contiguous data is in row_major format.
rows | The number of rows in the matrix. |
cols | The number of columns in the matrix. |
p | A pointer to the start of the data. |
Definition at line 38 of file DenseMatrix.cpp.
|
inline |
Construct a dense matrix from its banded counterpart.
source | The banded matrix to be used in the construction. |
Definition at line 62 of file DenseMatrix.h.
CppNoddy::DenseMatrix< _Type >::DenseMatrix | ( | const DenseMatrix< _Type > & | source | ) |
Copy constructor.
source | The source object to be copied |
Definition at line 51 of file DenseMatrix.cpp.
CppNoddy::DenseMatrix< _Type >::~DenseMatrix |
Definition at line 57 of file DenseMatrix.cpp.
void CppNoddy::DenseMatrix< _Type >::add | ( | const DenseMatrix< _Type > & | b | ) |
Add a DENSE matrix to this object.
b | The DENSE matrix to add to 'this' |
Definition at line 76 of file DenseMatrix.cpp.
References CppNoddy::DenseMatrix< _Type >::ncols(), and CppNoddy::DenseMatrix< _Type >::nrows().
Referenced by main().
|
inline |
Assign a value to the matrix but keep the same geometry.
elt | The value to be assigned to all entries |
Definition at line 167 of file DenseMatrix.h.
|
inline |
Pass through of iterator calls.
Definition at line 173 of file DenseMatrix.h.
|
inline |
Pass through of iterator calls.
Definition at line 197 of file DenseMatrix.h.
|
virtual |
Output the matrix to std::cout.
Implements CppNoddy::Sequential_Matrix_base< _Type >.
Definition at line 223 of file DenseMatrix.cpp.
|
inline |
Pass through of iterator calls.
Definition at line 179 of file DenseMatrix.h.
|
inline |
Pass through of iterator calls.
Definition at line 203 of file DenseMatrix.h.
double CppNoddy::DenseMatrix< _Type >::frob_norm |
Return the sum of the two_norm of all rows.
Definition at line 213 of file DenseMatrix.cpp.
|
inlinevirtual |
Access operator.
Implements CppNoddy::Sequential_Matrix_base< _Type >.
Definition at line 319 of file DenseMatrix.h.
DenseVector< _Type > CppNoddy::DenseMatrix< _Type >::get_col | ( | const std::size_t & | col | ) | const |
Get a column of the matrix.
col | The column to get |
Definition at line 249 of file DenseMatrix.cpp.
double CppNoddy::DenseMatrix< _Type >::inf_norm |
Return the maximum inf_norm of all rows.
Definition at line 204 of file DenseMatrix.cpp.
Referenced by main().
DenseVector< double > CppNoddy::DenseMatrix< double >::matrix_to_vector | ( | const std::size_t & | padding | ) | const |
Definition at line 287 of file DenseMatrix.cpp.
References V.
DenseVector< double > CppNoddy::DenseMatrix< std::complex< double > >::matrix_to_vector | ( | const std::size_t & | padding | ) | const |
Definition at line 302 of file DenseMatrix.cpp.
References V.
DenseVector< double > CppNoddy::DenseMatrix< _Type >::matrix_to_vector | ( | const std::size_t & | padding = 0 | ) | const |
Conversion to contiguous data in row major format Inefficient ... the void method is preferred.
padding | An integer padding hack |
Referenced by CppNoddy::FortranData::FortranData().
void CppNoddy::DenseMatrix< std::complex< double > >::matrix_to_vector | ( | DenseVector< double > & | p, |
const std::size_t & | padding | ||
) | const |
Definition at line 258 of file DenseMatrix.cpp.
References p.
void CppNoddy::DenseMatrix< double >::matrix_to_vector | ( | DenseVector< double > & | p, |
const std::size_t & | padding | ||
) | const |
Definition at line 274 of file DenseMatrix.cpp.
References p.
void CppNoddy::DenseMatrix< _Type >::matrix_to_vector | ( | DenseVector< double > & | p, |
const std::size_t & | padding = 0 |
||
) | const |
Conversion to contiguous data in row major format.
padding | An integer padding hack |
p | A DENSE vector containing the matrix |
std::vector< DenseVector< _Type > >::iterator CppNoddy::DenseMatrix< _Type >::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.
col | The column offset to search through |
row_min | Iterator to the begin row |
row_max | Iterator to final row (NOT INCLUSIVE) |
Definition at line 171 of file DenseMatrix.cpp.
DenseMatrix< _Type > CppNoddy::DenseMatrix< _Type >::multiply | ( | const DenseMatrix< _Type > & | b | ) | const |
Right-multiply by a DENSE matrix and return the result.
b | The matrix to right-multiply by |
Definition at line 149 of file DenseMatrix.cpp.
DenseVector< _Type > CppNoddy::DenseMatrix< _Type >::multiply | ( | const DenseVector< _Type > & | x | ) | const |
Right multiply the matrix by a DENSE vector.
x | The DENSE vector to be multiplied |
Definition at line 132 of file DenseMatrix.cpp.
Referenced by CppNoddy::OneD_TVDLF_Elt::contributed_flux_in_left(), CppNoddy::OneD_TVDLF_Elt::contributed_flux_out_right(), CppNoddy::TwoD_TVDLF_Elt::get_Q_Taylor_series(), and main().
|
inlinevirtual |
Implements CppNoddy::Sequential_Matrix_base< _Type >.
Definition at line 380 of file DenseMatrix.h.
Referenced by CppNoddy::DenseMatrix< _Type >::add(), CppNoddy::DenseMatrix< double >::frob_norm(), CppNoddy::Utility::multiply(), and CppNoddy::DenseMatrix< double >::~DenseMatrix().
|
virtual |
Implements CppNoddy::Sequential_Matrix_base< _Type >.
Definition at line 71 of file DenseMatrix.cpp.
|
inlinevirtual |
Implements CppNoddy::Sequential_Matrix_base< _Type >.
Definition at line 375 of file DenseMatrix.h.
Referenced by CppNoddy::DenseMatrix< _Type >::add(), CppNoddy::DenseMatrix< double >::frob_norm(), CppNoddy::Utility::multiply(), and CppNoddy::DenseMatrix< double >::~DenseMatrix().
double CppNoddy::DenseMatrix< _Type >::one_norm |
Return the maximum one_norm of all rows.
Definition at line 186 of file DenseMatrix.cpp.
|
inlinevirtual |
Access operator.
Implements CppNoddy::Sequential_Matrix_base< _Type >.
Definition at line 303 of file DenseMatrix.h.
|
inlinevirtual |
Access operator.
Implements CppNoddy::Sequential_Matrix_base< _Type >.
Definition at line 287 of file DenseMatrix.h.
|
inline |
SIMD operator sugar.
Definition at line 101 of file DenseMatrix.h.
References m, and CppNoddy::DenseMatrix< _Type >::scale().
|
inline |
Definition at line 106 of file DenseMatrix.h.
|
inline |
Definition at line 115 of file DenseMatrix.h.
|
inline |
Assignment operator.
source | The source object for the assignment |
Definition at line 61 of file DenseMatrix.cpp.
|
inline |
Operator overloading for ROW access.
row | The row to access |
Definition at line 353 of file DenseMatrix.h.
|
inline |
Operator overloading for ROW access.
row | The row to access |
Definition at line 364 of file DenseMatrix.h.
|
inline |
Pass through of iterator calls.
Definition at line 185 of file DenseMatrix.h.
|
inline |
Pass through of iterator calls.
Definition at line 209 of file DenseMatrix.h.
|
inline |
Pass through of iterator calls.
Definition at line 191 of file DenseMatrix.h.
|
inline |
Pass through of iterator calls.
Definition at line 215 of file DenseMatrix.h.
|
virtual |
Scale all matrix elements by a scalar.
mult | The scalar multiplier |
Implements CppNoddy::Sequential_Matrix_base< _Type >.
Definition at line 100 of file DenseMatrix.cpp.
Referenced by main(), and CppNoddy::DenseMatrix< _Type >::operator*().
|
inlinevirtual |
Access operator.
Implements CppNoddy::Sequential_Matrix_base< _Type >.
Definition at line 336 of file DenseMatrix.h.
void CppNoddy::DenseMatrix< _Type >::set_col | ( | const std::size_t & | col, |
const DenseVector< _Type > & | x | ||
) |
Set a column of the matrix.
col | The column to be set |
x | The DENSE vector of column information |
Definition at line 242 of file DenseMatrix.cpp.
Referenced by CppNoddy::OneD_Hyperbolic_System::Jac_flux_fn(), CppNoddy::TwoD_Hyperbolic_System::Jac_flux_fn_x(), CppNoddy::TwoD_Hyperbolic_System::Jac_flux_fn_y(), and CppNoddy::Residual< _Type >::jacobian().
void CppNoddy::DenseMatrix< _Type >::sub | ( | const DenseMatrix< _Type > & | b | ) |
Subtract a DENSE matrix from this object.
b | The DENSE matrix to subtract from 'this' |
Definition at line 88 of file DenseMatrix.cpp.
Referenced by main().
void CppNoddy::DenseMatrix< _Type >::transpose |
Transpose the matrix.
Definition at line 105 of file DenseMatrix.cpp.
Referenced by CppNoddy::FortranData::FortranData().
double CppNoddy::DenseMatrix< _Type >::two_norm |
Rreturn the maximum two_norm of all rows.
Definition at line 195 of file DenseMatrix.cpp.
© 2012
R.E. Hewitt