Image Component Library (ICL)
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
icl::math::FixedMatrix< T, COLS, ROWS > Class Template Reference

Powerful and highly flexible matrix class implementation. More...

#include <FixedMatrix.h>

Inheritance diagram for icl::math::FixedMatrix< T, COLS, ROWS >:
icl::utils::FixedArray< T, COLS *ROWS > icl::math::FixedMatrixBase

Classes

struct  col_iterator
 internal struct for row-wise iteration with stride=COLS More...
 

Public Types

typedef T * iterator
 iterator type More...
 
typedef const T * const_iterator
 const iterator type More...
 
typedef T * row_iterator
 row_iterator More...
 
typedef const T * const_row_iterator
 const row_iterator More...
 
typedef const col_iterator const_col_iterator
 

Public Member Functions

DynMatrix< T > dyn ()
 creates a shallow copied DynMatrix instance wrapping this' data More...
 
const DynMatrix< T > dyn () const
 creates a shallow copied DynMatrix instance wrapping this' data (const) More...
 
 FixedMatrix ()
 Default constructor. More...
 
 FixedMatrix (const T &initValue)
 Create Matrix and initialize elements with given value. More...
 
 FixedMatrix (const T *srcdata)
 Create matrix with given data pointer (const version) More...
 
 FixedMatrix (const T &v0, const T &v1, const T &v2=0, const T &v3=0, const T &v4=0, const T &v5=0, const T &v6=0, const T &v7=0, const T &v8=0, const T &v9=0, const T &v10=0, const T &v11=0, const T &v12=0, const T &v13=0, const T &v14=0, const T &v15=0)
 Create matrix with given initializer elements (16 values max) More...
 
template<class OtherIterator >
 FixedMatrix (OtherIterator begin, OtherIterator end)
 Range based constructor for STL compatiblitiy. More...
 
 FixedMatrix (const FixedMatrix &other)
 
template<class otherT >
 FixedMatrix (const FixedMatrix< otherT, COLS, ROWS > &other)
 
template<class Iterator >
 FixedMatrix (const FixedMatrixPart< T, DIM, Iterator > &r)
 Create matrix of a sub-part of another matrix (identical types) More...
 
template<class otherT , class Iterator >
 FixedMatrix (const FixedMatrixPart< otherT, DIM, Iterator > &r)
 Create matrix of a sub-part of another matrix (compatible types) More...
 
FixedMatrixoperator= (const FixedMatrix &other)
 Assignment operator (with compatible data type) (deep copy) More...
 
template<class otherT >
FixedMatrixoperator= (const FixedMatrix< otherT, COLS, ROWS > &other)
 Assignment operator (with compatible data type) (deep copy) More...
 
FixedMatrixoperator= (const T &t)
 Assign all elements with given value. More...
 
template<class Iterator >
FixedMatrixoperator= (const FixedMatrixPart< T, DIM, Iterator > &r)
 Assign matrix elements with sup-part of another matrix (identical types) More...
 
template<class otherT , class Iterator >
FixedMatrixoperator= (const FixedMatrixPart< otherT, DIM, Iterator > &r)
 Assign matrix elements with sup-part of another matrix (compatible types) More...
 
FixedMatrix operator/ (const FixedMatrix &m) const
 Matrix devision. More...
 
FixedMatrixoperator/= (const FixedMatrix &m)
 Matrix devision (inplace) More...
 
FixedMatrix operator * (T f) const
 Multiply all elements by a scalar. More...
 
FixedMatrixoperator *= (T f)
 moved outside the class Multiply all elements by a scalar (inplace) More...
 
FixedMatrix operator/ (T f) const
 Divide all elements by a scalar. More...
 
FixedMatrixoperator/= (T f)
 Divide all elements by a scalar. More...
 
FixedMatrix operator+ (const T &t) const
 Add a scalar to each element. More...
 
FixedMatrixoperator+= (const T &t)
 Add a scalar to each element (inplace) More...
 
FixedMatrix operator- (const T &t) const
 Substract a scalar from each element. More...
 
FixedMatrixoperator-= (const T &t)
 Substract a scalar from each element (inplace) More...
 
FixedMatrix operator+ (const FixedMatrix &m) const
 Element-wise matrix addition. More...
 
FixedMatrixoperator+= (const FixedMatrix &m)
 Element-wise matrix addition (inplace) More...
 
FixedMatrix operator- (const FixedMatrix &m) const
 Element-wise matrix subtraction. More...
 
FixedMatrixoperator-= (const FixedMatrix &m)
 Element-wise matrix subtraction (inplace) More...
 
FixedMatrix operator- () const
 Prefix - operator. More...
 
T & operator() (unsigned int col, unsigned int row)
 Element access operator. More...
 
const T & operator() (unsigned int col, unsigned int row) const
 Element access operator (const) More...
 
T & at (unsigned int col, unsigned int row)
 Element access index save (with exception if index is invalid) More...
 
const T & at (unsigned int col, unsigned int row) const
 Element access index save (with exception if index is invalid) (const) More...
 
T & operator[] (unsigned int idx)
 linear data view element access More...
 
const T & operator[] (unsigned int idx) const
 linear data view element access (const) More...
 
T * data ()
 return internal data pointer More...
 
const T * data () const
 return internal data pointer (const) More...
 
iterator begin ()
 returns an iterator to first element iterating over each element (row-major order) More...
 
iterator end ()
 returns an iterator after the last element More...
 
const_iterator begin () const
 returns an iterator to first element iterating over each element (row-major order) (const) More...
 
const_iterator end () const
 returns an iterator after the last element (const) More...
 
col_iterator col_begin (unsigned int col)
 returns an iterator iterating over a certain column More...
 
col_iterator col_end (unsigned int col)
 row end iterator More...
 
const_col_iterator col_begin (unsigned int col) const
 returns an iterator iterating over a certain column (const) More...
 
const_col_iterator col_end (unsigned int col) const
 row end iterator const More...
 
row_iterator row_begin (unsigned int row)
 returns an iterator iterating over a certain row More...
 
row_iterator row_end (unsigned int row)
 row end iterator More...
 
const_row_iterator row_begin (unsigned int row) const
 returns an iterator iterating over a certain row (const) More...
 
const_row_iterator row_end (unsigned int row) const
 row end iterator (const) More...
 
template<unsigned int MCOLS>
void mult (const FixedMatrix< T, MCOLS, COLS > &m, FixedMatrix< T, MCOLS, ROWS > &dst) const
 inplace matrix multiplication (dst = (*this)*m) More...
 
template<unsigned int MCOLS>
FixedMatrix< T, MCOLS, ROWS > operator * (const FixedMatrix< T, MCOLS, COLS > &m) const
 Matrix multiplication (essential) More...
 
FixedMatrix inv () const
 invert the matrix (only implemented with IPP_OPTIMIZATION and only for icl32f and icl64f) More...
 
det () const
 calculate matrix determinant (only implemented with IPP_OPTIMIZATION and only for icl32f and icl64f) More...
 
FixedMatrix< T, ROWS, COLS > transp () const
 returns matrix's transposed More...
 
template<unsigned int OTHER_COLS>
element_wise_inner_product (const FixedMatrix< T, OTHER_COLS, DIM/OTHER_COLS > &other) const
 inner product of data pointers (not matrix-mulitiplication) More...
 
template<unsigned int OTHER_COLS>
FixedMatrix< T, OTHER_COLS, COLS > dot (const FixedMatrix< T, OTHER_COLS, ROWS > &M) const
 returns the inner product of two matrices (i.e. dot-product) More...
 
double cond (const double p=2) const
 computes the condition of a fixed matrix More...
 
trace () const
 computes the sum of all diagonal elements More...
 
FixedMatrixPart< T, COLS, row_iteratorrow (unsigned int idx)
 returns a matrix row-reference iterator pair More...
 
FixedMatrixPart< T, COLS, const_row_iteratorrow (unsigned int idx) const
 returns a matrix row-reference iterator pair (const) More...
 
FixedMatrixPart< T, ROWS, col_iteratorcol (unsigned int idx)
 returns a matrix col-reference iterator pair More...
 
FixedMatrixPart< T, ROWS, const_col_iteratorcol (unsigned int idx) const
 returns a matrix col-reference iterator pair (const) More...
 
template<unsigned int X, unsigned int Y, unsigned int WIDTH, unsigned int HEIGHT>
FixedMatrixPart< T, WIDTH *HEIGHT, MatrixSubRectIterator< T > > part ()
 extracts a rectangular matrix sub region More...
 
template<unsigned int X, unsigned int Y, unsigned int WIDTH, unsigned int HEIGHT>
const FixedMatrixPart< T, WIDTH *HEIGHT, MatrixSubRectIterator< T > > part () const
 extracts a rectangular matrix sub region (const) More...
 
template<unsigned int NEW_WIDTH, unsigned int NEW_HEIGHT>
FixedMatrix< T, NEW_WIDTH, NEW_HEIGHT > resize (const T &init=T(0)) const
 extends/shrinks matrix dimensions while preserving content on remaining elements (without scaling) More...
 
double length (T norm=2) const
 Calculates the length of the matrix data vector. More...
 
void normalize (T norm=2)
 inplace normalization More...
 
FixedMatrix< T, COLS, ROWS > normalized (T norm=2) const
 create a normalized version of this matrix More...
 
template<class otherT >
bool operator== (const FixedMatrix< otherT, COLS, ROWS > &m) const
 Element-wise comparison with other matrix. More...
 
template<class otherT >
bool operator!= (const FixedMatrix< otherT, COLS, ROWS > &m) const
 Element-wise comparison with other matrix. More...
 
FixedMatrix< T, 1, ROWS > diag () const
 returns a vector of the diagonal elements (only for squared matrices) More...
 
void decompose_QR (FixedMatrix< T, COLS, ROWS > &Q, FixedMatrix< T, COLS, COLS > &R) const
 computes the QR decomposition of a matrix More...
 
void decompose_RQ (FixedMatrix< T, ROWS, ROWS > &R, FixedMatrix< T, ROWS, ROWS > &Q) const
 computes the RQ decomposition of a matrix More...
 
void svd (FixedMatrix< T, COLS, ROWS > &U, FixedMatrix< T, 1, COLS > &s, FixedMatrix< T, COLS, COLS > &V) const
 computes Singular Value Decomposition of this Matrix A = U diag(s) V' More...
 
FixedMatrix< T, ROWS, COLS > pinv (bool useSVD=0, float zeroThreshold=0.00000000000000001) const
 Computes the Matrix's pseudo-inverse. More...
 
void eigen (FixedMatrix &eigenvectors, FixedMatrix< T, 1, COLS > &eigenvalues) const
 Extracts the matrix's eigenvalues and eigenvectors. More...
 
- Public Member Functions inherited from icl::utils::FixedArray< T, COLS *ROWS >
T & operator[] (unsigned int idx)
 index access operator More...
 
const T & operator[] (unsigned int idx) const
 index access operator (const) More...
 

Static Public Member Functions

static const FixedMatrixnull ()
 returning a reference to a null matrix More...
 
static unsigned int rows ()
 compatibility-function returns template parameter ROWS More...
 
static unsigned int cols ()
 compatibility-function returns template parameter COLS More...
 
static unsigned int dim ()
 return static member variable DIM (COLS*ROWS) More...
 
static FixedMatrix< T, ROWS, COLS > id ()
 create identity matrix More...
 
- Static Public Member Functions inherited from icl::math::FixedMatrixBase
template<class SrcIterator , class DstIterator , unsigned int N>
static void optimized_copy (SrcIterator srcBegin, SrcIterator srcEnd, DstIterator dstBegin)
 Optimized copy function template (for N>30 using std::copy, otherwise a simple loop is used) More...
 

Static Public Attributes

static const unsigned int DIM = COLS*ROWS
 count of matrix elements (COLS x ROWS) More...
 

Additional Inherited Members

- Public Attributes inherited from icl::utils::FixedArray< T, COLS *ROWS >
m_data [DIM]
 

Detailed Description

template<class T, unsigned int COLS, unsigned int ROWS>
class icl::math::FixedMatrix< T, COLS, ROWS >

Powerful and highly flexible matrix class implementation.

By using fixed template parameters as Matrix dimensions, specializations to e.g. row or column vectors, are also as performant as possible.

Performance

Here are some benchmark results (measured on a 2GHz Core2Duo). All results are means of 10000 measurements using float matrices.

Member Typedef Documentation

◆ const_col_iterator

template<class T, unsigned int COLS, unsigned int ROWS>
typedef const col_iterator icl::math::FixedMatrix< T, COLS, ROWS >::const_col_iterator

◆ const_iterator

template<class T, unsigned int COLS, unsigned int ROWS>
typedef const T* icl::math::FixedMatrix< T, COLS, ROWS >::const_iterator

const iterator type

◆ const_row_iterator

template<class T, unsigned int COLS, unsigned int ROWS>
typedef const T* icl::math::FixedMatrix< T, COLS, ROWS >::const_row_iterator

const row_iterator

◆ iterator

template<class T, unsigned int COLS, unsigned int ROWS>
typedef T* icl::math::FixedMatrix< T, COLS, ROWS >::iterator

iterator type

◆ row_iterator

template<class T, unsigned int COLS, unsigned int ROWS>
typedef T* icl::math::FixedMatrix< T, COLS, ROWS >::row_iterator

row_iterator

Constructor & Destructor Documentation

◆ FixedMatrix() [1/9]

template<class T, unsigned int COLS, unsigned int ROWS>
icl::math::FixedMatrix< T, COLS, ROWS >::FixedMatrix ( )
inline

Default constructor.

New data is created internally but elements are not initialized

◆ FixedMatrix() [2/9]

template<class T, unsigned int COLS, unsigned int ROWS>
icl::math::FixedMatrix< T, COLS, ROWS >::FixedMatrix ( const T &  initValue)
inlineexplicit

Create Matrix and initialize elements with given value.

◆ FixedMatrix() [3/9]

template<class T, unsigned int COLS, unsigned int ROWS>
icl::math::FixedMatrix< T, COLS, ROWS >::FixedMatrix ( const T *  srcdata)
inlineexplicit

Create matrix with given data pointer (const version)

As given data pointer is const, no shallow pointer copies are allowed here

Parameters
srcdataconst source data pointer copied deeply

◆ FixedMatrix() [4/9]

template<class T, unsigned int COLS, unsigned int ROWS>
icl::math::FixedMatrix< T, COLS, ROWS >::FixedMatrix ( const T &  v0,
const T &  v1,
const T &  v2 = 0,
const T &  v3 = 0,
const T &  v4 = 0,
const T &  v5 = 0,
const T &  v6 = 0,
const T &  v7 = 0,
const T &  v8 = 0,
const T &  v9 = 0,
const T &  v10 = 0,
const T &  v11 = 0,
const T &  v12 = 0,
const T &  v13 = 0,
const T &  v14 = 0,
const T &  v15 = 0 
)
inline

Create matrix with given initializer elements (16 values max)

default parameters for unnecessary parameters are not created when compiled with -O4

◆ FixedMatrix() [5/9]

template<class T, unsigned int COLS, unsigned int ROWS>
template<class OtherIterator >
icl::math::FixedMatrix< T, COLS, ROWS >::FixedMatrix ( OtherIterator  begin,
OtherIterator  end 
)
inline

Range based constructor for STL compatiblitiy.

Range size must be compatible to the new matrix's dimension

◆ FixedMatrix() [6/9]

template<class T, unsigned int COLS, unsigned int ROWS>
icl::math::FixedMatrix< T, COLS, ROWS >::FixedMatrix ( const FixedMatrix< T, COLS, ROWS > &  other)
inline

◆ FixedMatrix() [7/9]

template<class T, unsigned int COLS, unsigned int ROWS>
template<class otherT >
icl::math::FixedMatrix< T, COLS, ROWS >::FixedMatrix ( const FixedMatrix< otherT, COLS, ROWS > &  other)
inline

◆ FixedMatrix() [8/9]

template<class T, unsigned int COLS, unsigned int ROWS>
template<class Iterator >
icl::math::FixedMatrix< T, COLS, ROWS >::FixedMatrix ( const FixedMatrixPart< T, DIM, Iterator > &  r)
inline

Create matrix of a sub-part of another matrix (identical types)

◆ FixedMatrix() [9/9]

template<class T, unsigned int COLS, unsigned int ROWS>
template<class otherT , class Iterator >
icl::math::FixedMatrix< T, COLS, ROWS >::FixedMatrix ( const FixedMatrixPart< otherT, DIM, Iterator > &  r)
inline

Create matrix of a sub-part of another matrix (compatible types)

Member Function Documentation

◆ at() [1/2]

template<class T, unsigned int COLS, unsigned int ROWS>
T& icl::math::FixedMatrix< T, COLS, ROWS >::at ( unsigned int  col,
unsigned int  row 
)
inline

Element access index save (with exception if index is invalid)

◆ at() [2/2]

template<class T, unsigned int COLS, unsigned int ROWS>
const T& icl::math::FixedMatrix< T, COLS, ROWS >::at ( unsigned int  col,
unsigned int  row 
) const
inline

Element access index save (with exception if index is invalid) (const)

◆ begin() [1/2]

template<class T, unsigned int COLS, unsigned int ROWS>
iterator icl::math::FixedMatrix< T, COLS, ROWS >::begin ( )
inline

returns an iterator to first element iterating over each element (row-major order)

◆ begin() [2/2]

template<class T, unsigned int COLS, unsigned int ROWS>
const_iterator icl::math::FixedMatrix< T, COLS, ROWS >::begin ( ) const
inline

returns an iterator to first element iterating over each element (row-major order) (const)

◆ col() [1/2]

template<class T, unsigned int COLS, unsigned int ROWS>
FixedMatrixPart<T,ROWS,col_iterator> icl::math::FixedMatrix< T, COLS, ROWS >::col ( unsigned int  idx)
inline

returns a matrix col-reference iterator pair

◆ col() [2/2]

template<class T, unsigned int COLS, unsigned int ROWS>
FixedMatrixPart<T,ROWS,const_col_iterator> icl::math::FixedMatrix< T, COLS, ROWS >::col ( unsigned int  idx) const
inline

returns a matrix col-reference iterator pair (const)

◆ col_begin() [1/2]

template<class T, unsigned int COLS, unsigned int ROWS>
col_iterator icl::math::FixedMatrix< T, COLS, ROWS >::col_begin ( unsigned int  col)
inline

returns an iterator iterating over a certain column

◆ col_begin() [2/2]

template<class T, unsigned int COLS, unsigned int ROWS>
const_col_iterator icl::math::FixedMatrix< T, COLS, ROWS >::col_begin ( unsigned int  col) const
inline

returns an iterator iterating over a certain column (const)

◆ col_end() [1/2]

template<class T, unsigned int COLS, unsigned int ROWS>
col_iterator icl::math::FixedMatrix< T, COLS, ROWS >::col_end ( unsigned int  col)
inline

row end iterator

◆ col_end() [2/2]

template<class T, unsigned int COLS, unsigned int ROWS>
const_col_iterator icl::math::FixedMatrix< T, COLS, ROWS >::col_end ( unsigned int  col) const
inline

row end iterator const

◆ cols()

template<class T, unsigned int COLS, unsigned int ROWS>
static unsigned int icl::math::FixedMatrix< T, COLS, ROWS >::cols ( )
inlinestatic

compatibility-function returns template parameter COLS

◆ cond()

template<class T, unsigned int COLS, unsigned int ROWS>
double icl::math::FixedMatrix< T, COLS, ROWS >::cond ( const double  p = 2) const
inline

computes the condition of a fixed matrix

◆ data() [1/2]

template<class T, unsigned int COLS, unsigned int ROWS>
T* icl::math::FixedMatrix< T, COLS, ROWS >::data ( )
inline

return internal data pointer

◆ data() [2/2]

template<class T, unsigned int COLS, unsigned int ROWS>
const T* icl::math::FixedMatrix< T, COLS, ROWS >::data ( ) const
inline

return internal data pointer (const)

◆ decompose_QR()

template<class T, unsigned int COLS, unsigned int ROWS>
void icl::math::FixedMatrix< T, COLS, ROWS >::decompose_QR ( FixedMatrix< T, COLS, ROWS > &  Q,
FixedMatrix< T, COLS, COLS > &  R 
) const
inline

computes the QR decomposition of a matrix

implements the stabilized Gram-Schmidt orthonormalization. (Internally using DynMatrix wrappers

◆ decompose_RQ()

template<class T, unsigned int COLS, unsigned int ROWS>
void icl::math::FixedMatrix< T, COLS, ROWS >::decompose_RQ ( FixedMatrix< T, ROWS, ROWS > &  R,
FixedMatrix< T, ROWS, ROWS > &  Q 
) const
inline

computes the RQ decomposition of a matrix

implements the stabilized Gram-Schmidt orthonormalization. (Internally using DynMatrix wrappers

◆ det()

template<class T, unsigned int COLS, unsigned int ROWS>
T icl::math::FixedMatrix< T, COLS, ROWS >::det ( ) const
inline

calculate matrix determinant (only implemented with IPP_OPTIMIZATION and only for icl32f and icl64f)

This function internally uses an instance of DynMatrix<T> Additionally implemented (in closed form) for float and double for 2x2 3x3 and 4x4 matrices

◆ diag()

template<class T, unsigned int COLS, unsigned int ROWS>
FixedMatrix<T,1,ROWS> icl::math::FixedMatrix< T, COLS, ROWS >::diag ( ) const
inline

returns a vector of the diagonal elements (only for squared matrices)

◆ dim()

template<class T, unsigned int COLS, unsigned int ROWS>
static unsigned int icl::math::FixedMatrix< T, COLS, ROWS >::dim ( )
inlinestatic

return static member variable DIM (COLS*ROWS)

◆ dot()

template<class T, unsigned int COLS, unsigned int ROWS>
template<unsigned int OTHER_COLS>
FixedMatrix<T,OTHER_COLS,COLS> icl::math::FixedMatrix< T, COLS, ROWS >::dot ( const FixedMatrix< T, OTHER_COLS, ROWS > &  M) const
inline

returns the inner product of two matrices (i.e. dot-product)

A.dot(B) is equivalent to A.transp() * B TODO: optimize implementation (current implementation is A.transp() * B)

◆ dyn() [1/2]

template<class T, unsigned int COLS, unsigned int ROWS>
DynMatrix<T> icl::math::FixedMatrix< T, COLS, ROWS >::dyn ( )
inline

creates a shallow copied DynMatrix instance wrapping this' data

Note: dyn() must be used imediatedly without a copy! TODO: check!!!!

◆ dyn() [2/2]

template<class T, unsigned int COLS, unsigned int ROWS>
const DynMatrix<T> icl::math::FixedMatrix< T, COLS, ROWS >::dyn ( ) const
inline

creates a shallow copied DynMatrix instance wrapping this' data (const)

◆ eigen()

template<class T, unsigned int COLS, unsigned int ROWS>
void icl::math::FixedMatrix< T, COLS, ROWS >::eigen ( FixedMatrix< T, COLS, ROWS > &  eigenvectors,
FixedMatrix< T, 1, COLS > &  eigenvalues 
) const
inline

Extracts the matrix's eigenvalues and eigenvectors.

Internally, a DynMatrix wrapper is used. This function only works on squared symmetric matrices. Resulting eigenvalues are ordered in descending order. The destination matrices' sizes are adapted automatically.

The function is only available for icl32f and icl64f and it is IPP-accelerated in case of having Intel-IPP-Support. The Fallback implementation was basically taken from the Visualization Toolkit VTK (Version 5.6.0)

Note: There is no internal check if the matrix is really symmetric. If it is not symmetric, the behaviour of this function is not predictable

Parameters
eigenvectorscontains the resulting eigenvectors in it's columns
eigenvaluesbecomes a N-dimensional column vector which ith element is the eigenvalue that corresponds to the ith column of eigenvectors

◆ element_wise_inner_product()

template<class T, unsigned int COLS, unsigned int ROWS>
template<unsigned int OTHER_COLS>
T icl::math::FixedMatrix< T, COLS, ROWS >::element_wise_inner_product ( const FixedMatrix< T, OTHER_COLS, DIM/OTHER_COLS > &  other) const
inline

inner product of data pointers (not matrix-mulitiplication)

computes the inner-product of internal data vectors

◆ end() [1/2]

template<class T, unsigned int COLS, unsigned int ROWS>
iterator icl::math::FixedMatrix< T, COLS, ROWS >::end ( )
inline

returns an iterator after the last element

◆ end() [2/2]

template<class T, unsigned int COLS, unsigned int ROWS>
const_iterator icl::math::FixedMatrix< T, COLS, ROWS >::end ( ) const
inline

returns an iterator after the last element (const)

◆ id()

template<class T, unsigned int COLS, unsigned int ROWS>
static FixedMatrix<T,ROWS,COLS> icl::math::FixedMatrix< T, COLS, ROWS >::id ( )
inlinestatic

create identity matrix

if matrix is not a spare one, upper left square matrix is initialized with the fitting identity matrix and other elements are initialized with 0

◆ inv()

template<class T, unsigned int COLS, unsigned int ROWS>
FixedMatrix icl::math::FixedMatrix< T, COLS, ROWS >::inv ( ) const
inline

invert the matrix (only implemented with IPP_OPTIMIZATION and only for icl32f and icl64f)

This function internally uses an instance of DynMatrix<T> Additionally implemented (in closed form) for float and double for 2x2 3x3 and 4x4 matrices

Note: Inv will not compute a pseudo inverse matrix. Include iclFixedMatrixUtils.h instead and use the non-member template function pinv() instead for pseudo-inverse calculation

◆ length()

template<class T, unsigned int COLS, unsigned int ROWS>
double icl::math::FixedMatrix< T, COLS, ROWS >::length ( norm = 2) const
inline

Calculates the length of the matrix data vector.

◆ mult()

template<class T, unsigned int COLS, unsigned int ROWS>
template<unsigned int MCOLS>
void icl::math::FixedMatrix< T, COLS, ROWS >::mult ( const FixedMatrix< T, MCOLS, COLS > &  m,
FixedMatrix< T, MCOLS, ROWS > &  dst 
) const
inline

inplace matrix multiplication (dst = (*this)*m)

Inplace matrix multiplication for 4x4-float-matrices (using ipp-optimization) is approximately twice as fast as D=A*B operator based multiplication

Benchmark

1.000.000 Multiplications of 4x4-float matrices (using ipp-optimization) on a 2GHz Core-2-Duo take about 145ms using inplace multiplication and about 290ms using not-inplace multiplication.
TODO: These results differ from the general matrix benchmarks ??

Parameters
mright matrix multiplication operand
dstdestination of matrix multiplication
See also
operator*(const FixedMatrix<T,MCOLS,COLS>&)

◆ normalize()

template<class T, unsigned int COLS, unsigned int ROWS>
void icl::math::FixedMatrix< T, COLS, ROWS >::normalize ( norm = 2)
inline

inplace normalization

◆ normalized()

template<class T, unsigned int COLS, unsigned int ROWS>
FixedMatrix<T,COLS,ROWS> icl::math::FixedMatrix< T, COLS, ROWS >::normalized ( norm = 2) const
inline

create a normalized version of this matrix

◆ null()

template<class T, unsigned int COLS, unsigned int ROWS>
static const FixedMatrix& icl::math::FixedMatrix< T, COLS, ROWS >::null ( )
inlinestatic

returning a reference to a null matrix

◆ operator *() [1/2]

template<class T, unsigned int COLS, unsigned int ROWS>
FixedMatrix icl::math::FixedMatrix< T, COLS, ROWS >::operator * ( f) const
inline

Multiply all elements by a scalar.

◆ operator *() [2/2]

template<class T, unsigned int COLS, unsigned int ROWS>
template<unsigned int MCOLS>
FixedMatrix<T,MCOLS,ROWS> icl::math::FixedMatrix< T, COLS, ROWS >::operator * ( const FixedMatrix< T, MCOLS, COLS > &  m) const
inline

Matrix multiplication (essential)

matrices multiplication A*B is only valid if cols(A) is equal to rows(B). Resulting matrix has dimensions cols(B) x rows(A). Matrix mutliplication is ipp-optimized for float and double and for (2x2-, 3x3- and 4x4- matrices)

Parameters
mright operator in matrix multiplication
Returns

multiplication sceme

            __MCOLS__
           |      c  |
           |      c  |
         COLS     c  |  = right operand
           |      c  |
           |______c__|
   _COLS__  __________
  |      | |      /\ |
  |      | |      |  |  = result
ROWS     | |      |  |
  |rrrrrr| |<-----x  |  x is inner product <r,c>
  |______| |_________|
   

◆ operator *=()

template<class T, unsigned int COLS, unsigned int ROWS>
FixedMatrix& icl::math::FixedMatrix< T, COLS, ROWS >::operator *= ( f)
inline

moved outside the class Multiply all elements by a scalar (inplace)

◆ operator!=()

template<class T, unsigned int COLS, unsigned int ROWS>
template<class otherT >
bool icl::math::FixedMatrix< T, COLS, ROWS >::operator!= ( const FixedMatrix< otherT, COLS, ROWS > &  m) const
inline

Element-wise comparison with other matrix.

◆ operator()() [1/2]

template<class T, unsigned int COLS, unsigned int ROWS>
T& icl::math::FixedMatrix< T, COLS, ROWS >::operator() ( unsigned int  col,
unsigned int  row 
)
inline

Element access operator.

◆ operator()() [2/2]

template<class T, unsigned int COLS, unsigned int ROWS>
const T& icl::math::FixedMatrix< T, COLS, ROWS >::operator() ( unsigned int  col,
unsigned int  row 
) const
inline

Element access operator (const)

◆ operator+() [1/2]

template<class T, unsigned int COLS, unsigned int ROWS>
FixedMatrix icl::math::FixedMatrix< T, COLS, ROWS >::operator+ ( const T &  t) const
inline

Add a scalar to each element.

◆ operator+() [2/2]

template<class T, unsigned int COLS, unsigned int ROWS>
FixedMatrix icl::math::FixedMatrix< T, COLS, ROWS >::operator+ ( const FixedMatrix< T, COLS, ROWS > &  m) const
inline

Element-wise matrix addition.

◆ operator+=() [1/2]

template<class T, unsigned int COLS, unsigned int ROWS>
FixedMatrix& icl::math::FixedMatrix< T, COLS, ROWS >::operator+= ( const T &  t)
inline

Add a scalar to each element (inplace)

◆ operator+=() [2/2]

template<class T, unsigned int COLS, unsigned int ROWS>
FixedMatrix& icl::math::FixedMatrix< T, COLS, ROWS >::operator+= ( const FixedMatrix< T, COLS, ROWS > &  m)
inline

Element-wise matrix addition (inplace)

◆ operator-() [1/3]

template<class T, unsigned int COLS, unsigned int ROWS>
FixedMatrix icl::math::FixedMatrix< T, COLS, ROWS >::operator- ( const T &  t) const
inline

Substract a scalar from each element.

◆ operator-() [2/3]

template<class T, unsigned int COLS, unsigned int ROWS>
FixedMatrix icl::math::FixedMatrix< T, COLS, ROWS >::operator- ( const FixedMatrix< T, COLS, ROWS > &  m) const
inline

Element-wise matrix subtraction.

◆ operator-() [3/3]

template<class T, unsigned int COLS, unsigned int ROWS>
FixedMatrix icl::math::FixedMatrix< T, COLS, ROWS >::operator- ( ) const
inline

Prefix - operator.

M + (-M) = 0;

◆ operator-=() [1/2]

template<class T, unsigned int COLS, unsigned int ROWS>
FixedMatrix& icl::math::FixedMatrix< T, COLS, ROWS >::operator-= ( const T &  t)
inline

Substract a scalar from each element (inplace)

◆ operator-=() [2/2]

template<class T, unsigned int COLS, unsigned int ROWS>
FixedMatrix& icl::math::FixedMatrix< T, COLS, ROWS >::operator-= ( const FixedMatrix< T, COLS, ROWS > &  m)
inline

Element-wise matrix subtraction (inplace)

◆ operator/() [1/2]

template<class T, unsigned int COLS, unsigned int ROWS>
FixedMatrix icl::math::FixedMatrix< T, COLS, ROWS >::operator/ ( const FixedMatrix< T, COLS, ROWS > &  m) const
inline

Matrix devision.

A/B is equal to A*inv(B) Only allowed form square matrices B

Parameters
mdenominator for division expression

◆ operator/() [2/2]

template<class T, unsigned int COLS, unsigned int ROWS>
FixedMatrix icl::math::FixedMatrix< T, COLS, ROWS >::operator/ ( f) const
inline

Divide all elements by a scalar.

◆ operator/=() [1/2]

template<class T, unsigned int COLS, unsigned int ROWS>
FixedMatrix& icl::math::FixedMatrix< T, COLS, ROWS >::operator/= ( const FixedMatrix< T, COLS, ROWS > &  m)
inline

Matrix devision (inplace)

◆ operator/=() [2/2]

template<class T, unsigned int COLS, unsigned int ROWS>
FixedMatrix& icl::math::FixedMatrix< T, COLS, ROWS >::operator/= ( f)
inline

Divide all elements by a scalar.

◆ operator=() [1/5]

template<class T, unsigned int COLS, unsigned int ROWS>
FixedMatrix& icl::math::FixedMatrix< T, COLS, ROWS >::operator= ( const FixedMatrix< T, COLS, ROWS > &  other)
inline

Assignment operator (with compatible data type) (deep copy)

◆ operator=() [2/5]

template<class T, unsigned int COLS, unsigned int ROWS>
template<class otherT >
FixedMatrix& icl::math::FixedMatrix< T, COLS, ROWS >::operator= ( const FixedMatrix< otherT, COLS, ROWS > &  other)
inline

Assignment operator (with compatible data type) (deep copy)

Internally using std::transform with icl::clipped_cast<otherT,T>

◆ operator=() [3/5]

template<class T, unsigned int COLS, unsigned int ROWS>
FixedMatrix& icl::math::FixedMatrix< T, COLS, ROWS >::operator= ( const T &  t)
inline

Assign all elements with given value.

◆ operator=() [4/5]

template<class T, unsigned int COLS, unsigned int ROWS>
template<class Iterator >
FixedMatrix& icl::math::FixedMatrix< T, COLS, ROWS >::operator= ( const FixedMatrixPart< T, DIM, Iterator > &  r)
inline

Assign matrix elements with sup-part of another matrix (identical types)

◆ operator=() [5/5]

template<class T, unsigned int COLS, unsigned int ROWS>
template<class otherT , class Iterator >
FixedMatrix& icl::math::FixedMatrix< T, COLS, ROWS >::operator= ( const FixedMatrixPart< otherT, DIM, Iterator > &  r)
inline

Assign matrix elements with sup-part of another matrix (compatible types)

◆ operator==()

template<class T, unsigned int COLS, unsigned int ROWS>
template<class otherT >
bool icl::math::FixedMatrix< T, COLS, ROWS >::operator== ( const FixedMatrix< otherT, COLS, ROWS > &  m) const
inline

Element-wise comparison with other matrix.

◆ operator[]() [1/2]

template<class T, unsigned int COLS, unsigned int ROWS>
T& icl::math::FixedMatrix< T, COLS, ROWS >::operator[] ( unsigned int  idx)
inline

linear data view element access

This function is very useful e.g. for derived classes FixedRowVector and FixedColVector

◆ operator[]() [2/2]

template<class T, unsigned int COLS, unsigned int ROWS>
const T& icl::math::FixedMatrix< T, COLS, ROWS >::operator[] ( unsigned int  idx) const
inline

linear data view element access (const)

This function is very useful e.g. for derived classes FixedRowVector and FixedColVector

◆ part() [1/2]

template<class T, unsigned int COLS, unsigned int ROWS>
template<unsigned int X, unsigned int Y, unsigned int WIDTH, unsigned int HEIGHT>
FixedMatrixPart<T,WIDTH*HEIGHT,MatrixSubRectIterator<T> > icl::math::FixedMatrix< T, COLS, ROWS >::part ( )
inline

extracts a rectangular matrix sub region

◆ part() [2/2]

template<class T, unsigned int COLS, unsigned int ROWS>
template<unsigned int X, unsigned int Y, unsigned int WIDTH, unsigned int HEIGHT>
const FixedMatrixPart<T,WIDTH*HEIGHT,MatrixSubRectIterator<T> > icl::math::FixedMatrix< T, COLS, ROWS >::part ( ) const
inline

extracts a rectangular matrix sub region (const)

◆ pinv()

template<class T, unsigned int COLS, unsigned int ROWS>
FixedMatrix<T,ROWS,COLS> icl::math::FixedMatrix< T, COLS, ROWS >::pinv ( bool  useSVD = 0,
float  zeroThreshold = 0.00000000000000001 
) const
inline

Computes the Matrix's pseudo-inverse.

internally a DynMatrix wrapper is used. If useSVD is false, a QR-decomposition based approach is used

◆ resize()

template<class T, unsigned int COLS, unsigned int ROWS>
template<unsigned int NEW_WIDTH, unsigned int NEW_HEIGHT>
FixedMatrix<T,NEW_WIDTH,NEW_HEIGHT> icl::math::FixedMatrix< T, COLS, ROWS >::resize ( const T &  init = T(0)) const
inline

extends/shrinks matrix dimensions while preserving content on remaining elements (without scaling)

This is resizing operation, which preserves contents for all remaining matrix elements. If new dimension is smaller than the current dimension, values are deleted. If otherwise new dimension gets larger, new allocated value are initialized with given init value.

◆ row() [1/2]

template<class T, unsigned int COLS, unsigned int ROWS>
FixedMatrixPart<T,COLS,row_iterator> icl::math::FixedMatrix< T, COLS, ROWS >::row ( unsigned int  idx)
inline

returns a matrix row-reference iterator pair

◆ row() [2/2]

template<class T, unsigned int COLS, unsigned int ROWS>
FixedMatrixPart<T,COLS,const_row_iterator> icl::math::FixedMatrix< T, COLS, ROWS >::row ( unsigned int  idx) const
inline

returns a matrix row-reference iterator pair (const)

◆ row_begin() [1/2]

template<class T, unsigned int COLS, unsigned int ROWS>
row_iterator icl::math::FixedMatrix< T, COLS, ROWS >::row_begin ( unsigned int  row)
inline

returns an iterator iterating over a certain row

◆ row_begin() [2/2]

template<class T, unsigned int COLS, unsigned int ROWS>
const_row_iterator icl::math::FixedMatrix< T, COLS, ROWS >::row_begin ( unsigned int  row) const
inline

returns an iterator iterating over a certain row (const)

◆ row_end() [1/2]

template<class T, unsigned int COLS, unsigned int ROWS>
row_iterator icl::math::FixedMatrix< T, COLS, ROWS >::row_end ( unsigned int  row)
inline

row end iterator

◆ row_end() [2/2]

template<class T, unsigned int COLS, unsigned int ROWS>
const_row_iterator icl::math::FixedMatrix< T, COLS, ROWS >::row_end ( unsigned int  row) const
inline

row end iterator (const)

◆ rows()

template<class T, unsigned int COLS, unsigned int ROWS>
static unsigned int icl::math::FixedMatrix< T, COLS, ROWS >::rows ( )
inlinestatic

compatibility-function returns template parameter ROWS

◆ svd()

template<class T, unsigned int COLS, unsigned int ROWS>
void icl::math::FixedMatrix< T, COLS, ROWS >::svd ( FixedMatrix< T, COLS, ROWS > &  U,
FixedMatrix< T, 1, COLS > &  s,
FixedMatrix< T, COLS, COLS > &  V 
) const
inline

computes Singular Value Decomposition of this Matrix A = U diag(s) V'

internally a DynMatrix wrapper is used

◆ trace()

template<class T, unsigned int COLS, unsigned int ROWS>
T icl::math::FixedMatrix< T, COLS, ROWS >::trace ( ) const
inline

computes the sum of all diagonal elements

◆ transp()

template<class T, unsigned int COLS, unsigned int ROWS>
FixedMatrix<T,ROWS,COLS> icl::math::FixedMatrix< T, COLS, ROWS >::transp ( ) const
inline

returns matrix's transposed

Member Data Documentation

◆ DIM

template<class T, unsigned int COLS, unsigned int ROWS>
const unsigned int icl::math::FixedMatrix< T, COLS, ROWS >::DIM = COLS*ROWS
static

count of matrix elements (COLS x ROWS)


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