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>
Inheritance diagram for oomph::Matrix< T, MATRIX_TYPE >:Public Member Functions | |
| Matrix () | |
| (Empty) constructor | |
| Matrix (const Matrix &matrix)=delete | |
| Broken copy constructor. | |
| void | operator= (const Matrix &)=delete |
| Broken assignment operator. | |
| virtual | ~Matrix () |
| Virtual (empty) destructor. | |
| virtual unsigned long | nrow () const =0 |
| Return the number of rows of the matrix. | |
| virtual unsigned long | ncol () const =0 |
| Return the number of columns of the matrix. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| virtual void | sparse_indexed_output_helper (std::ostream &outfile, const double &cutoff=0.0) 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. Final optional argument specifies max. size of entries which are set to zero on output. | |
| void | sparse_indexed_output (std::ostream &outfile, const unsigned &precision=0, const bool &output_bottom_right_zero=false, const double &cutoff=0.0) 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). Final optional argument specifies max. size of entries which are set to zero on output. | |
| void | sparse_indexed_output (std::string filename, const unsigned &precision=0, const bool &output_bottom_right_zero=false, const double &cutoff=0.0) 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). Final optional argument specifies max. size of entries which are set to zero on output. | |
| void | sparse_indexed_output_with_cutoff (std::ostream &outfile, const double &cutoff=0.0) const |
| Indexed output function to print a matrix to the stream outfile as i,j,a(i,j) for a(i,j)!=0. Final optional argument specifies max. size of entries which are set to zero on output. | |
| void | sparse_indexed_output_with_cutoff (std::string filename, const double &cutoff=0.0) const |
| Indexed output function to print a matrix to the stream outfile as i,j,a(i,j) for a(i,j)!=0. Final optional argument specifies max. size of entries which are set to zero on output. | |
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. | |
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 74 of file matrices.h.
|
inline |
(Empty) constructor
Definition at line 106 of file matrices.h.
|
delete |
Broken copy constructor.
|
inlinevirtual |
Virtual (empty) destructor.
Definition at line 115 of file matrices.h.
|
pure virtual |
Return the number of columns of the matrix.
Implemented in oomph::DenseComplexMatrix, oomph::CRComplexMatrix, oomph::CCComplexMatrix, oomph::DenseMatrix< T >, oomph::DenseMatrix< bool >, oomph::DenseMatrix< double * >, oomph::DenseMatrix< double >, oomph::DenseMatrix< int * >, oomph::DenseMatrix< int >, oomph::DenseMatrix< oomph::CRDoubleMatrix * >, oomph::DenseMatrix< oomph::MatrixVectorProduct * >, oomph::DenseMatrix< std::complex< double > >, oomph::DenseMatrix< unsigned >, oomph::SparseMatrix< T, MATRIX_TYPE >, oomph::SparseMatrix< double, CCMatrix< double > >, oomph::SparseMatrix< double, CRMatrix< double > >, oomph::SparseMatrix< std::complex< double >, CCMatrix< std::complex< double > > >, oomph::SparseMatrix< std::complex< double >, CRMatrix< std::complex< double > > >, oomph::SparseMatrix< T, CCMatrix< T > >, oomph::SparseMatrix< T, CRMatrix< T > >, oomph::CRDoubleMatrix, oomph::DenseDoubleMatrix, oomph::CCDoubleMatrix, and oomph::SumOfMatrices.
Referenced by oomph::CCDoubleMatrix::ncol(), 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::DenseComplexMatrix, oomph::CRComplexMatrix, oomph::CCComplexMatrix, oomph::DenseMatrix< T >, oomph::DenseMatrix< bool >, oomph::DenseMatrix< double * >, oomph::DenseMatrix< double >, oomph::DenseMatrix< int * >, oomph::DenseMatrix< int >, oomph::DenseMatrix< oomph::CRDoubleMatrix * >, oomph::DenseMatrix< oomph::MatrixVectorProduct * >, oomph::DenseMatrix< std::complex< double > >, oomph::DenseMatrix< unsigned >, oomph::SparseMatrix< T, MATRIX_TYPE >, oomph::SparseMatrix< double, CCMatrix< double > >, oomph::SparseMatrix< double, CRMatrix< double > >, oomph::SparseMatrix< std::complex< double >, CCMatrix< std::complex< double > > >, oomph::SparseMatrix< std::complex< double >, CRMatrix< std::complex< double > > >, oomph::SparseMatrix< T, CCMatrix< T > >, oomph::SparseMatrix< T, CRMatrix< T > >, oomph::CRDoubleMatrix, oomph::DenseDoubleMatrix, oomph::CCDoubleMatrix, and oomph::SumOfMatrices.
Referenced by oomph::CCDoubleMatrix::nrow(), 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 141 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 129 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< bool >, oomph::DenseMatrix< double * >, oomph::DenseMatrix< double >, oomph::DenseMatrix< int * >, oomph::DenseMatrix< int >, oomph::DenseMatrix< oomph::CRDoubleMatrix * >, oomph::DenseMatrix< oomph::MatrixVectorProduct * >, oomph::DenseMatrix< std::complex< double > >, and oomph::DenseMatrix< unsigned >.
Definition at line 153 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::DenseMatrix< T >, oomph::DenseMatrix< bool >, oomph::DenseMatrix< double * >, oomph::DenseMatrix< double >, oomph::DenseMatrix< int * >, oomph::DenseMatrix< int >, oomph::DenseMatrix< oomph::CRDoubleMatrix * >, oomph::DenseMatrix< oomph::MatrixVectorProduct * >, oomph::DenseMatrix< std::complex< double > >, oomph::DenseMatrix< unsigned >, oomph::SparseMatrix< T, MATRIX_TYPE >, oomph::SparseMatrix< double, CCMatrix< double > >, oomph::SparseMatrix< double, CRMatrix< double > >, oomph::SparseMatrix< std::complex< double >, CCMatrix< std::complex< double > > >, oomph::SparseMatrix< std::complex< double >, CRMatrix< std::complex< double > > >, oomph::SparseMatrix< T, CCMatrix< T > >, oomph::SparseMatrix< T, CRMatrix< T > >, oomph::CRMatrix< T >, oomph::CRMatrix< double >, oomph::CRMatrix< std::complex< double > >, oomph::CRDoubleMatrix, oomph::CCMatrix< T >, oomph::CCMatrix< double >, oomph::CCMatrix< std::complex< double > >, and oomph::SumOfMatrices.
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 79 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). Final optional argument specifies max. size of entries which are set to zero on output.
Definition at line 185 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(), oomph::Matrix< T, MATRIX_TYPE >::sparse_indexed_output(), oomph::Matrix< T, MATRIX_TYPE >::sparse_indexed_output_with_cutoff(), and oomph::Matrix< T, MATRIX_TYPE >::sparse_indexed_output_with_cutoff().
|
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). Final optional argument specifies max. size of entries which are set to zero on output.
Definition at line 231 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. Final optional argument specifies max. size of entries which are set to zero on output.
Implemented in oomph::CCMatrix< T >, oomph::CCMatrix< double >, oomph::CCMatrix< std::complex< double > >, oomph::DenseMatrix< T >, oomph::DenseMatrix< bool >, oomph::DenseMatrix< double * >, oomph::DenseMatrix< double >, oomph::DenseMatrix< int * >, oomph::DenseMatrix< int >, oomph::DenseMatrix< oomph::CRDoubleMatrix * >, oomph::DenseMatrix< oomph::MatrixVectorProduct * >, oomph::DenseMatrix< std::complex< double > >, oomph::DenseMatrix< unsigned >, oomph::SparseMatrix< T, MATRIX_TYPE >, oomph::SparseMatrix< double, CCMatrix< double > >, oomph::SparseMatrix< double, CRMatrix< double > >, oomph::SparseMatrix< std::complex< double >, CCMatrix< std::complex< double > > >, oomph::SparseMatrix< std::complex< double >, CRMatrix< std::complex< double > > >, oomph::SparseMatrix< T, CCMatrix< T > >, oomph::SparseMatrix< T, CRMatrix< T > >, oomph::CRMatrix< T >, oomph::CRMatrix< double >, oomph::CRMatrix< std::complex< double > >, oomph::CRDoubleMatrix, and oomph::SumOfMatrices.
Referenced by oomph::Matrix< T, MATRIX_TYPE >::sparse_indexed_output().
|
inline |
Indexed output function to print a matrix to the stream outfile as i,j,a(i,j) for a(i,j)!=0. Final optional argument specifies max. size of entries which are set to zero on output.
Definition at line 254 of file matrices.h.
References oomph::Matrix< T, MATRIX_TYPE >::sparse_indexed_output().
|
inline |
Indexed output function to print a matrix to the stream outfile as i,j,a(i,j) for a(i,j)!=0. Final optional argument specifies max. size of entries which are set to zero on output.
Definition at line 266 of file matrices.h.
References oomph::Matrix< T, MATRIX_TYPE >::sparse_indexed_output().