OPAL (Object Oriented Parallel Accelerator Library)
2021.1.99
OPAL
|
#include <MMatrix.h>
Public Member Functions | |
MMatrix () | |
default constructor makes an empty MMatrix of size (0,0) More... | |
MMatrix (const MMatrix< Tmplt > &mv) | |
Copy constructor makes a deep copy of mv. More... | |
MMatrix (size_t nrows, size_t ncols, Tmplt *data_beginning) | |
Construct a matrix and fill with data from memory data_beginning. More... | |
MMatrix (size_t nrows, size_t ncols, Tmplt value) | |
Construct a matrix and fill with identical data. More... | |
MMatrix (size_t nrows, size_t ncols) | |
Construct a matrix and fill all fields with 0. More... | |
~MMatrix () | |
destructor More... | |
size_t | num_row () const |
returns number of rows in the matrix More... | |
size_t | num_col () const |
returns number of columns in the matrix More... | |
Tmplt | trace () const |
returns sum of terms with row == column, even if matrix is not square More... | |
Tmplt | determinant () const |
returns matrix determinant; throws an exception if matrix is not square More... | |
MMatrix< Tmplt > | inverse () const |
returns matrix inverse leaving this matrix unchanged More... | |
void | invert () |
turns this matrix into its inverse More... | |
MMatrix< Tmplt > | T () const |
returns matrix transpose T (such that M(i,j) = T(j,i)) More... | |
MVector< m_complex > | 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). More... | |
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_complex > | T () const |
size_t | num_row () const |
size_t | num_row () const |
size_t | num_col () const |
size_t | num_col () const |
const double & | operator() (size_t i, size_t j) const |
const m_complex & | operator() (size_t i, size_t j) const |
double & | operator() (size_t i, size_t j) |
m_complex & | 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. More... | |
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_matrix * | get_matrix (const MMatrix< double > &m) |
static gsl_matrix_complex * | get_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_complex > | operator* (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) |
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
template interpolation::MMatrix< Tmplt >::MMatrix | ( | ) |
default constructor makes an empty MMatrix of size (0,0)
Definition at line 41 of file MMatrix.cpp.
interpolation::MMatrix< Tmplt >::MMatrix | ( | const MMatrix< Tmplt > & | mv | ) |
Copy constructor makes a deep copy of mv.
interpolation::MMatrix< Tmplt >::MMatrix | ( | size_t | nrows, |
size_t | ncols, | ||
Tmplt * | data_beginning | ||
) |
Construct a matrix and fill with data from memory data_beginning.
nrows | number of rows |
ncols | number of columns |
data_beginning | pointer 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 120 of file MMatrix.cpp.
References interpolation::MMatrix< Tmplt >::build_matrix().
interpolation::MMatrix< Tmplt >::MMatrix | ( | size_t | nrows, |
size_t | ncols, | ||
Tmplt | value | ||
) |
Construct a matrix and fill with identical data.
nrows | number of rows |
ncols | number of columns |
value | variable to be copied into all items in the matrix |
Definition at line 126 of file MMatrix.cpp.
References a.
interpolation::MMatrix< Tmplt >::MMatrix | ( | size_t | nrows, |
size_t | ncols | ||
) |
Construct a matrix and fill all fields with 0.
nrows | number of rows |
ncols | number of columns |
Definition at line 135 of file MMatrix.cpp.
template interpolation::MMatrix< Tmplt >::~MMatrix | ( | ) |
destructor
Definition at line 155 of file MMatrix.cpp.
interpolation::MMatrix< double >::MMatrix | ( | const MMatrix< double > & | mm | ) |
Definition at line 100 of file MMatrix.cpp.
References interpolation::MMatrix< Tmplt >::_matrix, interpolation::MMatrix< Tmplt >::num_col(), and interpolation::MMatrix< Tmplt >::num_row().
interpolation::MMatrix< m_complex >::MMatrix | ( | const MMatrix< m_complex > & | mm | ) |
Definition at line 110 of file MMatrix.cpp.
References interpolation::MMatrix< Tmplt >::_matrix, interpolation::MMatrix< Tmplt >::num_col(), and interpolation::MMatrix< Tmplt >::num_row().
|
private |
Definition at line 163 of file MMatrix.cpp.
|
private |
Definition at line 169 of file MMatrix.cpp.
|
private |
Referenced by interpolation::MMatrix< Tmplt >::MMatrix().
|
private |
Definition at line 175 of file MMatrix.cpp.
References a.
|
private |
Definition at line 184 of file MMatrix.cpp.
References a.
|
private |
|
private |
Definition at line 63 of file MMatrix.cpp.
|
private |
Definition at line 70 of file MMatrix.cpp.
|
private |
m_complex interpolation::MMatrix< m_complex >::determinant | ( | ) | const |
Definition at line 196 of file MMatrix.cpp.
References interpolation::MMatrix< Tmplt >::_matrix.
double interpolation::MMatrix< double >::determinant | ( | ) | const |
Definition at line 209 of file MMatrix.cpp.
References interpolation::MMatrix< Tmplt >::_matrix.
Tmplt interpolation::MMatrix< Tmplt >::determinant | ( | ) | const |
returns matrix determinant; throws an exception if matrix is not square
|
static |
Construct a square matrix filling on and off diagonal values.
i | number of rows and number of columns |
diag_value | fill values with row == column (i.e. on the diagonal) with this value |
off_diag_value | fill values with row != column (i.e. off the diagonal) with this value |
Definition at line 141 of file MMatrix.cpp.
References a.
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 301 of file MMatrix.cpp.
References interpolation::MVector< Tmplt >::get_vector(), and interpolation::m_complex_build().
template std::pair< MVector< m_complex >, MMatrix< m_complex > > interpolation::MMatrix< Tmplt >::eigenvectors | ( | ) | const |
Definition at line 316 of file MMatrix.cpp.
References interpolation::MVector< Tmplt >::get_vector().
|
staticprivate |
Definition at line 350 of file MMatrix.h.
References interpolation::MMatrix< Tmplt >::_matrix.
|
staticprivate |
Definition at line 358 of file MMatrix.h.
References interpolation::MMatrix< Tmplt >::_matrix.
template MVector< m_complex > interpolation::MMatrix< Tmplt >::get_mvector | ( | size_t | column | ) | const |
Definition at line 417 of file MMatrix.cpp.
MMatrix< Tmplt > interpolation::MMatrix< Tmplt >::inverse |
returns matrix inverse leaving this matrix unchanged
Definition at line 222 of file MMatrix.cpp.
References interpolation::MMatrix< Tmplt >::invert().
void interpolation::MMatrix< m_complex >::invert | ( | ) |
Definition at line 231 of file MMatrix.cpp.
References interpolation::MMatrix< Tmplt >::_matrix.
void interpolation::MMatrix< double >::invert | ( | ) |
Definition at line 246 of file MMatrix.cpp.
References interpolation::MMatrix< Tmplt >::_matrix.
void interpolation::MMatrix< Tmplt >::invert | ( | ) |
turns this matrix into its inverse
Referenced by interpolation::SolveFactory::BuildHInvMatrix(), and interpolation::MMatrix< Tmplt >::inverse().
size_t interpolation::MMatrix< Tmplt >::num_col | ( | ) | const |
returns number of columns in the matrix
Referenced by interpolation::complex(), interpolation::SquarePolynomialVector::Deriv(), interpolation::SquarePolynomialVector::F(), interpolation::im(), interpolation::SquarePolynomialVector::MakePolyVector(), interpolation::MMatrix< Tmplt >::MMatrix(), interpolation::MMatrix< double >::MMatrix(), interpolation::operator-(), interpolation::operator<<(), interpolation::operator==(), interpolation::SquarePolynomialVector::PolynomialOrder(), interpolation::SquarePolynomialVector::PrintHeader(), interpolation::re(), and interpolation::SquarePolynomialVector::SetCoefficients().
|
inline |
|
inline |
size_t interpolation::MMatrix< Tmplt >::num_row | ( | ) | const |
returns number of rows in the matrix
Referenced by interpolation::complex(), interpolation::SquarePolynomialVector::Deriv(), interpolation::im(), interpolation::MMatrix< Tmplt >::MMatrix(), interpolation::MMatrix< double >::MMatrix(), interpolation::operator-(), interpolation::operator<<(), interpolation::operator==(), interpolation::re(), interpolation::SquarePolynomialVector::SetCoefficients(), and interpolation::SquarePolynomialVector::ValueDimension().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Tmplt& interpolation::MMatrix< Tmplt >::operator() | ( | size_t | row, |
size_t | column | ||
) |
const Tmplt& interpolation::MMatrix< Tmplt >::operator() | ( | size_t | row, |
size_t | column | ||
) | const |
MMatrix< double > & interpolation::MMatrix< double >::operator= | ( | const MMatrix< double > & | mm | ) |
Definition at line 78 of file MMatrix.cpp.
MMatrix< m_complex > & interpolation::MMatrix< m_complex >::operator= | ( | const MMatrix< m_complex > & | mm | ) |
Definition at line 89 of file MMatrix.cpp.
MMatrix<Tmplt>& interpolation::MMatrix< Tmplt >::operator= | ( | const MMatrix< Tmplt > & | mm | ) |
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 277 of file MMatrix.cpp.
MMatrix< double > interpolation::MMatrix< double >::T | ( | ) | const |
Definition at line 261 of file MMatrix.cpp.
References interpolation::MMatrix< Tmplt >::_matrix.
MMatrix< m_complex > interpolation::MMatrix< m_complex >::T | ( | ) | const |
Definition at line 269 of file MMatrix.cpp.
References interpolation::MMatrix< Tmplt >::_matrix.
MMatrix<Tmplt> interpolation::MMatrix< Tmplt >::T | ( | ) | const |
returns matrix transpose T (such that M(i,j) = T(j,i))
template m_complex interpolation::MMatrix< Tmplt >::trace | ( | ) | const |
returns sum of terms with row == column, even if matrix is not square
Definition at line 290 of file MMatrix.cpp.
|
friend |
|
friend |
Definition at line 332 of file MMatrix.cpp.
|
friend |
Definition at line 340 of file MMatrix.cpp.
|
friend |
|
private |
Definition at line 191 of file MMatrix.h.
Referenced by interpolation::MMatrix< Tmplt >::determinant(), interpolation::MMatrix< Tmplt >::get_matrix(), interpolation::MMatrix< Tmplt >::invert(), interpolation::MMatrix< Tmplt >::MMatrix(), interpolation::MMatrix< double >::MMatrix(), and interpolation::MMatrix< Tmplt >::T().