Public Member Functions | Protected Member Functions | List of all members
oomph::Matrix< T, MATRIX_TYPE > Class Template Referenceabstract

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 More...
 
 Matrix (const Matrix &matrix)
 Broken copy constructor. More...
 
void operator= (const Matrix &)
 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...
 
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...
 

Detailed Description

template<class T, class MATRIX_TYPE>
class oomph::Matrix< T, MATRIX_TYPE >

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 78 of file matrices.h.

Constructor & Destructor Documentation

template<class T, class MATRIX_TYPE>
oomph::Matrix< T, MATRIX_TYPE >::Matrix ( )
inline

(Empty) constructor

Definition at line 113 of file matrices.h.

template<class T, class MATRIX_TYPE>
oomph::Matrix< T, MATRIX_TYPE >::Matrix ( const Matrix< T, MATRIX_TYPE > &  matrix)
inline

Broken copy constructor.

Definition at line 116 of file matrices.h.

template<class T, class MATRIX_TYPE>
virtual oomph::Matrix< T, MATRIX_TYPE >::~Matrix ( )
inlinevirtual

Virtual (empty) destructor.

Definition at line 128 of file matrices.h.

Member Function Documentation

template<class T, class MATRIX_TYPE>
virtual unsigned long oomph::Matrix< T, MATRIX_TYPE >::ncol ( ) const
pure virtual
template<class T, class MATRIX_TYPE>
virtual unsigned long oomph::Matrix< T, MATRIX_TYPE >::nrow ( ) const
pure virtual
template<class T, class MATRIX_TYPE>
T oomph::Matrix< T, MATRIX_TYPE >::operator() ( const unsigned long &  i,
const unsigned long &  j 
) const
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 142 of file matrices.h.

template<class T, class MATRIX_TYPE>
T& oomph::Matrix< T, MATRIX_TYPE >::operator() ( const unsigned long &  i,
const unsigned long &  j 
)
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 155 of file matrices.h.

template<class T, class MATRIX_TYPE>
void oomph::Matrix< T, MATRIX_TYPE >::operator= ( const Matrix< T, MATRIX_TYPE > &  )
inline

Broken assignment operator.

Definition at line 122 of file matrices.h.

template<class T, class MATRIX_TYPE>
virtual void oomph::Matrix< T, MATRIX_TYPE >::output ( std::ostream &  outfile) const
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< bool >, and oomph::DenseMatrix< int * >.

Definition at line 168 of file matrices.h.

template<class T, class MATRIX_TYPE>
virtual void oomph::Matrix< T, MATRIX_TYPE >::output_bottom_right_zero_helper ( std::ostream &  outfile) const
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::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< std::complex< double >, CCMatrix< std::complex< double > > >, oomph::SparseMatrix< double, CRMatrix< double > >, oomph::SparseMatrix< T, CRMatrix< T > >, oomph::SparseMatrix< std::complex< double >, CRMatrix< std::complex< double > > >, oomph::SparseMatrix< double, CCMatrix< double > >, 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< bool >, oomph::DenseMatrix< int * >, and oomph::SumOfMatrices.

Referenced by oomph::Matrix< double, CCMatrix< double > >::sparse_indexed_output().

template<class T, class MATRIX_TYPE>
void oomph::Matrix< T, MATRIX_TYPE >::range_check ( const unsigned long &  i,
const unsigned long &  j 
) const
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 85 of file matrices.h.

template<class T, class MATRIX_TYPE>
void oomph::Matrix< T, MATRIX_TYPE >::sparse_indexed_output ( std::ostream &  outfile,
const unsigned &  precision = 0,
const bool &  output_bottom_right_zero = false 
) const
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 197 of file matrices.h.

Referenced by oomph::Matrix< double, CCMatrix< double > >::sparse_indexed_output().

template<class T, class MATRIX_TYPE>
void oomph::Matrix< T, MATRIX_TYPE >::sparse_indexed_output ( std::string  filename,
const unsigned &  precision = 0,
const bool &  output_bottom_right_zero = false 
) const
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 240 of file matrices.h.

template<class T, class MATRIX_TYPE>
virtual void oomph::Matrix< T, MATRIX_TYPE >::sparse_indexed_output_helper ( std::ostream &  outfile) const
pure virtual

The documentation for this class was generated from the following file: