Geophysical Inversion and Modelling Library  v1.3.0-2-gcf7079e5
GIMLI::SparseMatrix< ValueType > Class Template Reference

Sparse matrix in compressed row storage (CRS) form. More...

Public Member Functions

 SparseMatrix ()
 
 SparseMatrix (const SparseMatrix< ValueType > &S)
 
 SparseMatrix (const SparseMapMatrix< ValueType, Index > &S)
 
 SparseMatrix (const IndexArray &colPtr, const IndexArray &rowIdx, const Vector< ValueType > vals, int stype=0)
 
 SparseMatrix (const std::vector< int > &colPtr, const std::vector< int > &rowIdx, const Vector< ValueType > vals, int stype=0)
 
virtual ~SparseMatrix ()
 
SparseMatrix< ValueType > & operator= (const SparseMatrix< ValueType > &S)
 
SparseMatrix< ValueType > & operator= (const SparseMapMatrix< ValueType, Index > &S)
 
SparseMatrix< ValueType > & operator+= (const SparseMatrix< ValueType > &A)
 
SparseMatrix< ValueType > & operator-= (const SparseMatrix< ValueType > &A)
 
SparseMatrix< ValueType > & operator+= (const ElementMatrix< double > &A)
 
virtual uint rtti () const
 
virtual Vector< ValueType > mult (const Vector< ValueType > &a) const
 
virtual Vector< ValueType > transMult (const Vector< ValueType > &a) const
 
void add (const ElementMatrix< double > &A)
 
void add (const ElementMatrix< double > &A, ValueType scale)
 
void add (const ElementMatrix< double > &A, const Pos &scale)
 
void add (const ElementMatrix< double > &A, const Matrix< ValueType > &scale)
 
void clean ()
 
void clear ()
 
void setVal (int i, int j, ValueType val)
 
ValueType getVal (int i, int j, bool warn=true) const
 
void cleanRow (int row)
 
void cleanCol (int col)
 
void copy_ (const SparseMapMatrix< double, Index > &S)
 
void copy_ (const SparseMapMatrix< Complex, Index > &S)
 
void buildSparsityPattern (const Mesh &mesh)
 
void fillStiffnessMatrix (const Mesh &mesh)
 
void fillStiffnessMatrix (const Mesh &mesh, const RVector &a)
 
void fillMassMatrix (const Mesh &mesh)
 
void fillMassMatrix (const Mesh &mesh, const RVector &a)
 
int stype () const
 
int * colPtr ()
 
const int & colPtr () const
 
const std::vector< int > & vecColPtr () const
 
int * rowIdx ()
 
const int & rowIdx () const
 
const std::vector< int > & vecRowIdx () const
 
ValueType * vals ()
 
const Vector< ValueType > & vecVals () const
 
Vector< ValueType > & vecVals ()
 
Index size () const
 
Index nVals () const
 
Index cols () const
 
Index rows () const
 
Index nCols () const
 
Index nRows () const
 
void save (const std::string &fileName) const
 
bool valid () const
 
void copy_ (const SparseMapMatrix< double, Index > &S)
 
void copy_ (const SparseMapMatrix< Complex, Index > &S)
 
void add (const ElementMatrix< double > &A, double scale)
 
void add (const ElementMatrix< double > &A, const Pos &scale)
 
void add (const ElementMatrix< double > &A, const Matrix< double > &scale)
 
void add (const ElementMatrix< double > &A, Complex scale)
 
void add (const ElementMatrix< double > &A, const Pos &scale)
 
void add (const ElementMatrix< double > &A, const CMatrix &scale)
 
DLLEXPORT void copy_ (const SparseMapMatrix< double, Index > &S)
 
DLLEXPORT void copy_ (const SparseMapMatrix< Complex, Index > &S)
 
DLLEXPORT void add (const ElementMatrix< double > &A, double scale)
 
DLLEXPORT void add (const ElementMatrix< double > &A, const Pos &scale)
 
DLLEXPORT void add (const ElementMatrix< double > &A, const RMatrix &scale)
 
DLLEXPORT void add (const ElementMatrix< double > &A, Complex scale)
 
DLLEXPORT void add (const ElementMatrix< double > &A, const Pos &scale)
 
DLLEXPORT void add (const ElementMatrix< double > &A, const CMatrix &scale)
 

Protected Attributes

std::vector< int > colPtr_
 
std::vector< int > rowIdx_
 
Vector< ValueType > vals_
 
bool valid_
 
int stype_
 
Index rows_
 
Index cols_
 

Detailed Description

template<class ValueType>
class GIMLI::SparseMatrix< ValueType >

Sparse matrix in compressed row storage (CRS) form.

Sparse matrix in compressed row storage (CRS) form. IF you need native CCS format you need to transpose CRS Symmetry type: 0 = nonsymmetric, -1 symmetric lower part, 1 symmetric upper part.

Constructor & Destructor Documentation

◆ SparseMatrix() [1/3]

template<class ValueType >
GIMLI::SparseMatrix< ValueType >::SparseMatrix ( )
inline

Default constructor. Builds invalid sparse matrix

◆ SparseMatrix() [2/3]

template<class ValueType >
GIMLI::SparseMatrix< ValueType >::SparseMatrix ( const SparseMatrix< ValueType > &  S)
inline

◆ SparseMatrix() [3/3]

template<class ValueType >
GIMLI::SparseMatrix< ValueType >::SparseMatrix ( const SparseMapMatrix< ValueType, Index > &  S)
inline

Copy constructor.

◆ ~SparseMatrix()

template<class ValueType >
virtual GIMLI::SparseMatrix< ValueType >::~SparseMatrix ( )
inlinevirtual

Destructor

Member Function Documentation

◆ copy_()

template<typename ValueType >
void GIMLI::SparseMatrix< ValueType >::copy_ ( const SparseMapMatrix< double, Index > &  S)

SparseMatrix specialized type traits in sparsematrix.cpp

◆ getVal()

template<class ValueType >
ValueType GIMLI::SparseMatrix< ValueType >::getVal ( int  i,
int  j,
bool  warn = true 
) const
inline

Get matrix value at i,j. If i and j is not part of the matrix sparsity pattern return 0 and print a warning. This warning can be disabled by setting warn to false.

◆ mult()

template<class ValueType >
virtual Vector< ValueType > GIMLI::SparseMatrix< ValueType >::mult ( const Vector< ValueType > &  a) const
inlinevirtual

Return this * a

◆ operator=()

template<class ValueType >
SparseMatrix< ValueType >& GIMLI::SparseMatrix< ValueType >::operator= ( const SparseMatrix< ValueType > &  S)
inline

Copy assignment operator.

◆ stype()

template<class ValueType >
int GIMLI::SparseMatrix< ValueType >::stype ( ) const
inline

symmetric type. 0 = nonsymmetric, -1 symmetric lower part, 1 symmetric upper part.

◆ transMult()

template<class ValueType >
virtual Vector< ValueType > GIMLI::SparseMatrix< ValueType >::transMult ( const Vector< ValueType > &  a) const
inlinevirtual

Return this.T * a