Geophysical Inversion and Modelling Library  v1.5.2-5-g042d7f36
GIMLI::Matrix< ValueType > Class Template Reference

Simple row-based dense matrix based on Vector. More...

+ Inheritance diagram for GIMLI::Matrix< ValueType >:
+ Collaboration diagram for GIMLI::Matrix< ValueType >:

Public Member Functions

 Matrix ()
 
 Matrix (Index rows)
 
 Matrix (Index rows, Index cols)
 
 Matrix (Index rows, Index cols, ValueType *src)
 
 Matrix (const std::vector< Vector< ValueType > > &mat)
 
 Matrix (const std::string &filename)
 
 Matrix (const Matrix< ValueType > &mat)
 
Matrix< ValueType > & operator= (const Matrix< ValueType > &mat)
 
virtual ~Matrix ()
 
void copy (const Matrix< ValueType > &mat)
 
virtual uint rtti () const
 
Vector< ValueType > & operator[] (Index i)
 
const Vector< ValueType > & operator[] (Index i) const
 
template<class T >
 operator Matrix< T > ()
 
virtual void resize (Index rows, Index cols)
 
void clear ()
 
void clean ()
 
Index rows () const
 
Index cols () const
 
void setRow (Index i, const Vector< ValueType > &val)
 
void setVal (Index i, const Vector< ValueType > &val)
 
void setVal (Index i, Index j, const ValueType &val)
 
void addVal (Index i, Index j, const ValueType &val)
 
const Vector< ValueType > & row (Index i) const
 
Vector< ValueType > & rowRef (Index i)
 
virtual const Vector< ValueType > col (Index i) const
 
void push_back (const Vector< ValueType > &vec)
 
Vector< ValueType > & back ()
 
void setCol (Index col, const Vector< ValueType > &v)
 
void addCol (Index col, const Vector< ValueType > &v)
 
BVectorrowFlag ()
 
Matrix< ValueType > & add (const Matrix< ValueType > &a)
 
Matrix< ValueType > & transAdd (const Matrix< ValueType > &a)
 
Vector< ValueType > mult (const Vector< ValueType > &b) const
 
Vector< ValueType > mult (const Vector< ValueType > &b, Index startI, Index endI) const
 
Vector< ValueType > transMult (const Vector< ValueType > &b) const
 
virtual void save (const std::string &filename) const
 
void round (const ValueType &tolerance)
 
void dumpData (ValueType *target) const
 
void fromData (ValueType *src, Index m, Index n)
 
Vector< double > mult (const Vector< double > &b) const
 
Vector< Complex > mult (const Vector< Complex > &b) const
 
Vector< double > mult (const Vector< double > &b, Index startI, Index endI) const
 
Vector< Complex > mult (const Vector< Complex > &b, Index startI, Index endI) const
 
Vector< double > transMult (const Vector< double > &b) const
 
Vector< Complex > transMult (const Vector< Complex > &b) const
 
Matrix< double > & transAdd (const Matrix< double > &a)
 
Matrix< Complex > & transAdd (const Matrix< Complex > &a)
 
DLLEXPORT Vector< double > mult (const Vector< double > &b, Index startI, Index endI) const
 
DLLEXPORT Vector< Complex > mult (const Vector< Complex > &b, Index startI, Index endI) const
 
DLLEXPORT Vector< double > mult (const Vector< double > &b) const
 
DLLEXPORT Vector< Complex > mult (const Vector< Complex > &b) const
 
DLLEXPORT Vector< double > transMult (const Vector< double > &b) const
 
DLLEXPORT Vector< Complex > transMult (const Vector< Complex > &b) const
 
DLLEXPORT Matrix< double > & transAdd (const Matrix< double > &a)
 
DLLEXPORT Matrix< Complex > & transAdd (const Matrix< Complex > &a)
 
- Public Member Functions inherited from GIMLI::MatrixBase
 MatrixBase (bool verbose=false)
 
virtual ~MatrixBase ()
 
void setVerbose (bool verbose)
 
bool verbose () const
 
Index size () const
 
virtual RVector dot (const RVector &a) const
 
virtual CVector mult (const CVector &a) const
 
virtual CVector mult (const CVector &b, Index startI, Index endI) const
 
virtual CVector transMult (const CVector &a) const
 

Public Attributes

std::vector< Vector< ValueType > > mat_
 

Protected Member Functions

void allocate_ (Index rows, Index cols)
 
void copy_ (const Matrix< ValueType > &mat)
 

Protected Attributes

BVector rowFlag_
 
- Protected Attributes inherited from GIMLI::MatrixBase
bool verbose_
 

Detailed Description

template<class ValueType>
class GIMLI::Matrix< ValueType >

Simple row-based dense matrix based on Vector.

Simple row-based dense matrix based on Vector

Constructor & Destructor Documentation

◆ Matrix() [1/4]

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

Constructs an empty matrix with the dimension rows x cols. Content of the matrix is zero.

◆ Matrix() [2/4]

template<class ValueType >
GIMLI::Matrix< ValueType >::Matrix ( const std::vector< Vector< ValueType > > &  mat)
inline

Copy constructor

◆ Matrix() [3/4]

template<class ValueType >
GIMLI::Matrix< ValueType >::Matrix ( const std::string &  filename)
inline

Constructor, read matrix from file see load(Matrix < ValueType > & A, const std::string & filename).

References GIMLI::load().

◆ Matrix() [4/4]

template<class ValueType >
GIMLI::Matrix< ValueType >::Matrix ( const Matrix< ValueType > &  mat)
inline

Copyconstructor

◆ ~Matrix()

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

Destruct matrix and free memory.

Member Function Documentation

◆ add()

template<class ValueType >
Matrix< ValueType >& GIMLI::Matrix< ValueType >::add ( const Matrix< ValueType > &  a)
inline

A += a

◆ addCol()

template<class ValueType >
void GIMLI::Matrix< ValueType >::addCol ( Index  col,
const Vector< ValueType > &  v 
)
inline

Add one specific column

◆ back()

template<class ValueType >
Vector< ValueType >& GIMLI::Matrix< ValueType >::back ( )
inline

Return last row vector.

◆ clean()

template<class ValueType >
void GIMLI::Matrix< ValueType >::clean ( )
inlinevirtual

Fill Vector with 0.0. Don't change size.

Reimplemented from GIMLI::MatrixBase.

◆ clear()

template<class ValueType >
void GIMLI::Matrix< ValueType >::clear ( )
inlinevirtual

Clear the matrix and free memory.

Reimplemented from GIMLI::MatrixBase.

Referenced by GIMLI::DataMap::collect(), and GIMLI::HarmonicModelling::HarmonicModelling().

◆ col()

template<class ValueType >
virtual const Vector< ValueType > GIMLI::Matrix< ValueType >::col ( Index  i) const
inlinevirtual

Readonly column entry of matrix, with boundary check. Probably slow.

◆ cols()

template<class ValueType >
Index GIMLI::Matrix< ValueType >::cols ( ) const
inlinevirtual

◆ copy()

template<class ValueType >
void GIMLI::Matrix< ValueType >::copy ( const Matrix< ValueType > &  mat)
inline

Force the copy of the matrix entries.

◆ mult() [1/4]

Vector< double > GIMLI::Matrix< double >::mult ( const Vector< double > &  a) const
virtual

Return this * a

Reimplemented from GIMLI::MatrixBase.

◆ mult() [2/4]

DLLEXPORT Vector< double > GIMLI::Matrix< double >::mult ( const Vector< double > &  a) const
virtual

Return this * a

Reimplemented from GIMLI::MatrixBase.

◆ mult() [3/4]

template<class ValueType >
Vector< ValueType > GIMLI::Matrix< ValueType >::mult ( const Vector< ValueType > &  b) const

Multiplication (A*b) with a vector of the same value type.

◆ mult() [4/4]

template<class ValueType >
Vector< ValueType > GIMLI::Matrix< ValueType >::mult ( const Vector< ValueType > &  b,
Index  startI,
Index  endI 
) const

Multiplication (A*b) with a part of a vector between two defined indices.

◆ operator Matrix< T >()

template<class ValueType >
template<class T >
GIMLI::Matrix< ValueType >::operator Matrix< T > ( )
inline

Implicite type converter.

◆ operator=()

template<class ValueType >
Matrix< ValueType >& GIMLI::Matrix< ValueType >::operator= ( const Matrix< ValueType > &  mat)
inline

Assignment operator

◆ operator[]() [1/2]

template<class ValueType >
Vector< ValueType >& GIMLI::Matrix< ValueType >::operator[] ( Index  i)
inline

Index operator for write operations without boundary check.

◆ operator[]() [2/2]

template<class ValueType >
const Vector< ValueType >& GIMLI::Matrix< ValueType >::operator[] ( Index  i) const
inline

Read only C style index operator, without boundary check.

◆ push_back()

◆ resize()

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

◆ round()

template<class ValueType >
void GIMLI::Matrix< ValueType >::round ( const ValueType &  tolerance)
inline

Round each matrix element to a given tolerance.

◆ row()

template<class ValueType >
const Vector< ValueType >& GIMLI::Matrix< ValueType >::row ( Index  i) const
inline

Readonly getter.

◆ rowFlag()

template<class ValueType >
BVector& GIMLI::Matrix< ValueType >::rowFlag ( )
inline

Return reference to row flag vector. Maybee you can check if the rows are valid. Size is set automatic to the amount of rows.

Referenced by GIMLI::loadMatrixSingleBin_T().

◆ rowRef()

template<class ValueType >
Vector< ValueType >& GIMLI::Matrix< ValueType >::rowRef ( Index  i)
inline

Return reference to row. Used for pygimli.

◆ rows()

◆ rtti()

template<class ValueType >
virtual uint GIMLI::Matrix< ValueType >::rtti ( ) const
inlinevirtual

Return entity rtti value.

Reimplemented from GIMLI::MatrixBase.

◆ save()

template<class ValueType >
virtual void GIMLI::Matrix< ValueType >::save ( const std::string &  filename) const
inlinevirtual

Save matrix to file.

Reimplemented from GIMLI::MatrixBase.

References GIMLI::saveMatrix().

◆ setCol()

template<class ValueType >
void GIMLI::Matrix< ValueType >::setCol ( Index  col,
const Vector< ValueType > &  v 
)
inline

Set one specific column

Referenced by GIMLI::ModellingBase::createJacobian().

◆ setRow()

template<class ValueType >
void GIMLI::Matrix< ValueType >::setRow ( Index  i,
const Vector< ValueType > &  val 
)
inline

Set a value. Throws out of range exception if index check fails.

◆ setVal()

template<class ValueType >
void GIMLI::Matrix< ValueType >::setVal ( Index  i,
const Vector< ValueType > &  val 
)
inline

Set a value. Throws out of range exception if index check fails.

◆ transAdd()

template<class ValueType >
Matrix< ValueType >& GIMLI::Matrix< ValueType >::transAdd ( const Matrix< ValueType > &  a)

A += a.T

◆ transMult() [1/3]

Vector< double > GIMLI::Matrix< double >::transMult ( const Vector< double > &  a) const
virtual

Return this.T * a

Reimplemented from GIMLI::MatrixBase.

◆ transMult() [2/3]

DLLEXPORT Vector< double > GIMLI::Matrix< double >::transMult ( const Vector< double > &  a) const
virtual

Return this.T * a

Reimplemented from GIMLI::MatrixBase.

◆ transMult() [3/3]

template<class ValueType >
Vector< ValueType > GIMLI::Matrix< ValueType >::transMult ( const Vector< ValueType > &  b) const

Transpose multiplication (A^T*b) with a vector of the same value type.

Referenced by GIMLI::MeshEntity::grad().

Member Data Documentation

◆ rowFlag_

template<class ValueType >
BVector GIMLI::Matrix< ValueType >::rowFlag_
protected

BVector flag(rows) for free use, e.g., check if rows are set valid.