strumpack::CompressedSparseMatrix< scalar_t, integer_t > Class Template Referenceabstract

Abstract base class for compressed sparse matrix storage. More...

#include <CompressedSparseMatrix.hpp>

Inheritance diagram for strumpack::CompressedSparseMatrix< scalar_t, integer_t >:

Public Member Functions

virtual ~CompressedSparseMatrix ()
 
integer_t size () const
 
integer_t nnz () const
 
const integer_t * ptr () const
 
const integer_t * ind () const
 
const scalar_t * val () const
 
integer_t * ptr ()
 
integer_t * ind ()
 
scalar_t * val ()
 
const integer_t & ptr (integer_t i) const
 
const integer_t & ind (integer_t i) const
 
const scalar_t & val (integer_t i) const
 
integer_t & ptr (integer_t i)
 
integer_t & ind (integer_t i)
 
scalar_t & val (integer_t i)
 
virtual real_t norm1 () const =0
 
bool symm_sparse () const
 
void set_symm_sparse (bool symm_sparse=true)
 
virtual void spmv (const DenseM_t &x, DenseM_t &y) const =0
 
virtual void spmv (const scalar_t *x, scalar_t *y) const =0
 
virtual void permute (const integer_t *iorder, const integer_t *order)
 
virtual void permute (const std::vector< integer_t > &iorder, const std::vector< integer_t > &order)
 
virtual void permute_columns (const std::vector< integer_t > &perm)=0
 
virtual Equil_t equilibration () const
 
virtual void equilibrate (const Equil_t &)
 
virtual Match_t matching (MatchingJob, bool apply=true)
 
virtual void apply_matching (const Match_t &)
 
virtual void symmetrize_sparsity ()
 
virtual void print () const
 
virtual void print_dense (const std::string &name) const
 
virtual void print_matrix_market (const std::string &filename) const
 
virtual int read_matrix_market (const std::string &filename)=0
 
virtual real_t max_scaled_residual (const scalar_t *x, const scalar_t *b) const =0
 
virtual real_t max_scaled_residual (const DenseM_t &x, const DenseM_t &b) const =0
 

Detailed Description

template<typename scalar_t, typename integer_t>
class strumpack::CompressedSparseMatrix< scalar_t, integer_t >

Abstract base class for compressed sparse matrix storage.

This is an abstract (pure virtual) base class for compressed sparse matrices.

This is only for square matrices!

The rows and the columns should always be sorted!

TODO make the public interface non-virtual

Template Parameters
scalar_ttype used to store matrix values
integer_ttype used for indices in the row/column pointer arrays and the column/row indices
See also
CSRMatrix, CSRMatrixMPI

Constructor & Destructor Documentation

◆ ~CompressedSparseMatrix()

template<typename scalar_t , typename integer_t >
virtual strumpack::CompressedSparseMatrix< scalar_t, integer_t >::~CompressedSparseMatrix ( )
inlinevirtual

Virtual destructor.

Member Function Documentation

◆ ind() [1/4]

template<typename scalar_t , typename integer_t >
integer_t * strumpack::CompressedSparseMatrix< scalar_t, integer_t >::ind ( )
inline

Return a pointer to the (row/column) indices. For compressed sparse row, this will return a pointer to an array of column indices, 1 for each nonzero.

See also
ptr, ind(integer_t i)

◆ ind() [2/4]

template<typename scalar_t , typename integer_t >
const integer_t * strumpack::CompressedSparseMatrix< scalar_t, integer_t >::ind ( ) const
inline

Return a (const) pointer to the (row/column) indices. For compressed sparse row, this will return a pointer to an array of column indices, 1 for each nonzero.

See also
ptr, ind(integer_t i)

◆ ind() [3/4]

template<typename scalar_t , typename integer_t >
integer_t & strumpack::CompressedSparseMatrix< scalar_t, integer_t >::ind ( integer_t  i)
inline

Access ind[i], ie, the row/column index of the i-th nonzero. This will assert that i >= 0 and i < nnz(). These assertions are removed when compiling in Release mode (adding -DNDEBUG).

◆ ind() [4/4]

template<typename scalar_t , typename integer_t >
const integer_t & strumpack::CompressedSparseMatrix< scalar_t, integer_t >::ind ( integer_t  i) const
inline

Access ind[i], ie, the row/column index of the i-th nonzero. This will assert that i >= 0 and i < nnz(). These assertions are removed when compiling in Release mode (adding -DNDEBUG).

◆ matching()

template<typename scalar_t , typename integer_t >
virtual Match_t strumpack::CompressedSparseMatrix< scalar_t, integer_t >::matching ( MatchingJob  ,
bool  apply = true 
)
virtual

◆ nnz()

template<typename scalar_t , typename integer_t >
integer_t strumpack::CompressedSparseMatrix< scalar_t, integer_t >::nnz ( ) const
inline

Return the number of nonzeros in this matrix. For distributed memory matrices, this refer to the global number of nonzeros, not the local number of nonzeros.

◆ permute()

template<typename scalar_t , typename integer_t >
virtual void strumpack::CompressedSparseMatrix< scalar_t, integer_t >::permute ( const integer_t *  iorder,
const integer_t *  order 
)
virtual

TODO Obtain reordering Anew = A(iorder,iorder). In addition, entries of IND, VAL are sorted in increasing order

Reimplemented in strumpack::CSRMatrixMPI< scalar_t, integer_t >.

◆ ptr() [1/4]

template<typename scalar_t , typename integer_t >
integer_t * strumpack::CompressedSparseMatrix< scalar_t, integer_t >::ptr ( )
inline

Return a pointer to the (row/column) pointer. For a compressed sparse row format, this will be a pointer to an array of dimension size()+1, where element ptr[i] denotes the start (in ind() or val()) of row i, and ptr[i+1] is the end of row i.

See also
ptr(integer_t i)

◆ ptr() [2/4]

template<typename scalar_t , typename integer_t >
const integer_t * strumpack::CompressedSparseMatrix< scalar_t, integer_t >::ptr ( ) const
inline

Return a (const) pointer to the (row/column) pointer. For a compressed sparse row format, this will be a pointer to an array of dimension size()+1, where element ptr[i] denotes the start (in ind() or val()) of row i, and ptr[i+1] is the end of row i.

See also
ptr(integer_t i)

◆ ptr() [3/4]

template<typename scalar_t , typename integer_t >
integer_t & strumpack::CompressedSparseMatrix< scalar_t, integer_t >::ptr ( integer_t  i)
inline

Access ptr[i], ie, the start of row i (in ind, or in val). This will assert that i >= 0 and i <= size(). These assertions are removed when compiling in Release mode (adding -DNDEBUG).

◆ ptr() [4/4]

template<typename scalar_t , typename integer_t >
const integer_t & strumpack::CompressedSparseMatrix< scalar_t, integer_t >::ptr ( integer_t  i) const
inline

Access ptr[i], ie, the start of row i (in ind, or in val). This will assert that i >= 0 and i <= size(). These assertions are removed when compiling in Release mode (adding -DNDEBUG).

◆ set_symm_sparse()

template<typename scalar_t , typename integer_t >
void strumpack::CompressedSparseMatrix< scalar_t, integer_t >::set_symm_sparse ( bool  symm_sparse = true)
inline

Specify that the sparsity pattern of this matrix is symmetric, or not.

Parameters
symm_sparsebool, set this to true (default if not provided) to specify that the sparsity pattern is symmetric

◆ size()

template<typename scalar_t , typename integer_t >
integer_t strumpack::CompressedSparseMatrix< scalar_t, integer_t >::size ( ) const
inline

Return the size of this square matrix, ie, the number of rows and columns. For distributed memory matrices, this refer to the global size, not the local size.

◆ spmv() [1/2]

template<typename scalar_t , typename integer_t >
virtual void strumpack::CompressedSparseMatrix< scalar_t, integer_t >::spmv ( const DenseM_t x,
DenseM_t y 
) const
pure virtual

Sparse matrix times dense vector/matrix product y = this * x x and y can have multiple columns. y should be pre-allocated!

TODO make the public interface non-virtual

Parameters
xinput right hand-side vector/matrix, should satisfy x.size() == this->size()
youtput, result of y = this * x, should satisfy y.size() == this->size()

Implemented in strumpack::CSRMatrix< scalar_t, integer_t >, strumpack::CSRMatrix< refine_t, integer_t >, and strumpack::CSRMatrixMPI< scalar_t, integer_t >.

◆ spmv() [2/2]

template<typename scalar_t , typename integer_t >
virtual void strumpack::CompressedSparseMatrix< scalar_t, integer_t >::spmv ( const scalar_t *  x,
scalar_t *  y 
) const
pure virtual

Sparse matrix times dense vector product y = this * x x and y can have multiple columns. y should be pre-allocated.

TODO make the public interface non-virtual

Parameters
xinput right hand-side vector/matrix, should be a pointer to an array of size size()
youtput, result of y = this * x, should be a pointer to an array of size size(), already allocated

Implemented in strumpack::CSRMatrix< refine_t, integer_t >, strumpack::CSRMatrix< scalar_t, integer_t >, and strumpack::CSRMatrixMPI< scalar_t, integer_t >.

◆ symm_sparse()

template<typename scalar_t , typename integer_t >
bool strumpack::CompressedSparseMatrix< scalar_t, integer_t >::symm_sparse ( ) const
inline

Check whether the matrix has a symmetric sparsity pattern (as specified in the constructor, will not actually check).

◆ val() [1/4]

template<typename scalar_t , typename integer_t >
scalar_t * strumpack::CompressedSparseMatrix< scalar_t, integer_t >::val ( )
inline

Return a pointer to the nonzero values. For compressed sparse row, this will return a pointer to an array of nonzero values.

See also
ptr, ind

◆ val() [2/4]

template<typename scalar_t , typename integer_t >
const scalar_t * strumpack::CompressedSparseMatrix< scalar_t, integer_t >::val ( ) const
inline

Return a (const) pointer to the nonzero values. For compressed sparse row, this will return a pointer to an array of nonzero values.

See also
ptr, ind

◆ val() [3/4]

template<typename scalar_t , typename integer_t >
scalar_t & strumpack::CompressedSparseMatrix< scalar_t, integer_t >::val ( integer_t  i)
inline

Access ind[i], ie, the value of the i-th nonzero. This will assert that i >= 0 and i < nnz(). These assertions are removed when compiling in Release mode (adding -DNDEBUG).

◆ val() [4/4]

template<typename scalar_t , typename integer_t >
const scalar_t & strumpack::CompressedSparseMatrix< scalar_t, integer_t >::val ( integer_t  i) const
inline

Access ind[i], ie, the value of the i-th nonzero. This will assert that i >= 0 and i < nnz(). These assertions are removed when compiling in Release mode (adding -DNDEBUG).


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