ACF $AcfVersion:0$
Public Types | Public Member Functions | List of all members
imath::TMatrix< Width, Height, Element > Class Template Reference

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

#include <TMatrix.h>

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=NULL, 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)
 
TMatrix< Width, Height, Element > & operator= (const TMatrix< Width, Height, Element > &matrix)=default
 

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 26 of file TMatrix.h.

Member Typedef Documentation

◆ ColumnVector

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

Definition at line 32 of file TMatrix.h.

◆ ElementType

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

Definition at line 31 of file TMatrix.h.

◆ IndexType

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

Definition at line 29 of file TMatrix.h.

◆ RowVector

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

Definition at line 33 of file TMatrix.h.

◆ SizesType

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

Definition at line 30 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 35 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 456 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 462 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 524 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 548 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 731 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 631 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 638 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 645 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 870 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 825 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 562 of file TMatrix.h.

◆ GetFrobeniusNorm()

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

Definition at line 818 of file TMatrix.h.

◆ GetFrobeniusNorm2()

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

Definition at line 803 of file TMatrix.h.

◆ GetMaxElement()

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

Definition at line 682 of file TMatrix.h.

◆ GetMinElement()

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

Definition at line 701 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 212 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 365 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 753 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 720 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 894 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 767 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 592 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 576 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 742 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 789 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 343 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 778 of file TMatrix.h.

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

◆ 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 = 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.

Definition at line 905 of file TMatrix.h.

References imath::TMatrix< Width, Height, Element >::GetAt(), imath::TMatrix< Width, Height, Element >::GetAtRef(), NULL, 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 666 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 555 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 1044 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 409 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 438 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 376 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 420 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 398 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 387 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 429 of file TMatrix.h.

◆ operator=()

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

◆ 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 1029 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 1066 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 1059 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 537 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 
)

◆ 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 659 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 882 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 569 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 608 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 585 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 354 of file TMatrix.h.


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