//////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////// More...
#include <matrices.h>
Public Member Functions | |
SparseMatrix () | |
Default constructor. More... | |
SparseMatrix (const SparseMatrix &source_matrix) | |
Copy constructor. More... | |
void | operator= (const SparseMatrix &)=delete |
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)=delete | |
Broken copy constructor. More... | |
void | operator= (const Matrix &)=delete |
Broken assignment operator. More... | |
virtual | ~Matrix () |
Virtual (empty) destructor. 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... | |
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... | |
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
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 561 of file matrices.h.
|
inline |
Default constructor.
Definition at line 581 of file matrices.h.
|
inline |
Copy constructor.
Definition at line 584 of file matrices.h.
References i, oomph::SparseMatrix< T, MATRIX_TYPE >::M, oomph::SparseMatrix< T, MATRIX_TYPE >::N, oomph::SparseMatrix< T, MATRIX_TYPE >::ncol(), oomph::SparseMatrix< T, MATRIX_TYPE >::Nnz, oomph::SparseMatrix< T, MATRIX_TYPE >::nnz(), oomph::SparseMatrix< T, MATRIX_TYPE >::nrow(), oomph::ElementGeometry::T, oomph::SparseMatrix< T, MATRIX_TYPE >::Value, and oomph::SparseMatrix< T, MATRIX_TYPE >::value().
|
inlinevirtual |
Destructor, delete the memory associated with the values.
Definition at line 609 of file matrices.h.
References oomph::SparseMatrix< T, MATRIX_TYPE >::Value.
|
inlinevirtual |
Return the number of columns of the matrix.
Implements oomph::Matrix< T, MATRIX_TYPE >.
Reimplemented in oomph::CCDoubleMatrix.
Definition at line 634 of file matrices.h.
References oomph::SparseMatrix< T, MATRIX_TYPE >::M.
Referenced by oomph::CRDoubleMatrix::ncol(), and oomph::SparseMatrix< T, MATRIX_TYPE >::SparseMatrix().
|
inline |
Return the number of nonzero entries.
Definition at line 640 of file matrices.h.
References oomph::SparseMatrix< T, MATRIX_TYPE >::Nnz.
Referenced by oomph::SuperLUSolver::factorise_distributed(), oomph::SuperLUSolver::factorise_serial(), oomph::CRComplexMatrix::multiply(), oomph::CRDoubleMatrix::nnz(), oomph::MatrixBasedLumpedPreconditioner< MATRIX >::setup(), and oomph::SparseMatrix< T, MATRIX_TYPE >::SparseMatrix().
|
inlinevirtual |
Return the number of rows of the matrix.
Implements oomph::Matrix< T, MATRIX_TYPE >.
Reimplemented in oomph::CCDoubleMatrix.
Definition at line 628 of file matrices.h.
References oomph::SparseMatrix< T, MATRIX_TYPE >::N.
Referenced by oomph::SparseMatrix< T, MATRIX_TYPE >::SparseMatrix().
|
delete |
Broken assignment operator.
|
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 648 of file matrices.h.
References oomph::Global_string_for_annotation::string().
|
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 661 of file matrices.h.
References oomph::Global_string_for_annotation::string().
|
inline |
Access to C-style value array.
Definition at line 616 of file matrices.h.
References oomph::SparseMatrix< T, MATRIX_TYPE >::Value.
Referenced by oomph::CRComplexMatrix::add(), oomph::SuperLUSolver::factorise_distributed(), oomph::SuperLUSolver::factorise_serial(), oomph::CRDoubleMatrix::inf_norm(), oomph::CRDoubleMatrix::matrix_reduction(), oomph::CCDoubleMatrix::multiply(), oomph::CRComplexMatrix::multiply(), oomph::CRDoubleMatrix::multiply(), oomph::CRDoubleMatrix::multiply_transpose(), oomph::MatrixBasedLumpedPreconditioner< MATRIX >::setup(), oomph::ILUZeroPreconditioner< CCDoubleMatrix >::setup(), oomph::SparseMatrix< T, MATRIX_TYPE >::SparseMatrix(), and oomph::CRDoubleMatrix::value().
|
inline |
Access to C-style value array (const version)
Definition at line 622 of file matrices.h.
References oomph::SparseMatrix< T, MATRIX_TYPE >::Value.
|
protected |
Number of columns.
Definition at line 571 of file matrices.h.
Referenced by oomph::CRComplexMatrix::lubksub(), oomph::CCComplexMatrix::lubksub(), oomph::CRComplexMatrix::ludecompose(), oomph::CCComplexMatrix::ludecompose(), oomph::CCDoubleMatrix::multiply(), oomph::CRComplexMatrix::multiply(), oomph::CCComplexMatrix::multiply(), oomph::CRComplexMatrix::multiply_transpose(), oomph::CCComplexMatrix::multiply_transpose(), oomph::SparseMatrix< T, MATRIX_TYPE >::ncol(), oomph::CRComplexMatrix::residual(), oomph::CCComplexMatrix::residual(), and oomph::SparseMatrix< T, MATRIX_TYPE >::SparseMatrix().
|
protected |
Number of rows.
Definition at line 568 of file matrices.h.
Referenced by oomph::CRComplexMatrix::clean_up_memory(), oomph::CCComplexMatrix::clean_up_memory(), oomph::CRComplexMatrix::lubksub(), oomph::CCComplexMatrix::lubksub(), oomph::CRComplexMatrix::ludecompose(), oomph::CCComplexMatrix::ludecompose(), oomph::CCDoubleMatrix::multiply(), oomph::CRComplexMatrix::multiply(), oomph::CCComplexMatrix::multiply(), oomph::CCDoubleMatrix::multiply_transpose(), oomph::CRComplexMatrix::multiply_transpose(), oomph::CCComplexMatrix::multiply_transpose(), oomph::SparseMatrix< T, MATRIX_TYPE >::nrow(), oomph::CRComplexMatrix::residual(), oomph::CCComplexMatrix::residual(), and oomph::SparseMatrix< T, MATRIX_TYPE >::SparseMatrix().
|
protected |
Number of non-zero values (i.e. size of Value array)
Definition at line 574 of file matrices.h.
Referenced by oomph::CRComplexMatrix::clean_up_memory(), oomph::CCComplexMatrix::clean_up_memory(), oomph::CRComplexMatrix::lubksub(), oomph::CCComplexMatrix::lubksub(), oomph::CRComplexMatrix::ludecompose(), oomph::CCComplexMatrix::ludecompose(), oomph::CCDoubleMatrix::multiply(), oomph::SparseMatrix< T, MATRIX_TYPE >::nnz(), and oomph::SparseMatrix< T, MATRIX_TYPE >::SparseMatrix().
|
protected |
Internal representation of the matrix values, a pointer.
Definition at line 565 of file matrices.h.
Referenced by oomph::CRComplexMatrix::clean_up_memory(), oomph::CCComplexMatrix::clean_up_memory(), oomph::CRComplexMatrix::lubksub(), oomph::CCComplexMatrix::lubksub(), oomph::CRComplexMatrix::ludecompose(), oomph::CCComplexMatrix::ludecompose(), oomph::CCDoubleMatrix::matrix_reduction(), oomph::CCDoubleMatrix::multiply(), oomph::CRComplexMatrix::multiply(), oomph::CCComplexMatrix::multiply(), oomph::CCDoubleMatrix::multiply_transpose(), oomph::CRComplexMatrix::multiply_transpose(), oomph::CCComplexMatrix::multiply_transpose(), oomph::CRComplexMatrix::residual(), oomph::CCComplexMatrix::residual(), oomph::SparseMatrix< T, MATRIX_TYPE >::SparseMatrix(), oomph::SparseMatrix< T, MATRIX_TYPE >::value(), and oomph::SparseMatrix< T, MATRIX_TYPE >::~SparseMatrix().
|
staticprotected |
Dummy zero.
Definition at line 577 of file matrices.h.