Geophysical Inversion and Modelling Library  v1.3.1-2-g7599abf9
GIMLI::Matrix< ValueType > Class Template Reference

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

+ 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 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_
 

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

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

Fill Vector with 0.0. Don't change size.

◆ clear()

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

Clear the matrix and free memory.

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

Return number of colums.

Referenced by GIMLI::MRSModelling::MRSModelling().

◆ copy()

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

Force the copy of the matrix entries.

◆ mult() [1/2]

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() [2/2]

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

template<class ValueType >
void GIMLI::Matrix< ValueType >::push_back ( const Vector< ValueType > &  vec)
inline

Add another row vector add the end.

Referenced by GIMLI::MeshEntity::dNdL(), GIMLI::interpolate(), and GIMLI::RInversion::modelCellResolution().

◆ resize()

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

Resize the matrix to rows x cols.

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

◆ rowRef()

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

Return reference to row. Used for pygimli.

◆ rows()

template<class ValueType >
Index GIMLI::Matrix< ValueType >::rows ( ) const
inline

Return number of rows.

Referenced by GIMLI::evaluateQuadraturePoints().

◆ rtti()

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

Return entity rtti value.

◆ save()

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

Save matrix to file.

◆ setCol()

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

Set one specific column

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

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.

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.