Public Types | Public Member Functions | Static Public Member Functions | List of all members
imath::CVarMatrix Class Reference

Definition of mathematical matrix. More...

#include <CVarMatrix.h>

Inheritance diagram for imath::CVarMatrix:
istd::TArray< double, 2 >

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. More...
 
 CVarMatrix (const CVarMatrix &matrix)
 Copy constructor. More...
 
 CVarMatrix (istd::CIndex2d size)
 Create matrix with specified size. More...
 
 CVarMatrix (const CVarVector &vector, bool isTransposed=false)
 Create matrix from vector. More...
 
void Clear ()
 Set all matrix cells to zero. More...
 
void InitToIdentity (int size)
 Create identity matrix. More...
 
double GetMaxElement () const
 
double GetMinElement () const
 
void GetNegated (CVarMatrix &result)
 Get result matrix with negated all elements. More...
 
void GetAdded (const CVarMatrix &matrix, CVarMatrix &result) const
 Get sum of two matrices. More...
 
void GetSubstracted (const CVarMatrix &matrix, CVarMatrix &result) const
 Get result of substraction of two matrices. More...
 
void GetMultiplied (const CVarMatrix &matrix, CVarMatrix &result) const
 Get result of multiplication of two matrices. More...
 
CVarMatrix GetMultiplied (const CVarMatrix &matrix) const
 Get result of multiplication of two matrices. More...
 
void GetScaled (double value, CVarMatrix &result) const
 Get result of multiplication of this matrix with scalar value. More...
 
void GetTransposed (CVarMatrix &result) const
 Get transposed matrix. More...
 
CVarMatrix GetTransposed () const
 Get transposed matrix. More...
 
void Transpose ()
 Transpose matrix. More...
 
double GetTrace () const
 Get trace of this matrix. More...
 
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. More...
 
bool TransformR (int firstPartWidth)
 Transform this matrix in place. More...
 
bool GetSolvedTriangle (const CVarMatrix &vector, CVarMatrix &result, double accuracy=I_BIG_EPSILON) const
 Solving of linear system with triangle matrix. More...
 
bool GetSolvedLSP (const CVarMatrix &vector, CVarMatrix &result, double minHhNorm=I_BIG_EPSILON) const
 Solve 'Least Square Problem'. More...
 
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. More...
 
void GetColumnVector (int columnIndex, CVarVector &result)
 Get single column as vector. More...
 
void GetRowVector (int rowIndex, CVarVector &result)
 Get single row as vector. More...
 
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. More...
 
bool IsEmpty () const
 Check if this array has no elements. More...
 
bool IsDimensionsCountFixed () const
 Check, if number dimensions is fixed. More...
 
int GetDimensionsCount () const
 Get number of dimensions of this array. More...
 
bool SetDimensionsCount (int count)
 Set number of dimensions of this array. More...
 
const SizesTypeGetSizes () const
 Get list of all sizes. More...
 
bool SetSizes (const SizesType &sizes)
 Set list of all sizes. More...
 
int GetSize (int dimension) const
 Get size of array for specified dimension. More...
 
bool SetSize (int dimension, int size)
 Set size of array for specified dimension. More...
 
const double & GetAt (const IndexType &index) const
 Get element stored at specified index. More...
 
double & GetAtRef (const IndexType &index)
 Get reference to element stored at specified index. More...
 
void SetAt (const IndexType &index, const double &value)
 Set element at specified index. More...
 
void SetAllElements (const double &value)
 Set some value to all elements. More...
 
Iterator Begin () const
 Get begin value of element access iterator. More...
 
const Iterator & End () const
 Get end value of element access iterator. More...
 
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. More...
 

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. More...
 
void UpdateElementsSize (const ElementType &value=ElementType())
 Update size of elements to size changes. More...
 
void DeepCopy (const Elements &elements, const SizesType &sizes)
 
- Protected Attributes inherited from istd::TArray< double, 2 >
SizesType m_sizes
 
Elements m_elements
 

Detailed Description

Definition of mathematical matrix.

Definition at line 27 of file CVarMatrix.h.

Member Typedef Documentation

Definition at line 30 of file CVarMatrix.h.

Constructor & Destructor Documentation

imath::CVarMatrix::CVarMatrix ( )

Create empty matrix.

imath::CVarMatrix::CVarMatrix ( const CVarMatrix matrix)

Copy constructor.

imath::CVarMatrix::CVarMatrix ( istd::CIndex2d  size)
explicit

Create matrix with specified size.

imath::CVarMatrix::CVarMatrix ( const CVarVector vector,
bool  isTransposed = false 
)
explicit

Create matrix from vector.

Member Function Documentation

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::GetFrobeniusNorm ( ) const
double imath::CVarMatrix::GetFrobeniusNorm2 ( ) const
double imath::CVarMatrix::GetMaxElement ( ) const
double imath::CVarMatrix::GetMinElement ( ) const
void imath::CVarMatrix::GetMultiplied ( const CVarMatrix matrix,
CVarMatrix result 
) const

Get result of multiplication of two matrices.

Referenced by GetMultiplied(), and operator*().

CVarMatrix imath::CVarMatrix::GetMultiplied ( const CVarMatrix matrix) const
inline

Get result of multiplication of two matrices.

Definition at line 212 of file CVarMatrix.h.

References GetMultiplied().

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.

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.

Returns
true if linear equation system was solved.
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.

void imath::CVarMatrix::GetTransposed ( CVarMatrix result) const

Get transposed matrix.

CVarMatrix imath::CVarMatrix::GetTransposed ( ) const

Get transposed matrix.

Referenced by Transpose().

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.

Parameters
resulttriangle matrix.
matrix2Ptroptional matrix will be transformed using the same reflexions. To realize QR decomposition you can use identity matrix.
maxColumnsoptional maximal number of transformed columns. If it is negative value whole matrix will be transformed.
minHhNormminimal Hausholder reflexion vector length. If any reflexion vector is shorter this method fails.
Returns
true if success.
void imath::CVarMatrix::InitToIdentity ( int  size)

Create identity matrix.

bool imath::CVarMatrix::operator!= ( const CVarMatrix matrix) const
CVarMatrix imath::CVarMatrix::operator* ( const CVarMatrix b) const
inline

Definition at line 262 of file CVarMatrix.h.

References GetMultiplied().

CVarMatrix imath::CVarMatrix::operator* ( double  value) const
inline

Definition at line 272 of file CVarMatrix.h.

References GetScaled().

CVarMatrix imath::CVarMatrix::operator+ ( const CVarMatrix b) const
inline

Definition at line 232 of file CVarMatrix.h.

References GetAdded().

CVarMatrix imath::CVarMatrix::operator- ( const CVarMatrix b) const
inline

Definition at line 242 of file CVarMatrix.h.

References GetSubstracted().

CVarMatrix imath::CVarMatrix::operator- ( )
inline

Definition at line 252 of file CVarMatrix.h.

References GetNegated().

bool imath::CVarMatrix::operator== ( const CVarMatrix matrix) const
bool imath::CVarMatrix::Serialize ( iser::IArchive archive)
static void imath::CVarMatrix::SolveRobustLSP ( CVarMatrix  matrixA,
CVarMatrix matrixY,
CVarMatrix matrixX,
double  minHhNorm = I_BIG_EPSILON 
)
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.

Parameters
matrixAinput matrix A in equation AX = Y. It will be destroyed by this operation (triangle matrix R = HA will be calculated in place).
matrixYinput 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.
matrixXresult 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.

void imath::CVarMatrix::Transpose ( )
inline

Transpose matrix.

Definition at line 222 of file CVarMatrix.h.

References GetTransposed().


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

© 2007-2017 Witold Gantzke and Kirill Lepskiy