ICF 3.0.5.47
Technical documentation of ICF Libraries
imath::TMatrix< Width, Height, Element > Class Template Reference

Definition of mathematical matrix with fixed dimensions. More...

#include <TMatrix.h>

Collaboration diagram for imath::TMatrix< Width, Height, Element >:

Public Types

enum  MatrixInitMode {
  MIM_ZERO , MIM_ONES , MIM_IDENTITY , MIM_UPPER_TRIANGLE ,
  MIM_DOWNER_TRIANGLE
}
 
typedef istd::CIndex2d IndexType
 
typedef istd::CIndex2d SizesType
 
typedef Element ElementType
 
typedef imath::TVector< Height, Element > ColumnVector
 
typedef imath::TVector< Width, Element > RowVector
 

Public Member Functions

 TMatrix ()
 Create matrix without initialization.
 
 TMatrix (MatrixInitMode mode)
 Create matrix with initialization to some specified one.
 
 TMatrix (const TMatrix &matrix)
 Copy constructor.
 
void Reset ()
 Set all matrix cells to zero.
 
void Clear ()
 Set all matrix cells to zero.
 
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 SizesTypeGetSizes () 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 ElementTypeGetAt (const IndexType &index) const
 Get element stored at specified index.
 
const ElementTypeGetAt (int x, int y) const
 Get element stored at specified index.
 
ElementTypeGetAtRef (const IndexType &index)
 Get reference to element stored at specified index.
 
ElementTypeGetAtRef (int x, int y)
 Get reference to element stored at specified index.
 
void SetAt (const IndexType &index, const ElementType &value)
 Set element at specified index.
 
void SetAt (int x, int y, const ElementType &value)
 Set element at specified index.
 
void InitToIdentity ()
 Create identity matrix.
 
double GetMaxElement () const
 
double GetMinElement () const
 
void GetNegated (TMatrix< Width, Height, Element > &result)
 Get result matrix with negated all elements.
 
void GetAdded (const TMatrix< Width, Height, Element > &matrix, TMatrix< Width, Height, Element > &result) const
 Get sum of two matrices.
 
void GetSubstracted (const TMatrix< Width, Height, Element > &matrix, TMatrix< Width, Height, Element > &result) const
 Get result of substraction of two matrices.
 
template<int SecondWidth>
void GetMultiplied (const TMatrix< SecondWidth, Width, Element > &matrix, TMatrix< SecondWidth, Height, Element > &result) const
 Get result of multiplication of two matrices.
 
template<int SecondWidth>
TMatrix< SecondWidth, Height, Element > GetMultiplied (const TMatrix< SecondWidth, Width, Element > &matrix) const
 Get result of multiplication of two matrices.
 
void GetMultiplied (const TVector< Width, Element > &vector, TVector< Height, Element > &result) const
 Get result of multiplication of this matrix and some vector.
 
TVector< Height, Element > GetMultiplied (const TVector< Width, Element > &vector) const
 Get result of multiplication of this matrix and some vector.
 
void GetScaled (double value, TMatrix< Width, Height, Element > &result) const
 Get result of multiplication of this matrix with scalar value.
 
void GetTransposed (TMatrix< Height, Width, Element > &result) const
 Get transposed matrix.
 
TMatrix< Height, Width, Element > 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 (TMatrix< Width, Height, Element > &result, TMatrix< Height, Height, Element > *matrixQPtr=nullptr, int maxColumns=-1, double minHhNorm=I_BIG_EPSILON) const
 Transform matrix to upper triangle form using method of Householder reflexions.
 
bool GetDecompositionQDQ (TMatrix< Height, Height, Element > &matrixQ, TVector< Height, Element > &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, TVector< Height, Element > &result) const
 Get single column as vector.
 
void SetColumnVector (int columnIndex, const TVector< Height, Element > &columnVector)
 Set a single column vector to matrix.
 
void GetRowVector (int rowIndex, TVector< Width, Element > &result)
 Get single row as vector.
 
bool Serialize (iser::IArchive &archive)
 
TMatrix< Width, Height, Element > operator+ (const TMatrix< Width, Height, Element > &matrix) const
 
TMatrix< Width, Height, Element > operator- (const TMatrix< Width, Height, Element > &matrix) const
 
TMatrix< Width, Height, Element > operator- ()
 
template<int SecondWidth>
TMatrix< SecondWidth, Height, Element > operator* (const TMatrix< SecondWidth, Width, Element > &matrix) const
 
TMatrix< Width, Height, Element > operator* (double value) const
 
TMatrix< Width, Height, Element > & operator+= (const TMatrix< Width, Height, Element > &matrix)
 
TMatrix< Width, Height, Element > & operator-= (const TMatrix< Width, Height, Element > &matrix)
 
TMatrix< Width, Height, Element > & operator*= (double value)
 
bool operator== (const TMatrix< Width, Height, Element > &matrix) const
 
bool operator!= (const TMatrix< Width, Height, Element > &matrix) const
 
const ElementTypeoperator[] (const IndexType &index) const
 
ElementTypeoperator[] (const IndexType &index)
 

Detailed Description

template<int Width, int Height, typename Element = double>
class imath::TMatrix< Width, Height, Element >

Definition of mathematical matrix with fixed dimensions.

Definition at line 32 of file TMatrix.h.

Member Typedef Documentation

◆ ColumnVector

template<int Width, int Height, typename Element = double>
imath::TVector<Height, Element> imath::TMatrix< Width, Height, Element >::ColumnVector

Definition at line 38 of file TMatrix.h.

◆ ElementType

template<int Width, int Height, typename Element = double>
Element imath::TMatrix< Width, Height, Element >::ElementType

Definition at line 37 of file TMatrix.h.

◆ IndexType

template<int Width, int Height, typename Element = double>
istd::CIndex2d imath::TMatrix< Width, Height, Element >::IndexType

Definition at line 35 of file TMatrix.h.

◆ RowVector

template<int Width, int Height, typename Element = double>
imath::TVector<Width, Element> imath::TMatrix< Width, Height, Element >::RowVector

Definition at line 39 of file TMatrix.h.

◆ SizesType

template<int Width, int Height, typename Element = double>
istd::CIndex2d imath::TMatrix< Width, Height, Element >::SizesType

Definition at line 36 of file TMatrix.h.

Member Enumeration Documentation

◆ MatrixInitMode

template<int Width, int Height, typename Element = double>
enum imath::TMatrix::MatrixInitMode
Enumerator
MIM_ZERO 

All elements initialized to 0.

MIM_ONES 

All elements initialized to 1.

MIM_IDENTITY 

Identity matrix.

MIM_UPPER_TRIANGLE 

Upper triangle matrix.

MIM_DOWNER_TRIANGLE 

Downer triangle matrix.

Definition at line 41 of file TMatrix.h.

Constructor & Destructor Documentation

◆ TMatrix() [1/3]

template<int Width, int Height, typename Element >
imath::TMatrix< Width, Height, Element >::TMatrix ( )

Create matrix without initialization.

Definition at line 460 of file TMatrix.h.

◆ TMatrix() [2/3]

template<int Width, int Height, typename Element >
imath::TMatrix< Width, Height, Element >::TMatrix ( MatrixInitMode mode)
explicit

Create matrix with initialization to some specified one.

Definition at line 466 of file TMatrix.h.

◆ TMatrix() [3/3]

template<int Width, int Height, typename Element >
imath::TMatrix< Width, Height, Element >::TMatrix ( const TMatrix< Width, Height, Element > & matrix)

Copy constructor.

Definition at line 528 of file TMatrix.h.

Member Function Documentation

◆ Clear()

template<int Width, int Height, typename Element >
void imath::TMatrix< Width, Height, Element >::Clear ( )

Set all matrix cells to zero.

It makes the same as Reset() and is used for compatibility with other matrix implementations.

Definition at line 552 of file TMatrix.h.

Referenced by imath::TMatrix< Width, Height, Element >::GetDecompositionQDQ().

◆ GetAdded()

template<int Width, int Height, typename Element >
void imath::TMatrix< Width, Height, Element >::GetAdded ( const TMatrix< Width, Height, Element > & matrix,
TMatrix< Width, Height, Element > & result ) const

Get sum of two matrices.

Definition at line 735 of file TMatrix.h.

◆ GetAt() [1/2]

template<int Width, int Height, typename Element >
const TMatrix< Width, Height, Element >::ElementType & imath::TMatrix< Width, Height, Element >::GetAt ( const IndexType & index) const

◆ GetAt() [2/2]

template<int Width, int Height, typename Element >
const TMatrix< Width, Height, Element >::ElementType & imath::TMatrix< Width, Height, Element >::GetAt ( int x,
int y ) const

Get element stored at specified index.

Definition at line 635 of file TMatrix.h.

◆ GetAtRef() [1/2]

template<int Width, int Height, typename Element >
TMatrix< Width, Height, Element >::ElementType & imath::TMatrix< Width, Height, Element >::GetAtRef ( const IndexType & index)

Get reference to element stored at specified index.

Definition at line 642 of file TMatrix.h.

Referenced by imath::TMatrix< Width, Height, Element >::GetTriangleDecomposed().

◆ GetAtRef() [2/2]

template<int Width, int Height, typename Element >
TMatrix< Width, Height, Element >::ElementType & imath::TMatrix< Width, Height, Element >::GetAtRef ( int x,
int y )

Get reference to element stored at specified index.

Definition at line 649 of file TMatrix.h.

◆ GetColumnVector()

template<int Width, int Height, typename Element >
void imath::TMatrix< Width, Height, Element >::GetColumnVector ( int columnIndex,
TVector< Height, Element > & result ) const

Get single column as vector.

Definition at line 874 of file TMatrix.h.

◆ GetDecompositionQDQ()

template<int Width, int Height, typename Element >
bool imath::TMatrix< Width, Height, Element >::GetDecompositionQDQ ( TMatrix< Height, Height, Element > & matrixQ,
TVector< Height, Element > & 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.

Definition at line 829 of file TMatrix.h.

References imath::TMatrix< Width, Height, Element >::Clear(), imath::TMatrix< Width, Height, Element >::GetAt(), imath::TMatrix< Width, Height, Element >::GetMultiplied(), and imath::TMatrix< Width, Height, Element >::GetTriangleDecomposed().

◆ GetDimensionsCount()

template<int Width, int Height, typename Element >
int imath::TMatrix< Width, Height, Element >::GetDimensionsCount ( ) const

Get number of dimensions of this array.

It is provided for template implementations. It returns always 2.

Definition at line 566 of file TMatrix.h.

◆ GetFrobeniusNorm()

template<int Width, int Height, typename Element >
double imath::TMatrix< Width, Height, Element >::GetFrobeniusNorm ( ) const

Definition at line 822 of file TMatrix.h.

◆ GetFrobeniusNorm2()

template<int Width, int Height, typename Element >
double imath::TMatrix< Width, Height, Element >::GetFrobeniusNorm2 ( ) const

Definition at line 807 of file TMatrix.h.

◆ GetMaxElement()

template<int Width, int Height, typename Element >
double imath::TMatrix< Width, Height, Element >::GetMaxElement ( ) const

Definition at line 686 of file TMatrix.h.

◆ GetMinElement()

template<int Width, int Height, typename Element >
double imath::TMatrix< Width, Height, Element >::GetMinElement ( ) const

Definition at line 705 of file TMatrix.h.

◆ GetMultiplied() [1/4]

template<int Width, int Height, typename Element = double>
template<int SecondWidth>
TMatrix< SecondWidth, Height, Element > imath::TMatrix< Width, Height, Element >::GetMultiplied ( const TMatrix< SecondWidth, Width, Element > & matrix) const
inline

Get result of multiplication of two matrices.

Definition at line 218 of file TMatrix.h.

References imath::TMatrix< Width, Height, Element >::GetMultiplied().

◆ GetMultiplied() [2/4]

template<int Width, int Height, typename Element = double>
template<int SecondWidth>
void imath::TMatrix< Width, Height, Element >::GetMultiplied ( const TMatrix< SecondWidth, Width, Element > & matrix,
TMatrix< SecondWidth, Height, Element > & result ) const
inline

◆ GetMultiplied() [3/4]

template<int Width, int Height, typename Element >
TVector< Height, Element > imath::TMatrix< Width, Height, Element >::GetMultiplied ( const TVector< Width, Element > & vector) const

Get result of multiplication of this matrix and some vector.

Definition at line 369 of file TMatrix.h.

◆ GetMultiplied() [4/4]

template<int Width, int Height, typename Element >
void imath::TMatrix< Width, Height, Element >::GetMultiplied ( const TVector< Width, Element > & vector,
TVector< Height, Element > & result ) const

Get result of multiplication of this matrix and some vector.

Definition at line 757 of file TMatrix.h.

◆ GetNegated()

template<int Width, int Height, typename Element >
void imath::TMatrix< Width, Height, Element >::GetNegated ( TMatrix< Width, Height, Element > & result)

Get result matrix with negated all elements.

Definition at line 724 of file TMatrix.h.

◆ GetRowVector()

template<int Width, int Height, typename Element >
void imath::TMatrix< Width, Height, Element >::GetRowVector ( int rowIndex,
TVector< Width, Element > & result )

Get single row as vector.

Definition at line 898 of file TMatrix.h.

◆ GetScaled()

template<int Width, int Height, typename Element >
void imath::TMatrix< Width, Height, Element >::GetScaled ( double value,
TMatrix< Width, Height, Element > & result ) const

Get result of multiplication of this matrix with scalar value.

Definition at line 771 of file TMatrix.h.

◆ GetSize()

template<int Width, int Height, typename Element >
int imath::TMatrix< Width, Height, Element >::GetSize ( int dimension) const

Get size of array for specified dimension.

Definition at line 596 of file TMatrix.h.

◆ GetSizes()

template<int Width, int Height, typename Element >
const TMatrix< Width, Height, Element >::SizesType & imath::TMatrix< Width, Height, Element >::GetSizes ( ) const

Get list of all sizes.

Definition at line 580 of file TMatrix.h.

◆ GetSubstracted()

template<int Width, int Height, typename Element >
void imath::TMatrix< Width, Height, Element >::GetSubstracted ( const TMatrix< Width, Height, Element > & matrix,
TMatrix< Width, Height, Element > & result ) const

Get result of substraction of two matrices.

Definition at line 746 of file TMatrix.h.

◆ GetTrace()

template<int Width, int Height, typename Element >
double imath::TMatrix< Width, Height, Element >::GetTrace ( ) const

Get trace of this matrix.

Definition at line 793 of file TMatrix.h.

◆ GetTransposed() [1/2]

template<int Width, int Height, typename Element >
TMatrix< Height, Width, Element > imath::TMatrix< Width, Height, Element >::GetTransposed ( ) const
inline

Get transposed matrix.

Definition at line 347 of file TMatrix.h.

◆ GetTransposed() [2/2]

template<int Width, int Height, typename Element >
void imath::TMatrix< Width, Height, Element >::GetTransposed ( TMatrix< Height, Width, Element > & result) const

Get transposed matrix.

Definition at line 782 of file TMatrix.h.

◆ GetTriangleDecomposed()

template<int Width, int Height, typename Element >
bool imath::TMatrix< Width, Height, Element >::GetTriangleDecomposed ( TMatrix< Width, Height, Element > & result,
TMatrix< Height, Height, Element > * matrixQPtr = nullptr,
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.

Definition at line 909 of file TMatrix.h.

References imath::TMatrix< Width, Height, Element >::GetAt(), imath::TMatrix< Width, Height, Element >::GetAtRef(), and imath::TMatrix< Width, Height, Element >::SetAt().

Referenced by imath::TMatrix< Width, Height, Element >::GetDecompositionQDQ().

◆ InitToIdentity()

template<int Width, int Height, typename Element >
void imath::TMatrix< Width, Height, Element >::InitToIdentity ( )

Create identity matrix.

Definition at line 670 of file TMatrix.h.

◆ IsDimensionsCountFixed()

template<int Width, int Height, typename Element >
bool imath::TMatrix< Width, Height, Element >::IsDimensionsCountFixed ( ) const

Check, if number dimensions is fixed.

It is provided for template implementations. It returns always true.

Definition at line 559 of file TMatrix.h.

◆ operator!=()

template<int Width, int Height, typename Element >
bool imath::TMatrix< Width, Height, Element >::operator!= ( const TMatrix< Width, Height, Element > & matrix) const

Definition at line 1048 of file TMatrix.h.

◆ operator*() [1/2]

template<int Width, int Height, typename Element = double>
template<int SecondWidth>
TMatrix< SecondWidth, Height, Element > imath::TMatrix< Width, Height, Element >::operator* ( const TMatrix< SecondWidth, Width, Element > & matrix) const
inline

◆ operator*() [2/2]

template<int Width, int Height, typename Element >
TMatrix< Width, Height, Element > imath::TMatrix< Width, Height, Element >::operator* ( double value) const
inline

Definition at line 413 of file TMatrix.h.

◆ operator*=()

template<int Width, int Height, typename Element >
TMatrix< Width, Height, Element > & imath::TMatrix< Width, Height, Element >::operator*= ( double value)

Definition at line 442 of file TMatrix.h.

◆ operator+()

template<int Width, int Height, typename Element >
TMatrix< Width, Height, Element > imath::TMatrix< Width, Height, Element >::operator+ ( const TMatrix< Width, Height, Element > & matrix) const
inline

Definition at line 380 of file TMatrix.h.

◆ operator+=()

template<int Width, int Height, typename Element >
TMatrix< Width, Height, Element > & imath::TMatrix< Width, Height, Element >::operator+= ( const TMatrix< Width, Height, Element > & matrix)

Definition at line 424 of file TMatrix.h.

◆ operator-() [1/2]

template<int Width, int Height, typename Element >
TMatrix< Width, Height, Element > imath::TMatrix< Width, Height, Element >::operator- ( )
inline

Definition at line 402 of file TMatrix.h.

◆ operator-() [2/2]

template<int Width, int Height, typename Element >
TMatrix< Width, Height, Element > imath::TMatrix< Width, Height, Element >::operator- ( const TMatrix< Width, Height, Element > & matrix) const
inline

Definition at line 391 of file TMatrix.h.

◆ operator-=()

template<int Width, int Height, typename Element >
TMatrix< Width, Height, Element > & imath::TMatrix< Width, Height, Element >::operator-= ( const TMatrix< Width, Height, Element > & matrix)

Definition at line 433 of file TMatrix.h.

◆ operator==()

template<int Width, int Height, typename Element >
bool imath::TMatrix< Width, Height, Element >::operator== ( const TMatrix< Width, Height, Element > & matrix) const

Definition at line 1033 of file TMatrix.h.

◆ operator[]() [1/2]

template<int Width, int Height, typename Element >
TMatrix< Width, Height, Element >::ElementType & imath::TMatrix< Width, Height, Element >::operator[] ( const IndexType & index)

Definition at line 1070 of file TMatrix.h.

◆ operator[]() [2/2]

template<int Width, int Height, typename Element >
const TMatrix< Width, Height, Element >::ElementType & imath::TMatrix< Width, Height, Element >::operator[] ( const IndexType & index) const

Definition at line 1063 of file TMatrix.h.

◆ Reset()

template<int Width, int Height, typename Element >
void imath::TMatrix< Width, Height, Element >::Reset ( )

Set all matrix cells to zero.

It makes the same as Clear() and is used for compatibility with other matrix implementations.

Definition at line 541 of file TMatrix.h.

◆ Serialize()

template<int Width, int Height, typename Element >
bool imath::TMatrix< Width, Height, Element >::Serialize ( iser::IArchive & archive)

◆ SetAt() [1/2]

template<int Width, int Height, typename Element >
void imath::TMatrix< Width, Height, Element >::SetAt ( const IndexType & index,
const ElementType & value )

Set element at specified index.

Definition at line 656 of file TMatrix.h.

Referenced by imath::TMatrix< Width, Height, Element >::GetTriangleDecomposed().

◆ SetAt() [2/2]

template<int Width, int Height, typename Element >
void imath::TMatrix< Width, Height, Element >::SetAt ( int x,
int y,
const ElementType & value )

Set element at specified index.

Definition at line 663 of file TMatrix.h.

◆ SetColumnVector()

template<int Width, int Height, typename Element >
void imath::TMatrix< Width, Height, Element >::SetColumnVector ( int columnIndex,
const TVector< Height, Element > & columnVector )

Set a single column vector to matrix.

Definition at line 886 of file TMatrix.h.

◆ SetDimensionsCount()

template<int Width, int Height, typename Element >
bool imath::TMatrix< Width, Height, Element >::SetDimensionsCount ( int count)

Set number of dimensions of this array.

This is only dummy method, to provide methods compatibility with template implementations.

Parameters
countnumber of dimensions will be set.
Returns
true, if number of set dimensions equals 2, or false if isn't.

Definition at line 573 of file TMatrix.h.

◆ SetSize()

template<int Width, int Height, typename Element >
bool imath::TMatrix< Width, Height, Element >::SetSize ( int dimension,
int size )

Set size of array for specified dimension.

This is only dummy method, to provide methods compatibility with template implementations.

Returns
true, if set dimension equals the template parameter, or false if isn't.

Definition at line 612 of file TMatrix.h.

◆ SetSizes()

template<int Width, int Height, typename Element >
bool imath::TMatrix< Width, Height, Element >::SetSizes ( const SizesType & sizes)

Set list of all sizes.

This is only dummy method, to provide methods compatibility with template implementations.

Returns
true, if set dimensions equals the template parameters, or false if isn't.

Definition at line 589 of file TMatrix.h.

◆ Transpose()

template<int Width, int Height, typename Element >
void imath::TMatrix< Width, Height, Element >::Transpose ( )
inline

Transpose matrix.

Definition at line 358 of file TMatrix.h.


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

© Witold Gantzke and Kirill Lepskiy