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)=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...
 
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 73 of file matrices.h.

Constructor & Destructor Documentation

◆ Matrix() [1/2]

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

(Empty) constructor

Definition at line 105 of file matrices.h.

◆ Matrix() [2/2]

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

Broken copy constructor.

◆ ~Matrix()

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

Virtual (empty) destructor.

Definition at line 114 of file matrices.h.

Member Function Documentation

◆ ncol()

template<class T , class MATRIX_TYPE >
virtual unsigned long oomph::Matrix< T, MATRIX_TYPE >::ncol ( ) const
pure virtual

◆ nrow()

template<class T , class MATRIX_TYPE >
virtual unsigned long oomph::Matrix< T, MATRIX_TYPE >::nrow ( ) const
pure virtual

◆ operator()() [1/2]

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

References i.

◆ operator()() [2/2]

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 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().

◆ operator=()

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

Broken assignment operator.

◆ output()

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< int * >, and oomph::DenseMatrix< bool >.

Definition at line 152 of file matrices.h.

◆ output_bottom_right_zero_helper()

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

◆ range_check()

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 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().

◆ sparse_indexed_output() [1/2]

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 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().

◆ sparse_indexed_output() [2/2]

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

References oomph::Matrix< T, MATRIX_TYPE >::sparse_indexed_output().

◆ sparse_indexed_output_helper()

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: