NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
|
This class defines a dynamic size 2D matrix with a single 1D internal buffer. If the internal buffer is used directly within the parser, parallelisation is far more common. More...
#include <matdatastructures.hpp>
Public Member Functions | |
Matrix () | |
Empty matrix default constructor. More... | |
Matrix (size_t r, size_t c=1u, const mu::value_type &init=NAN) | |
Fill constructor. More... | |
Matrix (const Matrix &mat) | |
Matrix copy constructor. More... | |
Matrix (Matrix &&mat)=default | |
Matrix (const std::vector< std::vector< mu::value_type > > &vectMatrix) | |
Construct a matrix from a vector matrix. More... | |
Matrix (size_t r, size_t c, mu::value_type *vVals, int nVals) | |
Assign constructor from large array. More... | |
Matrix & | operator= (const Matrix &mat) |
Assignment operator overload. More... | |
void | assign (const Matrix &mat) |
Assign a matrix. More... | |
void | assign (size_t r, size_t c, mu::value_type *vVals, int nVals) |
Assign a large array. More... | |
void | assign (size_t r, size_t c, const std::vector< mu::value_type > &vVals) |
Assign a vector. More... | |
std::vector< mu::value_type > & | data () |
Get a reference to the internal data structure. More... | |
const std::vector< mu::value_type > & | data () const |
Get a const reference to the internal data structure. More... | |
void | transpose () |
Transpose this matrix. More... | |
size_t | rows () const |
The rows of this matrix. More... | |
size_t | cols () const |
The cols of this matrix. More... | |
std::pair< size_t, size_t > | dims () const |
Get both dimensions at once. More... | |
bool | isScalar () const |
Check, whether this matrix is actually a scalar. More... | |
bool | isSquare () const |
Simple function to identify square matrices. More... | |
bool | isEmpty () const |
Simple function to identify empty matrices. More... | |
bool | containsInvalidValues () const |
Returns true, if this matrix contains invalid values. More... | |
std::string | printDims () const |
Convert the dimensions to a printable string. More... | |
mu::value_type & | operator() (size_t i, size_t j=0u) |
Get a reference to the indexed element. More... | |
const mu::value_type & | operator() (size_t i, size_t j=0u) const |
Get a const reference to the indexed element. More... | |
void | resize (size_t r, size_t c) |
Resize the matrix to another dimension. New elements will be zero-initialized. More... | |
void | extend (size_t r, size_t c) |
Extend this matrix to be prepared for the acutal mathematical operation. Scalars are not touched and vectors are repmat()-ed to enable elementwise operations. More... | |
Matrix & | operator*= (const Matrix &mat) |
Multiply a matrix from the right to this matrix. More... | |
Matrix | operator* (const Matrix &mat) const |
Multiply this matrix with a matrix from the right. More... | |
Matrix | hcat (const Matrix &mat) const |
Horizontally concatenate two matrices. More... | |
Matrix | vcat (const Matrix &mat) const |
Vertically concatenate two matrices. More... | |
Private Member Functions | |
mu::value_type & | get (size_t i, size_t j) |
Unchecked method to access indexed elements. More... | |
const mu::value_type & | get (size_t i, size_t j) const |
Const declared overload to the indexed access. More... | |
void | bakeTransposition () |
Bakes the transposition by swapping the actual elements instead of changing the read order. More... | |
Private Attributes | |
std::vector< mu::value_type > | m_storage |
The internal buffer. More... | |
size_t | m_rows |
Number of rows. More... | |
size_t | m_cols |
Number of columns. More... | |
bool | m_transpose |
Is this Matrix transposed. More... | |
This class defines a dynamic size 2D matrix with a single 1D internal buffer. If the internal buffer is used directly within the parser, parallelisation is far more common.
Definition at line 37 of file matdatastructures.hpp.
|
inline |
Empty matrix default constructor.
Definition at line 104 of file matdatastructures.hpp.
|
inline |
Fill constructor.
r | size_t |
c | size_t |
init | const mu::value_type& |
Definition at line 114 of file matdatastructures.hpp.
References m_storage.
|
inline |
Matrix copy constructor.
mat | const Matrix& |
Definition at line 125 of file matdatastructures.hpp.
References assign().
|
default |
|
inline |
|
inline |
Assign constructor from large array.
r | size_t |
c | size_t |
vVals | mu::value_type* |
nVals | int |
Definition at line 168 of file matdatastructures.hpp.
References assign().
|
inline |
Assign a matrix.
mat | const Matrix& |
Definition at line 193 of file matdatastructures.hpp.
References m_cols, m_rows, m_storage, and m_transpose.
Referenced by Matrix(), matrixUnique(), operator*=(), and operator=().
|
inline |
Assign a vector.
r | size_t |
c | size_t |
vVals | const std::vector<mu::value_type>& |
Definition at line 229 of file matdatastructures.hpp.
References m_cols, m_rows, m_storage, m_transpose, and min.
|
inline |
Assign a large array.
r | size_t |
c | size_t |
vVals | mu::value_type* |
nVals | int |
Definition at line 211 of file matdatastructures.hpp.
References m_cols, m_rows, m_storage, m_transpose, and min.
|
inlineprivate |
Bakes the transposition by swapping the actual elements instead of changing the read order.
Definition at line 81 of file matdatastructures.hpp.
References m_cols, m_rows, m_storage, and m_transpose.
Referenced by extend().
|
inline |
The cols of this matrix.
Definition at line 291 of file matdatastructures.hpp.
References m_cols.
Referenced by applyKernel(), assemble(), calcCrossProduct(), calculateStats(), cartToCyl(), cartToPolar(), coordsToGrid(), correlation(), covariance(), cylToCart(), cylToPolar(), diagonalMatrix(), findNearestLowerGridAxisValue(), formatMatrixRow(), getIndices(), getMatrixElements(), hcat(), indexToLog(), interpolate(), invertMatrix(), logToIndex(), matrixAnd(), matrixCmp(), matrixCnt(), matrixCumPrd(), matrixCumSum(), matrixCutoff(), matrixFilter(), matrixMax(), matrixMed(), matrixMin(), matrixMovAvg(), matrixMovMax(), matrixMovMed(), matrixMovMin(), matrixMovNorm(), matrixMovNum(), matrixMovPrd(), matrixMovStd(), matrixMovSum(), matrixNorm(), matrixNum(), matrixOr(), matrixPct(), matrixPrd(), matrixRepMat(), matrixReshape(), matrixResize(), matrixSize(), matrixStd(), matrixSum(), matrixUnique(), matrixXor(), multiplyMatrices(), normalize(), performMatrixOperation(), polarToCart(), polarToCyl(), polyLength(), readMat(), selection(), showMatrixResult(), solveLGS(), solveLGSSymbolic(), vcat(), and vcat().
|
inline |
Returns true, if this matrix contains invalid values.
Definition at line 350 of file matdatastructures.hpp.
References mu::isinf(), mu::isnan(), and m_storage.
Referenced by __attribute__(), and invertMatrix().
|
inline |
Get a reference to the internal data structure.
Definition at line 245 of file matdatastructures.hpp.
References m_storage.
Referenced by Assertion::checkAssertion(), evalMatOp(), matrixCumPrd(), matrixCumSum(), matrixMed(), matrixPct(), and matrixUnique().
|
inline |
Get a const reference to the internal data structure.
Definition at line 257 of file matdatastructures.hpp.
References m_storage.
|
inline |
Get both dimensions at once.
Definition at line 302 of file matdatastructures.hpp.
|
inline |
Extend this matrix to be prepared for the acutal mathematical operation. Scalars are not touched and vectors are repmat()-ed to enable elementwise operations.
r | size_t |
c | size_t |
Definition at line 458 of file matdatastructures.hpp.
References bakeTransposition(), get(), isScalar(), m_cols, m_rows, and resize().
Referenced by evalMatOp().
|
inlineprivate |
Unchecked method to access indexed elements.
i | size_t |
j | size_t |
Definition at line 54 of file matdatastructures.hpp.
References m_cols, m_rows, m_storage, and m_transpose.
Referenced by extend(), hcat(), Matrix(), operator()(), operator*(), and vcat().
|
inlineprivate |
Const declared overload to the indexed access.
i | size_t |
j | size_t |
Definition at line 68 of file matdatastructures.hpp.
References m_cols, m_rows, m_storage, and m_transpose.
|
inline |
Simple function to identify empty matrices.
Definition at line 338 of file matdatastructures.hpp.
References m_cols, and m_rows.
Referenced by __attribute__(), assemble(), calcCrossProduct(), calcTrace(), cartToCyl(), cartToPolar(), coordsToGrid(), correlation(), covariance(), cylToCart(), cylToPolar(), diagonalMatrix(), evalMatOp(), getDeterminant(), indexToLog(), interpolate(), invertMatrix(), logToIndex(), matrixAnd(), matrixAvg(), matrixCmp(), matrixCnt(), matrixCumPrd(), matrixCumSum(), matrixFilter(), matrixMax(), matrixMaxPos(), matrixMed(), matrixMin(), matrixMinPos(), matrixMovAvg(), matrixMovMax(), matrixMovMed(), matrixMovMin(), matrixMovNorm(), matrixMovNum(), matrixMovPrd(), matrixMovStd(), matrixMovSum(), matrixNorm(), matrixNum(), matrixOr(), matrixPct(), matrixPrd(), matrixReshape(), matrixResize(), matrixSize(), matrixStd(), matrixSum(), matrixUnique(), matrixXor(), multiplyMatrices(), normalize(), performMatrixOperation(), polarToCart(), polarToCyl(), polyLength(), selection(), solveLGS(), and solveLGSSymbolic().
|
inline |
Check, whether this matrix is actually a scalar.
Definition at line 314 of file matdatastructures.hpp.
References m_cols, and m_rows.
Referenced by assemble(), extend(), and selection().
|
inline |
Simple function to identify square matrices.
Definition at line 326 of file matdatastructures.hpp.
References m_cols, and m_rows.
Referenced by __attribute__(), calcTrace(), getDeterminant(), and invertMatrix().
|
inline |
Get a reference to the indexed element.
i | size_t |
j | size_t |
Definition at line 382 of file matdatastructures.hpp.
References get(), SyntaxError::INVALID_INDEX, SyntaxError::invalid_position, m_cols, m_rows, printDims(), and toString().
|
inline |
Get a const reference to the indexed element.
i | size_t |
j | size_t |
Definition at line 401 of file matdatastructures.hpp.
References get(), SyntaxError::INVALID_INDEX, SyntaxError::invalid_position, m_cols, m_rows, printDims(), and toString().
Multiply this matrix with a matrix from the right.
mat | const Matrix& |
Definition at line 520 of file matdatastructures.hpp.
References get(), SyntaxError::invalid_position, m_cols, m_rows, printDims(), and SyntaxError::WRONG_MATRIX_DIMENSIONS_FOR_MATOP.
Multiply a matrix from the right to this matrix.
mat | const Matrix& |
Definition at line 506 of file matdatastructures.hpp.
References assign().
Assignment operator overload.
mat | const Matrix& |
Definition at line 180 of file matdatastructures.hpp.
References assign().
|
inline |
Convert the dimensions to a printable string.
Definition at line 368 of file matdatastructures.hpp.
References m_cols, m_rows, and toString().
Referenced by evalMatOp(), multiplyMatrices(), operator()(), operator*(), and printMatrixDim().
|
inline |
Resize the matrix to another dimension. New elements will be zero-initialized.
r | size_t |
c | size_t |
Definition at line 421 of file matdatastructures.hpp.
References m_cols, m_rows, m_storage, and min.
Referenced by correlation(), createShuffledMatrix(), extend(), and matrixResize().
|
inline |
The rows of this matrix.
Definition at line 280 of file matdatastructures.hpp.
References m_rows.
Referenced by applyKernel(), assemble(), calcCrossProduct(), calcDeterminant(), calcTrace(), calculateStats(), cartToCyl(), cartToPolar(), coordsToGrid(), correlation(), covariance(), cylToCart(), cylToPolar(), diagonalMatrix(), findNearestLowerGridAxisValue(), for(), getDeterminant(), getIndices(), getMatrixElements(), hcat(), hcat(), if(), indexToLog(), interpolate(), invertMatrix(), logToIndex(), matrixAnd(), matrixCmp(), matrixCnt(), matrixCumPrd(), matrixCumSum(), matrixCutoff(), matrixFilter(), matrixMax(), matrixMed(), matrixMin(), matrixMovAvg(), matrixMovMax(), matrixMovMed(), matrixMovMin(), matrixMovNorm(), matrixMovNum(), matrixMovPrd(), matrixMovStd(), matrixMovSum(), matrixNorm(), matrixNum(), matrixOr(), matrixPct(), matrixPrd(), matrixRepMat(), matrixReshape(), matrixResize(), matrixSize(), matrixStd(), matrixSum(), matrixUnique(), matrixXor(), multiplyMatrices(), normalize(), performMatrixOperation(), polarToCart(), polarToCyl(), polyLength(), readMat(), selection(), showMatrixResult(), solveLGS(), solveLGSSymbolic(), and vcat().
|
inline |
Transpose this matrix.
Definition at line 268 of file matdatastructures.hpp.
References m_cols, m_rows, and m_transpose.
Referenced by matrixUnique(), and transposeMatrix().
|
private |
Number of columns.
Definition at line 42 of file matdatastructures.hpp.
Referenced by assign(), bakeTransposition(), cols(), dims(), extend(), get(), hcat(), isEmpty(), isScalar(), isSquare(), Matrix(), operator()(), operator*(), printDims(), resize(), transpose(), and vcat().
|
private |
Number of rows.
Definition at line 41 of file matdatastructures.hpp.
Referenced by assign(), bakeTransposition(), dims(), extend(), get(), hcat(), isEmpty(), isScalar(), isSquare(), Matrix(), operator()(), operator*(), printDims(), resize(), rows(), transpose(), and vcat().
|
private |
The internal buffer.
Definition at line 40 of file matdatastructures.hpp.
Referenced by assign(), bakeTransposition(), containsInvalidValues(), data(), get(), Matrix(), and resize().
|
private |
Is this Matrix transposed.
Definition at line 43 of file matdatastructures.hpp.
Referenced by assign(), bakeTransposition(), get(), and transpose().