Geophysical Inversion and Modeling Library  v1.0.11-38-g7483f4dd
GIMLI::SparseMapMatrix< ValueType, IndexType > Class Template Reference

based on: Ulrich Breymann, Addison Wesley Longman 2000 , revised edition ISBN 0-201-67488-2, Designing Components with the C++ STL More...

+ Inheritance diagram for GIMLI::SparseMapMatrix< ValueType, IndexType >:
+ Collaboration diagram for GIMLI::SparseMapMatrix< ValueType, IndexType >:

Classes

class  Aux
 

Public Types

typedef std::pair< IndexType, IndexType > IndexPair
 
typedef std::map< IndexPair, ValueType, std::less< IndexPair > > ContainerType
 
typedef ContainerType::iterator iterator
 
typedef ContainerType::const_iterator const_iterator
 
typedef MatrixElement< ValueType, IndexType, ContainerType > MatElement
 

Public Member Functions

 SparseMapMatrix (IndexType r=0, IndexType c=0, int stype=0)
 
 SparseMapMatrix (const std::string &filename)
 
 SparseMapMatrix (const SparseMapMatrix< ValueType, IndexType > &S)
 
 SparseMapMatrix (const SparseMatrix< ValueType > &S)
 
 SparseMapMatrix (const IndexArray &i, const IndexArray &j, const RVector &v)
 
SparseMapMatrix< ValueType, IndexType > & operator= (const SparseMapMatrix< ValueType, IndexType > &S)
 
SparseMapMatrixoperator= (const SparseMatrix< ValueType > &S)
 
virtual uint rtti () const
 
void resize (Index rows, Index cols)
 
void copy_ (const SparseMatrix< double > &S)
 
void copy_ (const SparseMatrix< Complex > &S)
 
void insert (const IndexArray &rows, const IndexArray &cols, const RVector &vals)
 
virtual void clear ()
 
int stype () const
 
void setRows (IndexType r)
 
virtual IndexType rows () const
 
virtual IndexType nRows () const
 
void setCols (IndexType c)
 
virtual IndexType cols () const
 
virtual IndexType nCols () const
 
IndexType size () const
 
IndexType max_size () const
 
IndexType nVals () const
 
iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
void addToCol (Index id, const ElementMatrix< double > &A, bool isDiag=false)
 
void addToRow (Index id, const ElementMatrix< double > &A, bool isDiag=false)
 
void add (const ElementMatrix< double > &A)
 
SparseMapMatrix< ValueType, IndexType > & operator+= (const SparseMapMatrix< ValueType, IndexType > &A)
 
SparseMapMatrix< ValueType, IndexType > & operator-= (const SparseMapMatrix< ValueType, IndexType > &A)
 
void operator+= (const ElementMatrix< double > &A)
 
Aux operator[] (IndexType r)
 
IndexType idx1 (const const_iterator &I) const
 
IndexType idx2 (const const_iterator &I) const
 
const ValueType & val (const const_iterator &I) const
 
ValueType & val (const iterator &I)
 
ValueType getVal (IndexType i, IndexType j)
 
void setVal (IndexType i, IndexType j, const ValueType &val)
 
void addVal (IndexType i, IndexType j, const ValueType &val)
 
virtual Vector< ValueType > mult (const Vector< ValueType > &a) const
 
virtual Vector< ValueType > transMult (const Vector< ValueType > &a) const
 
virtual Vector< ValueType > col (const Index i)
 
virtual Vector< ValueType > row (const Index i)
 
void save (const std::string &filename) const
 
void load (const std::string &filename)
 
void importCol (const std::string &filename, double dropTol, Index colOffset)
 
void importCol (const std::string &filename, double dropTol=1e-3)
 
void fillArrays (Vector< ValueType > &vals, IndexArray &rows, IndexArray &cols)
 
template<>
void copy_ (const SparseMatrix< double > &S)
 
template<>
DLLEXPORT void copy_ (const SparseMatrix< double > &S)
 
- Public Member Functions inherited from GIMLI::MatrixBase
 MatrixBase (bool verbose=false)
 
virtual ~MatrixBase ()
 
void setVerbose (bool verbose)
 
bool verbose () const
 
Index size () const
 
virtual void clean ()
 
virtual RVector dot (const RVector &a) const
 
virtual RVector mult (const RVector &a) const
 
virtual CVector mult (const CVector &a) const
 
virtual RVector mult (const RVector &b, Index startI, Index endI) const
 
virtual CVector mult (const CVector &b, Index startI, Index endI) const
 
virtual RVector transMult (const RVector &a) const
 
virtual CVector transMult (const CVector &a) const
 

Protected Attributes

IndexType rows_
 
IndexType cols_
 
ContainerType C_
 
int stype_
 
- Protected Attributes inherited from GIMLI::MatrixBase
bool verbose_
 

Detailed Description

template<class ValueType, class IndexType>
class GIMLI::SparseMapMatrix< ValueType, IndexType >

based on: Ulrich Breymann, Addison Wesley Longman 2000 , revised edition ISBN 0-201-67488-2, Designing Components with the C++ STL

Constructor & Destructor Documentation

◆ SparseMapMatrix() [1/2]

template<class ValueType, class IndexType>
GIMLI::SparseMapMatrix< ValueType, IndexType >::SparseMapMatrix ( IndexType  r = 0,
IndexType  c = 0,
int  stype = 0 
)
inline

stype .. symmetric style. stype=0 (full), stype=1 (UpperRight), stype=2 (LowerLeft)

◆ SparseMapMatrix() [2/2]

template<class ValueType, class IndexType>
GIMLI::SparseMapMatrix< ValueType, IndexType >::SparseMapMatrix ( const IndexArray i,
const IndexArray j,
const RVector v 
)
inline

Contruct Map Matrix from 3 arrays of the same length. Number of colums are max(j)+1 and Number of rows are max(i)+1.

Member Function Documentation

◆ clear()

template<class ValueType, class IndexType>
virtual void GIMLI::SparseMapMatrix< ValueType, IndexType >::clear ( )
inlinevirtual

Clear the data, set size to zero and frees memory.

Reimplemented from GIMLI::MatrixBase.

Referenced by GIMLI::TravelTimeDijkstraModelling::createJacobian(), and GIMLI::RegionManager::fillConstraints().

◆ cols()

template<class ValueType, class IndexType>
virtual IndexType GIMLI::SparseMapMatrix< ValueType, IndexType >::cols ( ) const
inlinevirtual

◆ copy_()

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

Implement specialized type traits in sparsematrix.cpp

◆ fillArrays()

template<class ValueType, class IndexType>
void GIMLI::SparseMapMatrix< ValueType, IndexType >::fillArrays ( Vector< ValueType > &  vals,
IndexArray rows,
IndexArray cols 
)
inline

Fill existing arrays with values, row and column indieces of this SparseMapMatrix

Referenced by GIMLI::BlockMatrix< ValueType >::save().

◆ importCol()

template<class ValueType, class IndexType>
void GIMLI::SparseMapMatrix< ValueType, IndexType >::importCol ( const std::string &  filename,
double  dropTol,
Index  colOffset 
)
inline

Import columnwise from bmat starting at offset

Referenced by GIMLI::DCMultiElectrodeModelling::prepareJacobianT_().

◆ mult()

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

◆ resize()

template<class ValueType, class IndexType>
void GIMLI::SparseMapMatrix< ValueType, IndexType >::resize ( Index  rows,
Index  cols 
)
inlinevirtual

Resize this matrix to rows, cols

Reimplemented from GIMLI::MatrixBase.

Referenced by GIMLI::Mesh::interpolationMatrix().

◆ rows()

template<class ValueType, class IndexType>
virtual IndexType GIMLI::SparseMapMatrix< ValueType, IndexType >::rows ( ) const
inlinevirtual

◆ rtti()

template<class ValueType, class IndexType>
virtual uint GIMLI::SparseMapMatrix< ValueType, IndexType >::rtti ( ) const
inlinevirtual

Return entity rtti value.

Reimplemented from GIMLI::MatrixBase.

◆ save()

template<class ValueType, class IndexType>
void GIMLI::SparseMapMatrix< ValueType, IndexType >::save ( const std::string &  filename) const
inlinevirtual

Brute force column separation fallback .. should be overwriten if you need performance for your onw matrix type.

Brute force row separation fallback .. should be overwriten if you need performance for your onw matrix type.

Brute force column separation fallback .. should be overwriten if you need performance for your onw matrix type.

Brute force row separation fallback .. should be overwriten if you need performance for your onw matrix type.

Save this matrix into the file filename given.

Reimplemented from GIMLI::MatrixBase.

Referenced by GIMLI::SparseMapMatrix< double, Index >::fillArrays().

◆ stype()

template<class ValueType, class IndexType>
int GIMLI::SparseMapMatrix< ValueType, IndexType >::stype ( ) const
inline

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

Referenced by GIMLI::SparseMapMatrix< double, Index >::SparseMapMatrix().

◆ transMult()

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