Geophysical Inversion and Modeling Library  v1.0.11-38-g7483f4dd
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 (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 (const Vector< ValueType > &val, Index i)
 
void setVal (const Vector< ValueType > &val, Index i)
 
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 ()
 
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)
 
template<>
Vector< double > mult (const Vector< double > &b) const
 
template<>
Vector< Complex > mult (const Vector< Complex > &b) const
 
template<>
Vector< double > mult (const Vector< double > &b, Index startI, Index endI) const
 
template<>
Vector< Complex > mult (const Vector< Complex > &b, Index startI, Index endI) const
 
template<>
Vector< double > transMult (const Vector< double > &b) const
 
template<>
Vector< Complex > transMult (const Vector< Complex > &b) const
 
template<>
DLLEXPORT Vector< double > mult (const Vector< double > &b, Index startI, Index endI) const
 
template<>
DLLEXPORT Vector< Complex > mult (const Vector< Complex > &b, Index startI, Index endI) const
 
template<>
DLLEXPORT Vector< double > mult (const Vector< double > &b) const
 
template<>
DLLEXPORT Vector< Complex > mult (const Vector< Complex > &b) const
 
template<>
DLLEXPORT Vector< double > transMult (const Vector< double > &b) const
 
template<>
DLLEXPORT Vector< Complex > transMult (const Vector< Complex > &b) const
 
- 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).

◆ 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

◆ 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

◆ 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()

◆ copy()

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

Force the copy of the matrix entries.

◆ mult() [1/4]

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

Return this * a

Reimplemented from GIMLI::MatrixBase.

◆ mult() [2/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.

Referenced by GIMLI::inv().

◆ mult() [3/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.

◆ mult() [4/4]

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

Return this * a

Reimplemented from GIMLI::MatrixBase.

◆ 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()

◆ 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::DCSRMultiElectrodeModelling::checkPrimpotentials_(), and GIMLI::loadMatrixSingleBin().

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

Referenced by GIMLI::CreateSensitivityColMT< ValueType >::calc1().

◆ 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 ( const Vector< ValueType > &  val,
Index  i 
)
inline

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

◆ setVal()

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

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

◆ transMult() [1/3]

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

Return this.T * a

Reimplemented from GIMLI::MatrixBase.

◆ transMult() [2/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::inv().

◆ transMult() [3/3]

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

Return this.T * a

Reimplemented from GIMLI::MatrixBase.

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.