Public Member Functions | Protected Attributes | Static Protected Attributes | List of all members
oomph::SparseMatrix< T, MATRIX_TYPE > Class Template Reference

#include <matrices.h>

+ Inheritance diagram for oomph::SparseMatrix< T, MATRIX_TYPE >:

Public Member Functions

 SparseMatrix ()
 Default constructor. More...
 
 SparseMatrix (const SparseMatrix &source_matrix)
 Copy constructor. More...
 
void operator= (const SparseMatrix &)
 Broken assignment operator. More...
 
virtual ~SparseMatrix ()
 Destructor, delete the memory associated with the values. More...
 
T * value ()
 Access to C-style value array. More...
 
const T * value () const
 Access to C-style value array (const version) More...
 
unsigned long nrow () const
 Return the number of rows of the matrix. More...
 
unsigned long ncol () const
 Return the number of columns of the matrix. More...
 
unsigned long nnz () const
 Return the number of nonzero entries. More...
 
virtual void output_bottom_right_zero_helper (std::ostream &outfile) const
 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...
 
virtual void sparse_indexed_output_helper (std::ostream &outfile) const
 Indexed output function to print a matrix to the stream outfile as i,j,a(i,j) for a(i,j)!=0 only. More...
 
- Public Member Functions inherited from oomph::Matrix< T, MATRIX_TYPE >
 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...
 
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...
 
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 Attributes

T * Value
 Internal representation of the matrix values, a pointer. More...
 
unsigned long N
 Number of rows. More...
 
unsigned long M
 Number of columns. More...
 
unsigned long Nnz
 Number of non-zero values (i.e. size of Value array) More...
 

Static Protected Attributes

static T Zero =T(0)
 Dummy zero. More...
 

Additional Inherited Members

- Protected Member Functions inherited from oomph::Matrix< T, MATRIX_TYPE >
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::SparseMatrix< T, MATRIX_TYPE >

Class for sparse matrices, that store only the non-zero values in a linear array in memory. The details of the array indexing vary depending on the storage scheme used. The MATRIX_TYPE template parameter for use in the curious recursive template pattern is included and passed directly to the base Matrix class.

Definition at line 565 of file matrices.h.

Constructor & Destructor Documentation

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

Default constructor.

Definition at line 587 of file matrices.h.

template<class T, class MATRIX_TYPE>
oomph::SparseMatrix< T, MATRIX_TYPE >::SparseMatrix ( const SparseMatrix< T, MATRIX_TYPE > &  source_matrix)
inline

Copy constructor.

Definition at line 590 of file matrices.h.

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

Destructor, delete the memory associated with the values.

Definition at line 615 of file matrices.h.

Member Function Documentation

template<class T, class MATRIX_TYPE>
unsigned long oomph::SparseMatrix< T, MATRIX_TYPE >::ncol ( ) const
inlinevirtual

Return the number of columns of the matrix.

Implements oomph::Matrix< T, MATRIX_TYPE >.

Definition at line 627 of file matrices.h.

Referenced by oomph::CRDoubleMatrix::ncol(), and oomph::SparseMatrix< double, CCMatrix< double > >::SparseMatrix().

template<class T, class MATRIX_TYPE>
unsigned long oomph::SparseMatrix< T, MATRIX_TYPE >::nnz ( ) const
inline
template<class T, class MATRIX_TYPE>
unsigned long oomph::SparseMatrix< T, MATRIX_TYPE >::nrow ( ) const
inlinevirtual

Return the number of rows of the matrix.

Implements oomph::Matrix< T, MATRIX_TYPE >.

Definition at line 624 of file matrices.h.

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

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

Broken assignment operator.

Definition at line 609 of file matrices.h.

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

Output the "bottom right" entry regardless of it being zero or not (this allows automatic detection of matrix size in e.g. matlab, python).

Implements oomph::Matrix< T, MATRIX_TYPE >.

Reimplemented in oomph::CCMatrix< T >, oomph::CCMatrix< double >, oomph::CCMatrix< std::complex< double > >, oomph::CRMatrix< T >, oomph::CRMatrix< double >, and oomph::CRMatrix< std::complex< double > >.

Definition at line 635 of file matrices.h.

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

Indexed output function to print a matrix to the stream outfile as i,j,a(i,j) for a(i,j)!=0 only.

Implements oomph::Matrix< T, MATRIX_TYPE >.

Reimplemented in oomph::CCMatrix< T >, oomph::CCMatrix< double >, oomph::CCMatrix< std::complex< double > >, oomph::CRMatrix< T >, oomph::CRMatrix< double >, and oomph::CRMatrix< std::complex< double > >.

Definition at line 649 of file matrices.h.

template<class T, class MATRIX_TYPE>
T* oomph::SparseMatrix< T, MATRIX_TYPE >::value ( )
inline
template<class T, class MATRIX_TYPE>
const T* oomph::SparseMatrix< T, MATRIX_TYPE >::value ( ) const
inline

Access to C-style value array (const version)

Definition at line 621 of file matrices.h.

Member Data Documentation

template<class T, class MATRIX_TYPE>
unsigned long oomph::SparseMatrix< T, MATRIX_TYPE >::M
protected
template<class T, class MATRIX_TYPE>
unsigned long oomph::SparseMatrix< T, MATRIX_TYPE >::N
protected
template<class T, class MATRIX_TYPE>
unsigned long oomph::SparseMatrix< T, MATRIX_TYPE >::Nnz
protected

Number of non-zero values (i.e. size of Value array)

Definition at line 579 of file matrices.h.

Referenced by oomph::SparseMatrix< double, CCMatrix< double > >::nnz(), and oomph::SparseMatrix< double, CCMatrix< double > >::SparseMatrix().

template<class T, class MATRIX_TYPE>
T* oomph::SparseMatrix< T, MATRIX_TYPE >::Value
protected
template<class T, class MATRIX_TYPE>
T oomph::SparseMatrix< T, MATRIX_TYPE >::Zero =T(0)
staticprotected

Dummy zero.

Definition at line 582 of file matrices.h.


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