OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
interpolation::MMatrix< Tmplt > Class Template Reference

#include <MMatrix.h>

Collaboration diagram for interpolation::MMatrix< Tmplt >:
Collaboration graph

Public Member Functions

 MMatrix ()
 default constructor makes an empty MMatrix of size (0,0)
 
 MMatrix (const MMatrix< Tmplt > &mv)
 Copy constructor makes a deep copy of mv.
 
 MMatrix (size_t nrows, size_t ncols, Tmplt *data_beginning)
 Construct a matrix and fill with data from memory data_beginning.
 
 MMatrix (size_t nrows, size_t ncols, Tmplt value)
 Construct a matrix and fill with identical data.
 
 MMatrix (size_t nrows, size_t ncols)
 Construct a matrix and fill all fields with 0.
 
 ~MMatrix ()
 destructor
 
size_t num_row () const
 returns number of rows in the matrix
 
size_t num_col () const
 returns number of columns in the matrix
 
Tmplt trace () const
 returns sum of terms with row == column, even if matrix is not square
 
Tmplt determinant () const
 returns matrix determinant; throws an exception if matrix is not square
 
MMatrix< Tmplt > inverse () const
 returns matrix inverse leaving this matrix unchanged
 
void invert ()
 turns this matrix into its inverse
 
MMatrix< Tmplt > T () const
 returns matrix transpose T (such that M(i,j) = T(j,i))
 
MVector< m_complexeigenvalues () const
 returns a vector of eigenvalues. Throws an exception if either this matrix is not square or the eigenvalues could not be found (e.g. singular matrix or whatever).
 
std::pair< MVector< m_complex >, MMatrix< m_complex > > eigenvectors () const
 
MMatrix< Tmplt > sub (size_t min_row, size_t max_row, size_t min_col, size_t max_col) const
 
MVector< Tmplt > get_mvector (size_t column) const
 
const Tmplt & operator() (size_t row, size_t column) const
 
Tmplt & operator() (size_t row, size_t column)
 
MMatrix< Tmplt > & operator= (const MMatrix< Tmplt > &mm)
 
MMatrix< double > & operator= (const MMatrix< double > &mm)
 
MMatrix< m_complex > & operator= (const MMatrix< m_complex > &mm)
 
 MMatrix (const MMatrix< double > &mm)
 
 MMatrix (const MMatrix< m_complex > &mm)
 
m_complex determinant () const
 
double determinant () const
 
void invert ()
 
void invert ()
 
MMatrix< double > T () const
 
MMatrix< m_complexT () const
 
size_t num_row () const
 
size_t num_row () const
 
size_t num_col () const
 
size_t num_col () const
 
const double inline & operator() (size_t i, size_t j) const
 
const m_complex inline & operator() (size_t i, size_t j) const
 
double inline & operator() (size_t i, size_t j)
 
m_complex inline & operator() (size_t i, size_t j)
 

Static Public Member Functions

static MMatrix< Tmplt > Diagonal (size_t i, Tmplt diag_value, Tmplt off_diag_value)
 Construct a square matrix filling on and off diagonal values.
 

Private Member Functions

void build_matrix (size_t i, size_t j)
 
void build_matrix (size_t i, size_t j, Tmplt *temp)
 
void delete_matrix ()
 
void delete_matrix ()
 
void delete_matrix ()
 
void build_matrix (size_t i, size_t j)
 
void build_matrix (size_t i, size_t j)
 
void build_matrix (size_t i, size_t j, double *data)
 
void build_matrix (size_t i, size_t j, m_complex *data)
 

Static Private Member Functions

static gsl_matrixget_matrix (const MMatrix< double > &m)
 
static gsl_matrix_complexget_matrix (const MMatrix< m_complex > &m)
 

Private Attributes

void * _matrix
 

Friends

class MMatrix< double >
 
MMatrix< m_complex > & operator*= (MMatrix< m_complex > &m, m_complex c)
 
MMatrix< double > & operator*= (MMatrix< double > &m, double d)
 
MMatrix< m_complex > & operator*= (MMatrix< m_complex > &m1, MMatrix< m_complex > m2)
 
MMatrix< double > & operator*= (MMatrix< double > &m1, MMatrix< double > m2)
 
MVector< m_complexoperator* (MMatrix< m_complex > m, MVector< m_complex > v)
 
MVector< double > operator* (MMatrix< double > m, MVector< double > v)
 
MMatrix< m_complex > & operator+= (MMatrix< m_complex > &m1, const MMatrix< m_complex > &m2)
 
MMatrix< double > & operator+= (MMatrix< double > &m1, const MMatrix< double > &m2)
 
template<class Tmplt2 >
MMatrix< Tmplt2 > operator+ (MMatrix< Tmplt2 > m1, const MMatrix< Tmplt2 > m2)
 

Detailed Description

template<class Tmplt>
class interpolation::MMatrix< Tmplt >

C++ wrapper for GSL matrix MMatrix class handles matrix algebra, maths operators and some higher level calculation like matrix inversion, eigenvector analysis etc

Use template to define two types:
(i) MMatrix<double> is a matrix of doubles
(ii) MMatrix<m_complex> is a matrix of m_complex
Maths operators and a few others are defined, but maths operators don't allow operations between types - i.e. you can't multiply a complex matrix by a double matrix. Instead use interface methods like real() and complex() to convert between types first

Definition at line 62 of file MMatrix.h.

Constructor & Destructor Documentation

◆ MMatrix() [1/7]

template<class Tmplt >
template interpolation::MMatrix< Tmplt >::MMatrix ( )

default constructor makes an empty MMatrix of size (0,0)

Definition at line 41 of file MMatrix.cpp.

◆ MMatrix() [2/7]

template<class Tmplt >
interpolation::MMatrix< Tmplt >::MMatrix ( const MMatrix< Tmplt > &  mv)

Copy constructor makes a deep copy of mv.

◆ MMatrix() [3/7]

template<class Tmplt >
interpolation::MMatrix< Tmplt >::MMatrix ( size_t  nrows,
size_t  ncols,
Tmplt *  data_beginning 
)

Construct a matrix and fill with data from memory data_beginning.

Parameters
nrowsnumber of rows
ncolsnumber of columns
data_beginningpointer to the start of a memory block of size nrows*ncols with data laid out <row> <row> <row>. Note MMatrix does not take ownership of memory in data_beginning.

Definition at line 119 of file MMatrix.cpp.

References interpolation::MMatrix< Tmplt >::build_matrix().

Here is the call graph for this function:

◆ MMatrix() [4/7]

template<class Tmplt >
interpolation::MMatrix< Tmplt >::MMatrix ( size_t  nrows,
size_t  ncols,
Tmplt  value 
)

Construct a matrix and fill with identical data.

Parameters
nrowsnumber of rows
ncolsnumber of columns
valuevariable to be copied into all items in the matrix

Definition at line 124 of file MMatrix.cpp.

◆ MMatrix() [5/7]

template<class Tmplt >
interpolation::MMatrix< Tmplt >::MMatrix ( size_t  nrows,
size_t  ncols 
)

Construct a matrix and fill all fields with 0.

Parameters
nrowsnumber of rows
ncolsnumber of columns

Definition at line 132 of file MMatrix.cpp.

◆ ~MMatrix()

template<class Tmplt >
template interpolation::MMatrix< Tmplt >::~MMatrix ( )

destructor

Definition at line 150 of file MMatrix.cpp.

◆ MMatrix() [6/7]

interpolation::MMatrix< double >::MMatrix ( const MMatrix< double > &  mm)

◆ MMatrix() [7/7]

Member Function Documentation

◆ build_matrix() [1/6]

void interpolation::MMatrix< double >::build_matrix ( size_t  i,
size_t  j 
)
private

Definition at line 157 of file MMatrix.cpp.

References gsl_matrix_alloc().

Here is the call graph for this function:

◆ build_matrix() [2/6]

void interpolation::MMatrix< m_complex >::build_matrix ( size_t  i,
size_t  j 
)
private

Definition at line 162 of file MMatrix.cpp.

References gsl_matrix_complex_alloc().

Here is the call graph for this function:

◆ build_matrix() [3/6]

template<class Tmplt >
void interpolation::MMatrix< Tmplt >::build_matrix ( size_t  i,
size_t  j 
)
private

◆ build_matrix() [4/6]

void interpolation::MMatrix< double >::build_matrix ( size_t  i,
size_t  j,
double *  data 
)
private

Definition at line 167 of file MMatrix.cpp.

◆ build_matrix() [5/6]

void interpolation::MMatrix< m_complex >::build_matrix ( size_t  i,
size_t  j,
m_complex data 
)
private

Definition at line 175 of file MMatrix.cpp.

References gsl_matrix_complex_alloc().

Here is the call graph for this function:

◆ build_matrix() [6/6]

template<class Tmplt >
void interpolation::MMatrix< Tmplt >::build_matrix ( size_t  i,
size_t  j,
Tmplt *  temp 
)
private

◆ delete_matrix() [1/3]

void interpolation::MMatrix< double >::delete_matrix ( )
private

Definition at line 63 of file MMatrix.cpp.

References gsl_matrix_free().

Here is the call graph for this function:

◆ delete_matrix() [2/3]

void interpolation::MMatrix< m_complex >::delete_matrix ( )
private

Definition at line 69 of file MMatrix.cpp.

References gsl_matrix_complex_free().

Here is the call graph for this function:

◆ delete_matrix() [3/3]

template<class Tmplt >
void interpolation::MMatrix< Tmplt >::delete_matrix ( )
private

◆ determinant() [1/3]

◆ determinant() [2/3]

double interpolation::MMatrix< double >::determinant ( ) const

Definition at line 199 of file MMatrix.cpp.

References interpolation::MMatrix< Tmplt >::_matrix, gsl_linalg_LU_decomp(), gsl_linalg_LU_det(), gsl_permutation_alloc(), and gsl_permutation_free().

Here is the call graph for this function:

◆ determinant() [3/3]

template<class Tmplt >
Tmplt interpolation::MMatrix< Tmplt >::determinant ( ) const

returns matrix determinant; throws an exception if matrix is not square

◆ Diagonal()

template<class Tmplt >
MMatrix< Tmplt > interpolation::MMatrix< Tmplt >::Diagonal ( size_t  i,
Tmplt  diag_value,
Tmplt  off_diag_value 
)
static

Construct a square matrix filling on and off diagonal values.

Parameters
inumber of rows and number of columns
diag_valuefill values with row == column (i.e. on the diagonal) with this value
off_diag_valuefill values with row != column (i.e. off the diagonal) with this value

Definition at line 137 of file MMatrix.cpp.

◆ eigenvalues()

template<class Tmplt >
template MVector< m_complex > interpolation::MMatrix< Tmplt >::eigenvalues ( ) const

returns a vector of eigenvalues. Throws an exception if either this matrix is not square or the eigenvalues could not be found (e.g. singular matrix or whatever).

Definition at line 296 of file MMatrix.cpp.

References interpolation::MVector< Tmplt >::get_vector(), gsl_eigen_nonsymm(), gsl_eigen_nonsymm_alloc(), gsl_eigen_nonsymm_free(), gsl_eigen_nonsymm_params(), and interpolation::m_complex_build().

Here is the call graph for this function:

◆ eigenvectors()

template<class Tmplt >
template std::pair< MVector< m_complex >, MMatrix< m_complex > > interpolation::MMatrix< Tmplt >::eigenvectors ( ) const

Definition at line 315 of file MMatrix.cpp.

References interpolation::MVector< Tmplt >::get_vector(), gsl_eigen_nonsymmv(), gsl_eigen_nonsymmv_alloc(), and gsl_eigen_nonsymmv_free().

Here is the call graph for this function:

◆ get_matrix() [1/2]

template<class Tmplt >
gsl_matrix inline * interpolation::MMatrix< Tmplt >::get_matrix ( const MMatrix< double > &  m)
staticprivate

Definition at line 396 of file MMatrix.h.

References interpolation::MMatrix< Tmplt >::_matrix.

◆ get_matrix() [2/2]

template<class Tmplt >
gsl_matrix_complex inline * interpolation::MMatrix< Tmplt >::get_matrix ( const MMatrix< m_complex > &  m)
staticprivate

Definition at line 404 of file MMatrix.h.

References interpolation::MMatrix< Tmplt >::_matrix.

◆ get_mvector()

template<class Tmplt >
template MVector< m_complex > interpolation::MMatrix< Tmplt >::get_mvector ( size_t  column) const

Definition at line 421 of file MMatrix.cpp.

◆ inverse()

template<class Tmplt >
MMatrix< Tmplt > interpolation::MMatrix< Tmplt >::inverse ( ) const

returns matrix inverse leaving this matrix unchanged

Definition at line 213 of file MMatrix.cpp.

References interpolation::MMatrix< Tmplt >::invert().

Here is the call graph for this function:

◆ invert() [1/3]

◆ invert() [2/3]

void interpolation::MMatrix< double >::invert ( )

Definition at line 239 of file MMatrix.cpp.

References interpolation::MMatrix< Tmplt >::_matrix, gsl_linalg_LU_decomp(), gsl_linalg_LU_invert(), gsl_permutation_alloc(), and gsl_permutation_free().

Here is the call graph for this function:

◆ invert() [3/3]

template<class Tmplt >
void interpolation::MMatrix< Tmplt >::invert ( )

◆ num_col() [1/3]

◆ num_col() [2/3]

size_t interpolation::MMatrix< double >::num_col ( ) const
inline

Definition at line 263 of file MMatrix.h.

◆ num_col() [3/3]

size_t interpolation::MMatrix< m_complex >::num_col ( ) const
inline

Definition at line 269 of file MMatrix.h.

◆ num_row() [1/3]

◆ num_row() [2/3]

size_t interpolation::MMatrix< double >::num_row ( ) const
inline

Definition at line 253 of file MMatrix.h.

◆ num_row() [3/3]

size_t interpolation::MMatrix< m_complex >::num_row ( ) const
inline

Definition at line 258 of file MMatrix.h.

◆ operator()() [1/6]

double inline & interpolation::MMatrix< double >::operator() ( size_t  i,
size_t  j 
)

Definition at line 368 of file MMatrix.h.

References gsl_matrix_ptr().

Here is the call graph for this function:

◆ operator()() [2/6]

m_complex inline & interpolation::MMatrix< m_complex >::operator() ( size_t  i,
size_t  j 
)

Definition at line 372 of file MMatrix.h.

References gsl_matrix_complex_ptr().

Here is the call graph for this function:

◆ operator()() [3/6]

const double inline & interpolation::MMatrix< double >::operator() ( size_t  i,
size_t  j 
) const

Definition at line 359 of file MMatrix.h.

References gsl_matrix_ptr().

Here is the call graph for this function:

◆ operator()() [4/6]

const m_complex inline & interpolation::MMatrix< m_complex >::operator() ( size_t  i,
size_t  j 
) const

Definition at line 363 of file MMatrix.h.

References gsl_matrix_complex_ptr().

Here is the call graph for this function:

◆ operator()() [5/6]

template<class Tmplt >
Tmplt & interpolation::MMatrix< Tmplt >::operator() ( size_t  row,
size_t  column 
)

◆ operator()() [6/6]

template<class Tmplt >
const Tmplt & interpolation::MMatrix< Tmplt >::operator() ( size_t  row,
size_t  column 
) const

◆ operator=() [1/3]

MMatrix< double > & interpolation::MMatrix< double >::operator= ( const MMatrix< double > &  mm)

Definition at line 75 of file MMatrix.cpp.

References interpolation::MMatrix< Tmplt >::_matrix.

◆ operator=() [2/3]

MMatrix< m_complex > & interpolation::MMatrix< m_complex >::operator= ( const MMatrix< m_complex > &  mm)

Definition at line 88 of file MMatrix.cpp.

◆ operator=() [3/3]

template<class Tmplt >
MMatrix< Tmplt > & interpolation::MMatrix< Tmplt >::operator= ( const MMatrix< Tmplt > &  mm)

◆ sub()

template<class Tmplt >
template MMatrix< m_complex > interpolation::MMatrix< Tmplt >::sub ( size_t  min_row,
size_t  max_row,
size_t  min_col,
size_t  max_col 
) const

Definition at line 272 of file MMatrix.cpp.

◆ T() [1/3]

MMatrix< double > interpolation::MMatrix< double >::T ( ) const

Definition at line 257 of file MMatrix.cpp.

References interpolation::MMatrix< Tmplt >::_matrix, and gsl_matrix_transpose_memcpy().

Here is the call graph for this function:

◆ T() [2/3]

Definition at line 264 of file MMatrix.cpp.

References interpolation::MMatrix< Tmplt >::_matrix, and gsl_matrix_complex_transpose_memcpy().

Here is the call graph for this function:

◆ T() [3/3]

template<class Tmplt >
MMatrix< Tmplt > interpolation::MMatrix< Tmplt >::T ( ) const

returns matrix transpose T (such that M(i,j) = T(j,i))

◆ trace()

template<class Tmplt >
template m_complex interpolation::MMatrix< Tmplt >::trace ( ) const

returns sum of terms with row == column, even if matrix is not square

Definition at line 286 of file MMatrix.cpp.

Friends And Related Symbol Documentation

◆ MMatrix< double >

template<class Tmplt >
friend class MMatrix< double >
friend

Definition at line 175 of file MMatrix.h.

◆ operator* [1/2]

template<class Tmplt >
MVector< double > operator* ( MMatrix< double >  m,
MVector< double >  v 
)
friend

Definition at line 293 of file MMatrix.h.

◆ operator* [2/2]

template<class Tmplt >
MVector< m_complex > operator* ( MMatrix< m_complex m,
MVector< m_complex v 
)
friend

Definition at line 284 of file MMatrix.h.

◆ operator*= [1/4]

template<class Tmplt >
MMatrix< double > & operator*= ( MMatrix< double > &  m,
double  d 
)
friend

Definition at line 279 of file MMatrix.h.

◆ operator*= [2/4]

template<class Tmplt >
MMatrix< double > & operator*= ( MMatrix< double > &  m1,
MMatrix< double >  m2 
)
friend

Definition at line 337 of file MMatrix.cpp.

◆ operator*= [3/4]

template<class Tmplt >
MMatrix< m_complex > & operator*= ( MMatrix< m_complex > &  m,
m_complex  c 
)
friend

Definition at line 274 of file MMatrix.h.

◆ operator*= [4/4]

template<class Tmplt >
MMatrix< m_complex > & operator*= ( MMatrix< m_complex > &  m1,
MMatrix< m_complex m2 
)
friend

Definition at line 346 of file MMatrix.cpp.

◆ operator+

template<class Tmplt >
template<class Tmplt2 >
MMatrix< Tmplt2 > operator+ ( MMatrix< Tmplt2 >  m1,
const MMatrix< Tmplt2 >  m2 
)
friend

◆ operator+= [1/2]

template<class Tmplt >
MMatrix< double > & operator+= ( MMatrix< double > &  m1,
const MMatrix< double > &  m2 
)
friend

Definition at line 306 of file MMatrix.h.

◆ operator+= [2/2]

template<class Tmplt >
MMatrix< m_complex > & operator+= ( MMatrix< m_complex > &  m1,
const MMatrix< m_complex > &  m2 
)
friend

Definition at line 301 of file MMatrix.h.

Member Data Documentation

◆ _matrix


The documentation for this class was generated from the following files: