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. More...
 
 TMatrix (MatrixInitMode mode)
 Create matrix with initialization to some specified one. More...
 
 TMatrix (const TMatrix &matrix)
 Copy constructor. More...
 
void Reset ()
 Set all matrix cells to zero. More...
 
void Clear ()
 Set all matrix cells to zero. 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 ElementTypeGetAt (const IndexType &index) const
 Get element stored at specified index. More...
 
const ElementTypeGetAt (int x, int y) const
 Get element stored at specified index. More...
 
ElementTypeGetAtRef (const IndexType &index)
 Get reference to element stored at specified index. More...
 
ElementTypeGetAtRef (int x, int y)
 Get reference to element stored at specified index. More...
 
void SetAt (const IndexType &index, const ElementType &value)
 Set element at specified index. More...
 
void SetAt (int x, int y, const ElementType &value)
 Set element at specified index. More...
 
void InitToIdentity ()
 Create identity matrix. More...
 
double GetMaxElement () const
 
double GetMinElement () const
 
void GetNegated (TMatrix< Width, Height, Element > &result)
 Get result matrix with negated all elements. More...
 
void GetAdded (const TMatrix< Width, Height, Element > &matrix, TMatrix< Width, Height, Element > &result) const
 Get sum of two matrices. More...
 
void GetSubstracted (const TMatrix< Width, Height, Element > &matrix, TMatrix< Width, Height, Element > &result) const
 Get result of substraction of two matrices. More...
 
template<int SecondWidth>
void GetMultiplied (const TMatrix< SecondWidth, Width, Element > &matrix, TMatrix< SecondWidth, Height, Element > &result) const
 Get result of multiplication of two matrices. More...
 
template<int SecondWidth>
TMatrix< SecondWidth, Height,
Element > 
GetMultiplied (const TMatrix< SecondWidth, Width, Element > &matrix) const
 Get result of multiplication of two matrices. More...
 
void GetMultiplied (const TVector< Width, Element > &vector, TVector< Height, Element > &result) const
 Get result of multiplication of this matrix and some vector. More...
 
TVector< Height, Element > GetMultiplied (const TVector< Width, Element > &vector) const
 Get result of multiplication of this matrix and some vector. More...
 
void GetScaled (double value, TMatrix< Width, Height, Element > &result) const
 Get result of multiplication of this matrix with scalar value. More...
 
void GetTransposed (TMatrix< Height, Width, Element > &result) const
 Get transposed matrix. More...
 
TMatrix< Height, Width, Element > 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 (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. More...
 
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. More...
 
void GetColumnVector (int columnIndex, TVector< Height, Element > &result)
 Get single column as vector. More...
 
void SetColumnVector (int columnIndex, const TVector< Height, Element > &columnVector)
 Set a single column vector to matrix. More...
 
void GetRowVector (int rowIndex, TVector< Width, Element > &result)
 Get single row as vector. More...
 
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 27 of file TMatrix.h.

Member Typedef Documentation

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

Definition at line 33 of file TMatrix.h.

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

Definition at line 32 of file TMatrix.h.

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

Definition at line 30 of file TMatrix.h.

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

Definition at line 34 of file TMatrix.h.

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

Definition at line 31 of file TMatrix.h.

Member Enumeration Documentation

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

Constructor & Destructor Documentation

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

Create matrix without initialization.

Definition at line 455 of file TMatrix.h.

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

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

Copy constructor.

Definition at line 523 of file TMatrix.h.

Member Function Documentation

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

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

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

template<int Width, int Height, typename Element >
const TMatrix< Width, Height, Element >::ElementType & imath::TMatrix< Width, Height, Element >::GetAt ( const IndexType index) const
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 630 of file TMatrix.h.

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

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

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

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

Get single column as vector.

Definition at line 869 of file TMatrix.h.

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 824 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().

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

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

Definition at line 817 of file TMatrix.h.

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

Definition at line 802 of file TMatrix.h.

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

Definition at line 681 of file TMatrix.h.

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

Definition at line 700 of file TMatrix.h.

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

Get result of multiplication of two matrices.

Definition at line 195 of file TMatrix.h.

Referenced by imath::TMatrix< Width, Height, Element >::GetDecompositionQDQ(), imath::TMatrix< 3, 3 >::GetMultiplied(), and imath::TMatrix< 3, 3 >::operator*().

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

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

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

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

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

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

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

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

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

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

Get trace of this matrix.

Definition at line 788 of file TMatrix.h.

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

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

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 904 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().

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

Create identity matrix.

Definition at line 665 of file TMatrix.h.

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

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

Definition at line 1043 of file TMatrix.h.

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

Definition at line 311 of file TMatrix.h.

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

Definition at line 408 of file TMatrix.h.

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

Definition at line 437 of file TMatrix.h.

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

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

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

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

Definition at line 397 of file TMatrix.h.

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

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

Definition at line 1028 of file TMatrix.h.

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

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

Definition at line 1065 of file TMatrix.h.

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

template<int Width, int Height, typename Element >
bool imath::TMatrix< Width, Height, Element >::Serialize ( iser::IArchive archive)
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 651 of file TMatrix.h.

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

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

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

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

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

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

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

Transpose matrix.

Definition at line 353 of file TMatrix.h.


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

© 2007-2017 Witold Gantzke and Kirill Lepskiy