XMM - Probabilistic Models for Motion Recognition and Mapping

Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
xmm::Matrix< T > Class Template Reference

Dirty and very incomplete Matrix Class. More...

#include <xmmMatrix.hpp>

Public Member Functions

 Matrix (bool ownData_=true)
 Default Constructor. More...
 
 Matrix (unsigned int nrows_, bool ownData_=true)
 Square Matrix Constructor. More...
 
 Matrix (unsigned int nrows_, unsigned int ncols_, bool ownData_=true)
 Constructor. More...
 
 Matrix (unsigned int nrows_, unsigned int ncols_, typename std::vector< T >::iterator data_it)
 Constructor from vector (shared data) More...
 
void resize (unsigned int nrows_, unsigned int ncols_)
 Resize the matrix. More...
 
void resize (unsigned int nrows_)
 Resize a Square Matrix. More...
 
float sum () const
 Compute the Sum of the matrix. More...
 
void print () const
 Print the matrix. More...
 
Matrix< T > * transpose () const
 Compute the transpose matrix. More...
 
Matrix< T > * product (Matrix const *mat) const
 Compute the product of matrices. More...
 
Matrix< T > * pinv (double *det) const
 Compute the Pseudo-Inverse of a Matrix. More...
 
Matrix< T > * gauss_jordan_inverse (double *det) const
 Compute the Gauss-Jordan Inverse of a Square Matrix. More...
 
void swap_lines (unsigned int i, unsigned int j)
 Swap 2 lines of the matrix. More...
 
void swap_columns (unsigned int i, unsigned int j)
 Swap 2 columns of the matrix. More...
 

Static Public Member Functions

static const double kEpsilonPseudoInverse ()
 Epsilon value for Matrix inversion. More...
 

Public Attributes

unsigned int nrows
 number of rows of the matrix More...
 
unsigned int ncols
 number of columns of the matrix More...
 
std::vector< T > _data
 Matrix Data if not shared. More...
 
std::vector< T >::iterator data
 Data iterator. More...
 
bool ownData
 Defines if the matrix has its own data. More...
 

Detailed Description

template<typename T>
class xmm::Matrix< T >

Dirty and very incomplete Matrix Class.

Contains few utilities for matrix operations, with possibility to share data with vectors

Template Parameters
Tdata type of the matrix (should be used with float/double)

Constructor & Destructor Documentation

template<typename T>
xmm::Matrix< T >::Matrix ( bool  ownData_ = true)
inline

Default Constructor.

Parameters
ownData_defines if the matrix stores the data itself (true by default)
template<typename T>
xmm::Matrix< T >::Matrix ( unsigned int  nrows_,
bool  ownData_ = true 
)
inline

Square Matrix Constructor.

Parameters
nrows_Number of rows (defines a square matrix)
ownData_defines if the matrix stores the data itself (true by default)
template<typename T>
xmm::Matrix< T >::Matrix ( unsigned int  nrows_,
unsigned int  ncols_,
bool  ownData_ = true 
)
inline

Constructor.

Parameters
nrows_Number of rows
ncols_Number of columns
ownData_defines if the matrix stores the data itself (true by default)
template<typename T>
xmm::Matrix< T >::Matrix ( unsigned int  nrows_,
unsigned int  ncols_,
typename std::vector< T >::iterator  data_it 
)
inline

Constructor from vector (shared data)

Parameters
nrows_Number of rows
ncols_Number of columns
data_ititerator to the vector data

Member Function Documentation

template<typename T>
Matrix<T>* xmm::Matrix< T >::gauss_jordan_inverse ( double *  det) const
inline

Compute the Gauss-Jordan Inverse of a Square Matrix.

Parameters
detDeterminant (computed with the inversion)
Returns
pointer to the inverse Matrix
Warning
Memory is allocated for the new matrix (need to be freed)
Exceptions
runtime_errorif the matrix is not square
runtime_errorif the matrix is not invertible
template<typename T>
static const double xmm::Matrix< T >::kEpsilonPseudoInverse ( )
inlinestatic

Epsilon value for Matrix inversion.

defines

template<typename T>
Matrix<T>* xmm::Matrix< T >::pinv ( double *  det) const
inline

Compute the Pseudo-Inverse of a Matrix.

Parameters
detDeterminant (computed with the inversion)
Returns
pointer to the inverse Matrix
Warning
Memory is allocated for the new matrix (need to be freed)
template<typename T>
void xmm::Matrix< T >::print ( ) const
inline

Print the matrix.

template<typename T>
Matrix<T>* xmm::Matrix< T >::product ( Matrix< T > const *  mat) const
inline

Compute the product of matrices.

Returns
pointer to the Matrix resulting of the product
Warning
Memory is allocated for the new matrix (need to be freed)
Exceptions
runtime_errorif the matrices have wrong dimensions
template<typename T>
void xmm::Matrix< T >::resize ( unsigned int  nrows_,
unsigned int  ncols_ 
)
inline

Resize the matrix.

Parameters
nrows_Number of rows
ncols_Number of columns
Exceptions
runtime_errorif the matrix is not square
template<typename T>
void xmm::Matrix< T >::resize ( unsigned int  nrows_)
inline

Resize a Square Matrix.

Parameters
nrows_Number of rows
template<typename T>
float xmm::Matrix< T >::sum ( ) const
inline

Compute the Sum of the matrix.

Returns
sum of all elements in the matrix
template<typename T>
void xmm::Matrix< T >::swap_columns ( unsigned int  i,
unsigned int  j 
)
inline

Swap 2 columns of the matrix.

Parameters
iindex of the first column
jindex of the second column
template<typename T>
void xmm::Matrix< T >::swap_lines ( unsigned int  i,
unsigned int  j 
)
inline

Swap 2 lines of the matrix.

Parameters
iindex of the first line
jindex of the second line
template<typename T>
Matrix<T>* xmm::Matrix< T >::transpose ( ) const
inline

Compute the transpose matrix.

Returns
pointer to the transpose Matrix
Warning
Memory is allocated for the new matrix (need to be freed)

Member Data Documentation

template<typename T>
std::vector<T> xmm::Matrix< T >::_data

Matrix Data if not shared.

template<typename T>
std::vector<T>::iterator xmm::Matrix< T >::data

Data iterator.

Can point to own data vector, or can be shared with another container.

template<typename T>
unsigned int xmm::Matrix< T >::ncols

number of columns of the matrix

template<typename T>
unsigned int xmm::Matrix< T >::nrows

number of rows of the matrix

template<typename T>
bool xmm::Matrix< T >::ownData

Defines if the matrix has its own data.


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