|
ACF $AcfVersion:0$
|
Implementation of variable-size mathematical matrix with double precision elements. More...
#include <CVarMatrix.h>
Public Types | |
| typedef istd::TArray< double, 2 > | BaseClass |
Public Types inherited from istd::TArray< double, 2 > | |
| typedef TIndex< Dimensions > | IndexType |
| typedef TIndex< Dimensions > | SizesType |
| typedef double | ElementType |
Public Member Functions | |
| CVarMatrix () | |
| Create empty matrix. | |
| CVarMatrix (const CVarMatrix &matrix) | |
| Copy constructor. | |
| CVarMatrix (istd::CIndex2d size) | |
| Create matrix with specified size. | |
| CVarMatrix (const CVarVector &vector, bool isTransposed=false) | |
| Create matrix from vector. | |
| void | Clear () |
| Set all matrix cells to zero. | |
| void | InitToIdentity (int size) |
| Create identity matrix. | |
| double | GetElementAt (int x, int y) const |
| double & | GetElementRef (int x, int y) |
| double | GetMaxElement () const |
| Get maximal element. | |
| double | GetMinElement () const |
| void | GetNegated (CVarMatrix &result) |
| Get result matrix with negated all elements. | |
| void | GetAdded (const CVarMatrix &matrix, CVarMatrix &result) const |
| Get sum of two matrices. | |
| void | GetSubstracted (const CVarMatrix &matrix, CVarMatrix &result) const |
| Get result of substraction of two matrices. | |
| void | GetMultiplied (const CVarMatrix &matrix, CVarMatrix &result) const |
| Get result of multiplication of two matrices. | |
| CVarMatrix | GetMultiplied (const CVarMatrix &matrix) const |
| Get result of multiplication of two matrices. | |
| void | GetScaled (double value, CVarMatrix &result) const |
| Get result of multiplication of this matrix with scalar value. | |
| void | GetTransposed (CVarMatrix &result) const |
| Get transposed matrix. | |
| CVarMatrix | GetTransposed () const |
| Get transposed matrix. | |
| void | Transpose () |
| Transpose matrix. | |
| double | GetTrace () const |
| Get trace of this matrix. | |
| double | GetFrobeniusNorm2 () const |
| double | GetFrobeniusNorm () const |
| bool | GetTriangleDecomposed (CVarMatrix &result, CVarMatrix *matrix2Ptr=NULL, int maxColumns=-1, double minHhNorm=I_BIG_EPSILON) const |
| Transform matrix to upper triangle form using method of Householder reflexions. | |
| bool | TransformR (int firstPartWidth) |
| Transform this matrix in place. | |
| bool | GetSolvedTriangle (const CVarMatrix &vector, CVarMatrix &result, double accuracy=I_BIG_EPSILON) const |
| Solving of linear system with triangle matrix. | |
| bool | GetSolvedLSP (const CVarMatrix &vector, CVarMatrix &result, double minHhNorm=I_BIG_EPSILON) const |
| Solve 'Least Square Problem'. | |
| bool | GetDecompositionQDQ (CVarMatrix &matrixQ, CVarVector &diagonalD, double tolerance=I_BIG_EPSILON, int maxIterations=100) const |
Calculate decomposition in form of QDQ where Q is orthogonal matrix and D is diagonal one. | |
| void | GetColumnVector (int columnIndex, CVarVector &result) |
| Get single column as vector. | |
| void | GetRowVector (int rowIndex, CVarVector &result) |
| Get single row as vector. | |
| bool | Serialize (iser::IArchive &archive) |
| CVarMatrix | operator+ (const CVarMatrix &b) const |
| CVarMatrix | operator- (const CVarMatrix &b) const |
| CVarMatrix | operator- () |
| CVarMatrix | operator* (const CVarMatrix &b) const |
| CVarMatrix | operator* (double value) const |
| bool | operator== (const CVarMatrix &matrix) const |
| bool | operator!= (const CVarMatrix &matrix) const |
Public Member Functions inherited from istd::TArray< double, 2 > | |
| TArray () | |
| TArray (const TArray &array) | |
| TArray (const SizesType &sizes, const ElementType &value=ElementType()) | |
| void | Reset () |
| Removes all elements and set all sizes to 0. | |
| bool | IsEmpty () const |
| Check if this array has no elements. | |
| bool | IsDimensionsCountFixed () const |
| Check, if number dimensions is fixed. | |
| int | GetDimensionsCount () const |
| Get number of dimensions of this array. | |
| bool | SetDimensionsCount (int count) |
| Set number of dimensions of this array. | |
| const SizesType & | GetSizes () const |
| Get list of all sizes. | |
| bool | SetSizes (const SizesType &sizes) |
| Set list of all sizes. | |
| int | GetSize (int dimension) const |
| Get size of array for specified dimension. | |
| bool | SetSize (int dimension, int size) |
| Set size of array for specified dimension. | |
| const double & | GetAt (const IndexType &index) const |
| Get element stored at specified index. | |
| double & | GetAtRef (const IndexType &index) |
| Get reference to element stored at specified index. | |
| void | SetAt (const IndexType &index, const double &value) |
| Set element at specified index. | |
| void | SetAllElements (const double &value) |
| Set some value to all elements. | |
| Iterator | Begin () const |
| Get begin value of element access iterator. | |
| const Iterator & | End () const |
| Get end value of element access iterator. | |
| bool | operator== (const TArray< double, Dimensions > &value) const |
| bool | operator!= (const TArray< double, Dimensions > &value) const |
| const double & | operator[] (const IndexType &index) const |
| double & | operator[] (const IndexType &index) |
Static Public Member Functions | |
| static void | SolveRobustLSP (CVarMatrix matrixA, CVarMatrix &matrixY, CVarMatrix &matrixX, double minHhNorm=I_BIG_EPSILON) |
| Solve 'Least Square Problem' using robust algorithm. | |
Additional Inherited Members | |
Protected Types inherited from istd::TArray< double, 2 > | |
| typedef std::vector< double > | Elements |
Protected Member Functions inherited from istd::TArray< double, 2 > | |
| int | GetElementIndex (const IndexType &index) const |
| Get index of element in one dimensional array. | |
| void | UpdateElementsSize (const ElementType &value=ElementType()) |
| Update size of elements to size changes. | |
| void | DeepCopy (const Elements &elements, const SizesType &sizes) |
Protected Attributes inherited from istd::TArray< double, 2 > | |
| SizesType | m_sizes |
| Elements | m_elements |
Implementation of variable-size mathematical matrix with double precision elements.
CVarMatrix is a dynamic-size matrix class that provides mathematical matrix operations with runtime-determined dimensions. Built on top of istd::TArray<double, 2>, it supports common matrix operations like addition, multiplication, transpose, decomposition, and various matrix norms. The matrix stores double precision floating-point values in a 2D array structure.
Use CVarMatrix when:
Use TMatrix when:
The matrix uses column-major storage (compatible with OpenGL and many scientific libraries):
Definition at line 108 of file CVarMatrix.h.
| typedef istd::TArray<double, 2> imath::CVarMatrix::BaseClass |
Definition at line 111 of file CVarMatrix.h.
| imath::CVarMatrix::CVarMatrix | ( | ) |
Create empty matrix.
| imath::CVarMatrix::CVarMatrix | ( | const CVarMatrix & | matrix | ) |
Copy constructor.
|
explicit |
Create matrix with specified size.
|
explicit |
Create matrix from vector.
| void imath::CVarMatrix::Clear | ( | ) |
Set all matrix cells to zero.
| void imath::CVarMatrix::GetAdded | ( | const CVarMatrix & | matrix, |
| CVarMatrix & | result | ||
| ) | const |
Get sum of two matrices.
Referenced by operator+().
| void imath::CVarMatrix::GetColumnVector | ( | int | columnIndex, |
| CVarVector & | result | ||
| ) |
Get single column as vector.
| bool imath::CVarMatrix::GetDecompositionQDQ | ( | CVarMatrix & | matrixQ, |
| CVarVector & | diagonalD, | ||
| double | tolerance = I_BIG_EPSILON, |
||
| int | maxIterations = 100 |
||
| ) | const |
Calculate decomposition in form of QDQ where Q is orthogonal matrix and D is diagonal one.
It works for square matrix only.
| double imath::CVarMatrix::GetElementAt | ( | int | x, |
| int | y | ||
| ) | const |
| double & imath::CVarMatrix::GetElementRef | ( | int | x, |
| int | y | ||
| ) |
| double imath::CVarMatrix::GetFrobeniusNorm | ( | ) | const |
| double imath::CVarMatrix::GetFrobeniusNorm2 | ( | ) | const |
| double imath::CVarMatrix::GetMaxElement | ( | ) | const |
Get maximal element.
| double imath::CVarMatrix::GetMinElement | ( | ) | const |
|
inline |
Get result of multiplication of two matrices.
Definition at line 303 of file CVarMatrix.h.
References GetMultiplied().
| void imath::CVarMatrix::GetMultiplied | ( | const CVarMatrix & | matrix, |
| CVarMatrix & | result | ||
| ) | const |
Get result of multiplication of two matrices.
Referenced by GetMultiplied(), and operator*().
| void imath::CVarMatrix::GetNegated | ( | CVarMatrix & | result | ) |
Get result matrix with negated all elements.
Referenced by operator-().
| void imath::CVarMatrix::GetRowVector | ( | int | rowIndex, |
| CVarVector & | result | ||
| ) |
Get single row as vector.
| void imath::CVarMatrix::GetScaled | ( | double | value, |
| CVarMatrix & | result | ||
| ) | const |
Get result of multiplication of this matrix with scalar value.
Referenced by operator*().
| bool imath::CVarMatrix::GetSolvedLSP | ( | const CVarMatrix & | vector, |
| CVarMatrix & | result, | ||
| double | minHhNorm = I_BIG_EPSILON |
||
| ) | const |
Solve 'Least Square Problem'.
Solve linear Least Square Problem for equation AX = Y, where A is a N * M matrix, N >= M, X is n * k matrix and Y is m * k matrix.
Referenced by imath::TMultidimensionalPolynomial< Dimensions, Element >::ApproximateCoefficientsFromFulcrums().
| bool imath::CVarMatrix::GetSolvedTriangle | ( | const CVarMatrix & | vector, |
| CVarMatrix & | result, | ||
| double | accuracy = I_BIG_EPSILON |
||
| ) | const |
Solving of linear system with triangle matrix.
Rx = y, result = x.
| void imath::CVarMatrix::GetSubstracted | ( | const CVarMatrix & | matrix, |
| CVarMatrix & | result | ||
| ) | const |
Get result of substraction of two matrices.
Referenced by operator-().
| double imath::CVarMatrix::GetTrace | ( | ) | const |
Get trace of this matrix.
| CVarMatrix imath::CVarMatrix::GetTransposed | ( | ) | const |
Get transposed matrix.
Referenced by Transpose().
| void imath::CVarMatrix::GetTransposed | ( | CVarMatrix & | result | ) | const |
Get transposed matrix.
| bool imath::CVarMatrix::GetTriangleDecomposed | ( | CVarMatrix & | result, |
| CVarMatrix * | matrix2Ptr = NULL, |
||
| int | maxColumns = -1, |
||
| double | minHhNorm = I_BIG_EPSILON |
||
| ) | const |
Transform matrix to upper triangle form using method of Householder reflexions.
| result | triangle matrix. |
| matrix2Ptr | optional matrix will be transformed using the same reflexions. To realize QR decomposition you can use identity matrix. |
| maxColumns | optional maximal number of transformed columns. If it is negative value whole matrix will be transformed. |
| minHhNorm | minimal Hausholder reflexion vector length. If any reflexion vector is shorter this method fails. |
| void imath::CVarMatrix::InitToIdentity | ( | int | size | ) |
Create identity matrix.
| bool imath::CVarMatrix::operator!= | ( | const CVarMatrix & | matrix | ) | const |
|
inline |
Definition at line 353 of file CVarMatrix.h.
References GetMultiplied().
|
inline |
Definition at line 363 of file CVarMatrix.h.
References GetScaled().
|
inline |
Definition at line 323 of file CVarMatrix.h.
References GetAdded().
|
inline |
Definition at line 343 of file CVarMatrix.h.
References GetNegated().
|
inline |
Definition at line 333 of file CVarMatrix.h.
References GetSubstracted().
| bool imath::CVarMatrix::operator== | ( | const CVarMatrix & | matrix | ) | const |
| bool imath::CVarMatrix::Serialize | ( | iser::IArchive & | archive | ) |
|
static |
Solve 'Least Square Problem' using robust algorithm.
Solve linear Least Square Problem for equation AX = Y, where A is a {n * m} matrix, X is {m * k} matrix and Y is {n * k} matrix. This implementation solve LSP in place, it transforms internal matrix A into R = HA and matrix Y into Y' = HY. Then it solves equation in form RX = Y', where R is 'quasi' triangle matrix.
| matrixA | input matrix A in equation AX = Y. It will be destroyed by this operation (triangle matrix R = HA will be calculated in place). |
| matrixY | input matrix Y in equation AX = Y. It will be destroyed by this operation (matrix Y' = HY will be calculated in place). Please note, that height of this matrix must be the same as height of matrix A. |
| matrixX | result matrix X in equation AX = Y. It will be initialized be this function. The output size of this matrix will be set to {m * k} where m is width of matrix A and k is height of matrix Y. |
| bool imath::CVarMatrix::TransformR | ( | int | firstPartWidth | ) |
Transform this matrix in place.
|
inline |