Geophysical Inversion and Modelling Library  v1.5.1
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 add (const IndexArray &rows, const IndexArray &cols, const RVector &vals)
 
virtual void clear ()
 
void cleanRow (IndexType row)
 
void cleanCol (IndexType col)
 
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 add (const ElementMatrix< double > &A, ValueType scale=1.0)
 
void add (const ElementMatrix< double > &A, const Pos &scale)
 
void add (const ElementMatrix< double > &A, const Matrix< ValueType > &scale)
 
void add (const ElementMatrix< double > &A, const Vector< ValueType > &scale)
 
void addToCol (Index id, const ElementMatrix< double > &A, ValueType scale=1.0, bool isDiag=false)
 
void addToRow (Index id, const ElementMatrix< double > &A, ValueType scale=1.0, bool isDiag=false)
 
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)
 
Vector< ValueType > values () const
 
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)
 
void copy_ (const SparseMatrix< double > &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 RMatrix &scale)
 
void add (const ElementMatrix< double > &A, const Vector< double > &scale)
 
void add (const ElementMatrix< double > &A, Complex scale)
 
void add (const ElementMatrix< double > &A, const Vector< Complex > &scale)
 
void add (const ElementMatrix< double > &A, const CMatrix &scale)
 
void add (const ElementMatrix< double > &A, const Pos &scale)
 
void addToCol (Index id, const ElementMatrix< double > &A, double scale, bool isDiag)
 
void addToRow (Index id, const ElementMatrix< double > &A, double scale, bool isDiag)
 
void addToCol (Index id, const ElementMatrix< double > &A, Complex scale, bool isDiag)
 
void addToRow (Index id, const ElementMatrix< double > &A, Complex scale, bool isDiag)
 
DLLEXPORT void copy_ (const SparseMatrix< double > &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, const Vector< double > &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 Matrix< Complex > &scale)
 
DLLEXPORT void add (const ElementMatrix< double > &A, const Vector< Complex > &scale)
 
DLLEXPORT void addToCol (Index id, const ElementMatrix< double > &A, double scale, bool isDiag)
 
DLLEXPORT void addToRow (Index id, const ElementMatrix< double > &A, double scale, bool isDiag)
 
DLLEXPORT void addToCol (Index id, const ElementMatrix< double > &A, Complex scale, bool isDiag)
 
DLLEXPORT void addToRow (Index id, const ElementMatrix< double > &A, Complex scale, bool isDiag)
 
- 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

◆ add() [1/3]

template<class ValueType , class IndexType >
void GIMLI::SparseMapMatrix< ValueType, IndexType >::add ( const ElementMatrix< double > &  A,
const Vector< ValueType > &  scale 
)

Scale with values from vector scale. Take values from scale[A.ids()].

◆ add() [2/3]

template<class ValueType , class IndexType >
void GIMLI::SparseMapMatrix< ValueType, IndexType >::add ( const ElementMatrix< double > &  A,
ValueType  scale = 1.0 
)

Scale with scale

◆ add() [3/3]

template<class ValueType , class IndexType >
void GIMLI::SparseMapMatrix< ValueType, IndexType >::add ( const IndexArray rows,
const IndexArray cols,
const RVector vals 
)
inline

◆ 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::RegionManager::fillConstraints().

◆ cols()

◆ copy_()

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

SparseMapMatrix 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

◆ importCol()

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

◆ 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

◆ rows()

◆ 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. ‍/ template< class ValueType > const Vector < ValueType > row(Index r) const{ __M ASSERT_RANGE(r, 0, rows()) Vector < ValueType > b(rows(), 0.0); b[r] = 1.0; return this->transMult(b); } these template function above will not work until MatrixBase is a non template function /! 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. *‍/ virtual const RVector row(Index r) const { __M ASSERT_RANGE(r, 0, rows()) RVector b(rows(), 0.0); b[r] = 1.0; return this->transMult(b); }

/*! Save this matrix into the file filename given. 

Reimplemented from GIMLI::MatrixBase.

◆ 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.

◆ transMult()

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