Abstract base class for matrices, templated by the type of object that is stored in them and the type of matrix. The MATRIX_TYPE template argument is used as part of the Curiously Recurring Template Pattern, see http://en.wikipedia.org/wiki/Curiously_Recurring_Template_Pattern The pattern is used to force the inlining of the round bracket access functions by ensuring that they are NOT virtual functions. More...
#include <matrices.h>
Public Member Functions | |
Matrix () | |
(Empty) constructor More... | |
Matrix (const Matrix &matrix)=delete | |
Broken copy constructor. More... | |
void | operator= (const Matrix &)=delete |
Broken assignment operator. More... | |
virtual | ~Matrix () |
Virtual (empty) destructor. More... | |
virtual unsigned long | nrow () const =0 |
Return the number of rows of the matrix. More... | |
virtual unsigned long | ncol () const =0 |
Return the number of columns of the matrix. More... | |
T | operator() (const unsigned long &i, const unsigned long &j) const |
Round brackets to give access as a(i,j) for read only (we're not providing a general interface for component-wise write access since not all matrix formats allow efficient direct access!) The function uses the MATRIX_TYPE template parameter to call the get_entry() function which must be defined in all derived classes that are to be fully instantiated. More... | |
T & | operator() (const unsigned long &i, const unsigned long &j) |
Round brackets to give access as a(i,j) for read-write access. The function uses the MATRIX_TYPE template parameter to call the entry() function which must be defined in all derived classes that are to be fully instantiated. If the particular Matrix does not allow write access, the function should break with an error message. More... | |
virtual void | output (std::ostream &outfile) const |
Output function to print a matrix row-by-row, in the form a(0,0) a(0,1) ... a(1,0) a(1,1) ... ... to the stream outfile. Broken virtual since it might not be sensible to implement this for some sparse matrices. More... | |
virtual void | output_bottom_right_zero_helper (std::ostream &outfile) const =0 |
Output the "bottom right" entry regardless of it being zero or not (this allows automatic detection of matrix size in e.g. matlab, python). This functionality was moved from the function sparse_indexed_output(...) because at the moment, generalisation of this functionality does not work in parallel. CRDoubleMatrix has an nrow() function but it should it should use nrow_local() - which is the N variable in the underlaying CRMatrix. More... | |
virtual void | sparse_indexed_output_helper (std::ostream &outfile) const =0 |
Indexed output function to print a matrix to the stream outfile as i,j,a(i,j) for a(i,j)!=0 only. More... | |
void | sparse_indexed_output (std::ostream &outfile, const unsigned &precision=0, const bool &output_bottom_right_zero=false) const |
Indexed output function to print a matrix to the stream outfile as i,j,a(i,j) for a(i,j)!=0 only with specified precision (if precision=0 then nothing is changed). If optional boolean flag is set to true we also output the "bottom right" entry regardless of it being zero or not (this allows automatic detection of matrix size in e.g. matlab, python). More... | |
void | sparse_indexed_output (std::string filename, const unsigned &precision=0, const bool &output_bottom_right_zero=false) const |
Indexed output function to print a matrix to the file named filename as i,j,a(i,j) for a(i,j)!=0 only with specified precision. If optional boolean flag is set to true we also output the "bottom right" entry regardless of it being zero or not (this allows automatic detection of matrix size in e.g. matlab, python). More... | |
Protected Member Functions | |
void | range_check (const unsigned long &i, const unsigned long &j) const |
Range check to catch when an index is out of bounds, if so, it issues a warning message and dies by throwing an OomphLibError . More... | |
Abstract base class for matrices, templated by the type of object that is stored in them and the type of matrix. The MATRIX_TYPE template argument is used as part of the Curiously Recurring Template Pattern, see http://en.wikipedia.org/wiki/Curiously_Recurring_Template_Pattern The pattern is used to force the inlining of the round bracket access functions by ensuring that they are NOT virtual functions.
Definition at line 73 of file matrices.h.
|
inline |
(Empty) constructor
Definition at line 105 of file matrices.h.
|
delete |
Broken copy constructor.
|
inlinevirtual |
Virtual (empty) destructor.
Definition at line 114 of file matrices.h.
|
pure virtual |
Return the number of columns of the matrix.
Implemented in oomph::SumOfMatrices, oomph::CCDoubleMatrix, oomph::DenseDoubleMatrix, oomph::CRDoubleMatrix, oomph::SparseMatrix< T, MATRIX_TYPE >, oomph::SparseMatrix< T, CCMatrix< T > >, oomph::SparseMatrix< T, CRMatrix< T > >, oomph::DenseMatrix< T >, oomph::DenseMatrix< oomph::MatrixVectorProduct * >, oomph::DenseMatrix< double >, oomph::DenseMatrix< int >, oomph::DenseMatrix< double * >, oomph::DenseMatrix< oomph::CRDoubleMatrix * >, oomph::DenseMatrix< std::complex< double > >, oomph::DenseMatrix< unsigned >, oomph::DenseMatrix< int * >, oomph::DenseMatrix< bool >, oomph::CCComplexMatrix, oomph::CRComplexMatrix, and oomph::DenseComplexMatrix.
Referenced by oomph::Matrix< T, MATRIX_TYPE >::range_check(), and oomph::Matrix< T, MATRIX_TYPE >::sparse_indexed_output().
|
pure virtual |
Return the number of rows of the matrix.
Implemented in oomph::SumOfMatrices, oomph::CCDoubleMatrix, oomph::DenseDoubleMatrix, oomph::CRDoubleMatrix, oomph::SparseMatrix< T, MATRIX_TYPE >, oomph::SparseMatrix< T, CCMatrix< T > >, oomph::SparseMatrix< T, CRMatrix< T > >, oomph::DenseMatrix< T >, oomph::DenseMatrix< oomph::MatrixVectorProduct * >, oomph::DenseMatrix< double >, oomph::DenseMatrix< int >, oomph::DenseMatrix< double * >, oomph::DenseMatrix< oomph::CRDoubleMatrix * >, oomph::DenseMatrix< std::complex< double > >, oomph::DenseMatrix< unsigned >, oomph::DenseMatrix< int * >, oomph::DenseMatrix< bool >, oomph::CCComplexMatrix, oomph::CRComplexMatrix, and oomph::DenseComplexMatrix.
Referenced by oomph::Matrix< T, MATRIX_TYPE >::range_check(), and oomph::Matrix< T, MATRIX_TYPE >::sparse_indexed_output().
|
inline |
Round brackets to give access as a(i,j) for read-write access. The function uses the MATRIX_TYPE template parameter to call the entry() function which must be defined in all derived classes that are to be fully instantiated. If the particular Matrix does not allow write access, the function should break with an error message.
Definition at line 140 of file matrices.h.
References i.
|
inline |
Round brackets to give access as a(i,j) for read only (we're not providing a general interface for component-wise write access since not all matrix formats allow efficient direct access!) The function uses the MATRIX_TYPE template parameter to call the get_entry() function which must be defined in all derived classes that are to be fully instantiated.
Definition at line 128 of file matrices.h.
References i.
Referenced by oomph::CRMatrix< T >::output_bottom_right_zero_helper(), and oomph::CCMatrix< T >::output_bottom_right_zero_helper().
|
delete |
Broken assignment operator.
|
inlinevirtual |
Output function to print a matrix row-by-row, in the form a(0,0) a(0,1) ... a(1,0) a(1,1) ... ... to the stream outfile. Broken virtual since it might not be sensible to implement this for some sparse matrices.
Reimplemented in oomph::DenseMatrix< T >, oomph::DenseMatrix< oomph::MatrixVectorProduct * >, oomph::DenseMatrix< double >, oomph::DenseMatrix< int >, oomph::DenseMatrix< double * >, oomph::DenseMatrix< oomph::CRDoubleMatrix * >, oomph::DenseMatrix< std::complex< double > >, oomph::DenseMatrix< unsigned >, oomph::DenseMatrix< int * >, and oomph::DenseMatrix< bool >.
Definition at line 152 of file matrices.h.
|
pure virtual |
Output the "bottom right" entry regardless of it being zero or not (this allows automatic detection of matrix size in e.g. matlab, python). This functionality was moved from the function sparse_indexed_output(...) because at the moment, generalisation of this functionality does not work in parallel. CRDoubleMatrix has an nrow() function but it should it should use nrow_local() - which is the N variable in the underlaying CRMatrix.
Implemented in oomph::SumOfMatrices, oomph::CCMatrix< T >, oomph::CCMatrix< double >, oomph::CCMatrix< std::complex< double > >, oomph::CRDoubleMatrix, oomph::CRMatrix< T >, oomph::CRMatrix< double >, oomph::CRMatrix< std::complex< double > >, oomph::SparseMatrix< T, MATRIX_TYPE >, oomph::SparseMatrix< T, CCMatrix< T > >, oomph::SparseMatrix< T, CRMatrix< T > >, oomph::DenseMatrix< T >, oomph::DenseMatrix< oomph::MatrixVectorProduct * >, oomph::DenseMatrix< double >, oomph::DenseMatrix< int >, oomph::DenseMatrix< double * >, oomph::DenseMatrix< oomph::CRDoubleMatrix * >, oomph::DenseMatrix< std::complex< double > >, oomph::DenseMatrix< unsigned >, oomph::DenseMatrix< int * >, and oomph::DenseMatrix< bool >.
Referenced by oomph::Matrix< T, MATRIX_TYPE >::sparse_indexed_output().
|
inlineprotected |
Range check to catch when an index is out of bounds, if so, it issues a warning message and dies by throwing an OomphLibError
.
Definition at line 78 of file matrices.h.
References i, oomph::Matrix< T, MATRIX_TYPE >::ncol(), and oomph::Matrix< T, MATRIX_TYPE >::nrow().
Referenced by oomph::CRMatrix< T >::get_entry(), and oomph::CCMatrix< T >::get_entry().
|
inline |
Indexed output function to print a matrix to the stream outfile as i,j,a(i,j) for a(i,j)!=0 only with specified precision (if precision=0 then nothing is changed). If optional boolean flag is set to true we also output the "bottom right" entry regardless of it being zero or not (this allows automatic detection of matrix size in e.g. matlab, python).
Definition at line 182 of file matrices.h.
References oomph::Matrix< T, MATRIX_TYPE >::ncol(), oomph::Matrix< T, MATRIX_TYPE >::nrow(), oomph::Matrix< T, MATRIX_TYPE >::output_bottom_right_zero_helper(), and oomph::Matrix< T, MATRIX_TYPE >::sparse_indexed_output_helper().
Referenced by oomph::BlackBoxFDNewtonSolver::black_box_fd_newton_solve(), and oomph::Matrix< T, MATRIX_TYPE >::sparse_indexed_output().
|
inline |
Indexed output function to print a matrix to the file named filename as i,j,a(i,j) for a(i,j)!=0 only with specified precision. If optional boolean flag is set to true we also output the "bottom right" entry regardless of it being zero or not (this allows automatic detection of matrix size in e.g. matlab, python).
Definition at line 226 of file matrices.h.
References oomph::Matrix< T, MATRIX_TYPE >::sparse_indexed_output().
|
pure virtual |
Indexed output function to print a matrix to the stream outfile as i,j,a(i,j) for a(i,j)!=0 only.
Implemented in oomph::SumOfMatrices, oomph::CCMatrix< T >, oomph::CCMatrix< double >, oomph::CCMatrix< std::complex< double > >, oomph::CRDoubleMatrix, oomph::CRMatrix< T >, oomph::CRMatrix< double >, oomph::CRMatrix< std::complex< double > >, oomph::SparseMatrix< T, MATRIX_TYPE >, oomph::SparseMatrix< T, CCMatrix< T > >, oomph::SparseMatrix< T, CRMatrix< T > >, oomph::DenseMatrix< T >, oomph::DenseMatrix< oomph::MatrixVectorProduct * >, oomph::DenseMatrix< double >, oomph::DenseMatrix< int >, oomph::DenseMatrix< double * >, oomph::DenseMatrix< oomph::CRDoubleMatrix * >, oomph::DenseMatrix< std::complex< double > >, oomph::DenseMatrix< unsigned >, oomph::DenseMatrix< int * >, and oomph::DenseMatrix< bool >.
Referenced by oomph::Matrix< T, MATRIX_TYPE >::sparse_indexed_output().