MRPT logo

mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS > Class Template Reference

A numeric matrix of compile-time fixed size. More...

#include <mrpt/math/CMatrixFixedNumeric.h>

Collaboration diagram for mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >:
Collaboration graph
[legend]

List of all members.

Public Types

typedef T value_type
 The type of the matrix elements.

Public Member Functions

 CMatrixFixedNumeric ()
 Default constructor, fills the whole matrix with zeros.
 CMatrixFixedNumeric (bool, bool)
 Constructor which leaves the matrix uninitialized: it uses two bool arguments with ignored values, but they must be present to make the method signature distinctive and make sure that the user wants the matrix to be uninitialized (ie, leaving only one bool argument may lead to unintended conversions from bool values!) Example of usage: CMatrixFixedNumeric<double,3,2> M(UNITIALIZED_MATRIX);.
template<typename V , size_t N>
 CMatrixFixedNumeric (V(&theArray)[N])
 Constructor from a given size and a C array.
template<size_t N, size_t M>
 CMatrixFixedNumeric (const CMatrixFixedNumeric< T, N, M > &B)
 Copy constructor from another matrix of a different size: it's explicit so matrices of different sizes are not mixed by mistake.
template<typename R >
 CMatrixFixedNumeric (const CMatrixFixedNumeric< R, NROWS, NCOLS > &B)
 Copy constructor from another matrix of a different type: it's explicit so matrices of different types are not mixed by mistake.
template<typename R >
 CMatrixFixedNumeric (const CMatrixTemplate< R > &B, bool clipToFixedMatrixSize=false)
 Copy constructor from a dynamic-size matrix An exception will be raised if the sizes do not match, unless "clipToFixedMatrixSize" is true.
CMatrixFixedNumeric< T, NROWS,
NCOLS > & 
operator= (const CMatrixTemplate< T > &B)
 Conversion from a dynamic-size matrix to a fixed-size one.
template<typename R >
CMatrixFixedNumeric< T, NROWS,
NCOLS > & 
operator= (const CMatrixTemplate< R > &B)
 Conversion from a dynamic-size matrix of a different data type to a fixed-size one.
 CMatrixFixedNumeric (const CPoint2D &p)
 Assigns a pose to a 2x1 or 1x2 matrix.
 CMatrixFixedNumeric (const CPoint3D &p)
 Assigns a pose to a 3x1 or 1x3 matrix.
 CMatrixFixedNumeric (const CPose2D &p)
 Assigns a pose to a 3x1 or 1x3 matrix.
 CMatrixFixedNumeric (const CPose3D &p)
 Assigns a pose to a 6x1 or 1x6 matrix.
CMatrixFixedNumeric< T, NROWS,
NCOLS > & 
operator= (const CPoint2D &p)
 Assigns a pose to a 2x1 or 1x2 matrix.
CMatrixFixedNumeric< T, NROWS,
NCOLS > & 
operator= (const CPoint3D &p)
 Assigns a pose to a 3x1 or 1x3 matrix.
CMatrixFixedNumeric< T, NROWS,
NCOLS > & 
operator= (const CPose2D &p)
 Assigns a pose to a 3x1 or 1x3 matrix.
CMatrixFixedNumeric< T, NROWS,
NCOLS > & 
operator= (const CPose3D &p)
 Assigns a pose to a 6x1 or 1x6 matrix.
void unit ()
 Make the matrix an identity matrix.
void zeros ()
 Set all elements to zero.
void zeros (size_t N, size_t M)
 Set all elements to zero.
get_unsafe (const size_t row, const size_t col) const
 Read-only access to one element (Use with caution, bounds are not checked!).
T & get_unsafe (const size_t row, const size_t col)
 Reference access to one element (Use with caution, bounds are not checked!).
void set_unsafe (const size_t row, const size_t col, const T val)
 Sets an element (Use with caution, bounds are not checked!).
T & operator() (const size_t row, const size_t col)
 Subscript operator to get/set individual elements.
operator() (const size_t row, const size_t col) const
 Subscript operator to get/set individual elements.
std::string inMatlabFormat () const
 Gets the matrix as a string in matlab format, for example: [a11 a12 a12;a21 a22 a23].
bool fromMatlabStringFormat (const std::string &s)
 Read a matrix from a string in Matlab-like format, for example "[1 0 2; 0 4 -1]" The string must start with '[' and end with ']'.
void inv (CMatrixFixedNumeric< T, NROWS, NCOLS > &out_inv) const
 Returns the inverse of the matrix in "out_inv".
void inv_fast (CMatrixFixedNumeric< T, NROWS, NCOLS > &out_inv)
 Returns the inverse of the matrix in "out_inv" , DESTROYING the current matrix.
template<size_t NC1>
void multiply (const CMatrixFixedNumeric< T, NROWS, NC1 > &A, const CMatrixFixedNumeric< T, NC1, NCOLS > &B)
 this = A*B
template<size_t NC1>
void multiply_AAt (const CMatrixFixedNumeric< T, NROWS, NC1 > &A)
 this = A * A^t
void multiply_Ab (const std::vector< T > &a, std::vector< T > &out_v) const
 Computes the vector v = this * a, where "a" is a column vector of the appropriate length.
template<size_t N1, size_t N2>
void multiply_ABC (const CMatrixFixedNumeric< T, NROWS, N1 > &A, const CMatrixFixedNumeric< T, N1, N2 > &B, const CMatrixFixedNumeric< T, N2, NCOLS > &C)
 Calculate the operation this = A*B*C.
template<size_t N1, size_t N2>
void multiply_ABCt (const CMatrixFixedNumeric< T, NROWS, N1 > &A, const CMatrixFixedNumeric< T, N1, N2 > &B, const CMatrixFixedNumeric< T, NCOLS, N2 > &C)
 Calculate the operation this = A*B*Ct.
template<size_t M1>
void add_AAt (const CMatrixFixedNumeric< T, M1, M1 > &A)
 Sum to this matrix A and its transpose: this = this + A + At.
void add (const CMatrixFixedNumeric< T, NROWS, NCOLS > &A)
 Sum A to this matrix: this = this + A.
void substract (const CMatrixFixedNumeric< T, NROWS, NCOLS > &A)
 Substract A from this matrix: this = this - A.
void add_Ac (const CMatrixFixedNumeric< T, NROWS, NCOLS > &A, const T c)
 Sum A times a scalar to this matrix: this = this + A*c.
void substract_Ac (const CMatrixFixedNumeric< T, NROWS, NCOLS > &A, const T c)
 Substract A times a scalar from this matrix: this = this - A*c.
void operator*= (const T val)
 Multiplies all elements by a scalar.
void operator/= (const T val)
 Multiplies all elements by a scalar.
void operator+= (const T val)
 Sum a scalar to all elements.
void operator-= (const T val)
 Substract a scalar to all elements.
void operator+= (const CMatrixFixedNumeric< T, NROWS, NCOLS > &m)
 Sum a matrix to this one.
void operator-= (const CMatrixFixedNumeric< T, NROWS, NCOLS > &m)
 Substract a matrix to this one.
sumAll () const
 Returns the sum of all the elements.
minimum () const
 Returns the minimum of all the elements.
maximum () const
 Returns the maximum of all the elements.
void minimumAndMaximum (T &val_min, T &val_max) const
 Returns the minimum & maximum of all the elements.
det () const
 Returns the determinant of the matrix.
void Sqrt ()
 Applies the sqrt to all the elements.
void eigenVectors (CMatrixFixedNumeric< T, NROWS, NROWS > &Z, CMatrixFixedNumeric< T, NROWS, NROWS > &D) const
 Computes the eigenvalues/eigenvector decomposition of a symmetric matrix.
void force_symmetry ()
 Copy the upper half of the matrix into the lower half.
void multiply_HCHt (const CMatrixFixedNumeric< T, NCOLS, NCOLS > &C, CMatrixFixedNumeric< T, NROWS, NROWS > &R, bool accumResultInOutput=false) const
 This executes the operation $ \mathbf{R} = \mathbf{H} \mathbf{C} \mathbf{H}^t $, where 'this' matrix is $ \mathbf{H} $ and $ \mathbf{C} $ is symmetric, in an efficient and numerically stable way.
void multiplyColumnByScalar (size_t c, T scalar)
multiply_HCHt_scalar (const CMatrixFixedNumeric< T, NCOLS, NCOLS > &C) const
 Like multiply_HCHt but for resulting matrices of size 1x1, which is returned as a scalar.
void multiply_HtCH (const CMatrixFixedNumeric< T, NROWS, NROWS > &C, CMatrixFixedNumeric< T, NCOLS, NCOLS > &R, bool accumResultInOutput=false) const
 Like CMatrixFixedNumeric::multiply_HCHt but for Ht being given transpose.
multiply_HtCH_scalar (const CMatrixFixedNumeric< T, NROWS, NROWS > &C) const
 Like multiply_HtCH but for resulting matrices of size 1x1, which is returned as a scalar.
int pivot (const size_t row)
 Used for "det".
void swap_rows (size_t i1, size_t i2)
void swap_cols (size_t i1, size_t i2)
_E (const size_t row, const size_t col) const
 auxiliary member to get element (i,j), starting at (1,1) instead of (0,0)
T & _E (const size_t row, const size_t col)
 auxiliary member to get element (i,j), starting at (1,1) instead of (0,0)
template<size_t N>
void ASSERT_ENOUGHROOM (size_t r, size_t c) const
template<size_t N, typename ReturnType >
ReturnType getVicinity (size_t c, size_t r) const
Import/export as text

void saveToTextFile (const std::string &file, TMatrixTextFileFormat fileFormat=MATRIX_FORMAT_ENG, bool appendMRPTHeader=false, const std::string &userHeader=std::string("")) const
 Save matrix to a text file, compatible with MATLAB text format.
void loadFromTextFile (const std::string &file)
 Load matrix from a text file, compatible with MATLAB text format.

Static Public Member Functions

static size_t getRowCount ()
 Get number of rows.
static size_t getColCount ()
 Get number of columns.
static bool IsSquare ()
 Is square?
static void setSize (const size_t nRows, const size_t nCols)
 This method has no effects in this class.

Public Attributes

CArray< T, NROWS *NCOLS > m_Val
 The stored data of the matrix: elements are saved by rows, left to right, from top to bottom.

Detailed Description

template<typename T, size_t NROWS, size_t NCOLS>
class mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >

A numeric matrix of compile-time fixed size.

The template can be instanced for data types "float" or "double" Virtually all methods have specializations and/or SSE2 optimized implementations, so use this class when time is critical.

Note:
To enable SSE2 optimizations, add the definition "#define MRPT_USE_SSE2" BEFORE including MRPT headers in your code. This is because these optimizations are only applicable to static matrix objects, but not when they are created in dynamic memory.
See also:
CMatrixTemplateNumeric (for dynamic-size matrices)

Definition at line 88 of file CMatrixFixedNumeric.h.


Member Typedef Documentation

template<typename T, size_t NROWS, size_t NCOLS>
typedef T mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::value_type

The type of the matrix elements.

Definition at line 91 of file CMatrixFixedNumeric.h.


Constructor & Destructor Documentation

template<typename T, size_t NROWS, size_t NCOLS>
mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::CMatrixFixedNumeric (  )  [inline]

Default constructor, fills the whole matrix with zeros.

Definition at line 103 of file CMatrixFixedNumeric.h.

template<typename T, size_t NROWS, size_t NCOLS>
mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::CMatrixFixedNumeric ( bool  ,
bool   
) [inline]

Constructor which leaves the matrix uninitialized: it uses two bool arguments with ignored values, but they must be present to make the method signature distinctive and make sure that the user wants the matrix to be uninitialized (ie, leaving only one bool argument may lead to unintended conversions from bool values!) Example of usage: CMatrixFixedNumeric<double,3,2> M(UNITIALIZED_MATRIX);.

Definition at line 114 of file CMatrixFixedNumeric.h.

template<typename T, size_t NROWS, size_t NCOLS>
template<typename V , size_t N>
mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::CMatrixFixedNumeric ( V(&)  theArray[N]  )  [inline]

Constructor from a given size and a C array.

The array length must match cols x row.

  const double numbers[] = {
    1,2,3,
    4,5,6 };
         CMatrixFixedNumeric<double,3,2>    M(numbers);

Definition at line 126 of file CMatrixFixedNumeric.h.

template<typename T, size_t NROWS, size_t NCOLS>
template<size_t N, size_t M>
mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::CMatrixFixedNumeric ( const CMatrixFixedNumeric< T, N, M > &  B  )  [inline, explicit]

Copy constructor from another matrix of a different size: it's explicit so matrices of different sizes are not mixed by mistake.

Definition at line 140 of file CMatrixFixedNumeric.h.

template<typename T, size_t NROWS, size_t NCOLS>
template<typename R >
mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::CMatrixFixedNumeric ( const CMatrixFixedNumeric< R, NROWS, NCOLS > &  B  )  [inline, explicit]

Copy constructor from another matrix of a different type: it's explicit so matrices of different types are not mixed by mistake.

Definition at line 152 of file CMatrixFixedNumeric.h.

template<typename T, size_t NROWS, size_t NCOLS>
template<typename R >
mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::CMatrixFixedNumeric ( const CMatrixTemplate< R > &  B,
bool  clipToFixedMatrixSize = false 
) [inline, explicit]

Copy constructor from a dynamic-size matrix An exception will be raised if the sizes do not match, unless "clipToFixedMatrixSize" is true.

Definition at line 163 of file CMatrixFixedNumeric.h.

template<typename T, size_t NROWS, size_t NCOLS>
mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::CMatrixFixedNumeric ( const CPoint2D p  )  [inline]

Assigns a pose to a 2x1 or 1x2 matrix.

Definition at line 221 of file CMatrixFixedNumeric.h.

template<typename T, size_t NROWS, size_t NCOLS>
mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::CMatrixFixedNumeric ( const CPoint3D p  )  [inline]

Assigns a pose to a 3x1 or 1x3 matrix.

Definition at line 223 of file CMatrixFixedNumeric.h.

template<typename T, size_t NROWS, size_t NCOLS>
mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::CMatrixFixedNumeric ( const CPose2D p  )  [inline]

Assigns a pose to a 3x1 or 1x3 matrix.

Definition at line 225 of file CMatrixFixedNumeric.h.

template<typename T, size_t NROWS, size_t NCOLS>
mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::CMatrixFixedNumeric ( const CPose3D p  )  [inline]

Assigns a pose to a 6x1 or 1x6 matrix.

Definition at line 227 of file CMatrixFixedNumeric.h.


Member Function Documentation

template<typename T, size_t NROWS, size_t NCOLS>
T& mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::_E ( const size_t  row,
const size_t  col 
) [inline]

auxiliary member to get element (i,j), starting at (1,1) instead of (0,0)

Definition at line 795 of file CMatrixFixedNumeric.h.

template<typename T, size_t NROWS, size_t NCOLS>
T mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::_E ( const size_t  row,
const size_t  col 
) const [inline]

auxiliary member to get element (i,j), starting at (1,1) instead of (0,0)

Definition at line 791 of file CMatrixFixedNumeric.h.

Referenced by mrpt::math::detMatrix(), and mrpt::math::invMatrix().

template<typename T, size_t NROWS, size_t NCOLS>
void mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::add ( const CMatrixFixedNumeric< T, NROWS, NCOLS > &  A  )  [inline]

Sum A to this matrix: this = this + A.

Definition at line 447 of file CMatrixFixedNumeric.h.

template<typename T, size_t NROWS, size_t NCOLS>
template<size_t M1>
void mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::add_AAt ( const CMatrixFixedNumeric< T, M1, M1 > &  A  )  [inline]

Sum to this matrix A and its transpose: this = this + A + At.

Definition at line 432 of file CMatrixFixedNumeric.h.

template<typename T, size_t NROWS, size_t NCOLS>
void mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::add_Ac ( const CMatrixFixedNumeric< T, NROWS, NCOLS > &  A,
const T  c 
) [inline]

Sum A times a scalar to this matrix: this = this + A*c.

Definition at line 461 of file CMatrixFixedNumeric.h.

template<typename T, size_t NROWS, size_t NCOLS>
template<size_t N>
void mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::ASSERT_ENOUGHROOM ( size_t  r,
size_t  c 
) const [inline]

Definition at line 799 of file CMatrixFixedNumeric.h.

template<typename T, size_t NROWS, size_t NCOLS>
T mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::det (  )  const [inline]

Returns the determinant of the matrix.

Definition at line 563 of file CMatrixFixedNumeric.h.

Referenced by mrpt::math::invMatrix(), mrpt::math::normalPDF(), and mrpt::math::productIntegralTwoGaussians().

template<typename T, size_t NROWS, size_t NCOLS>
void mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::eigenVectors ( CMatrixFixedNumeric< T, NROWS, NROWS > &  Z,
CMatrixFixedNumeric< T, NROWS, NROWS > &  D 
) const [inline]

Computes the eigenvalues/eigenvector decomposition of a symmetric matrix.

The decomposition is: M = Z · D · ZT, where columns in Z are the eigenvectors and the diagonal matrix D contains the eigenvalues as diagonal elements, sorted in ascending order. The algorithm is taken from "Numerical recipes in C", freely available online.

Definition at line 578 of file CMatrixFixedNumeric.h.

Referenced by mrpt::random::CRandomGenerator::drawGaussianMultivariate(), and mrpt::random::CRandomGenerator::drawGaussianMultivariateMany().

template<typename T, size_t NROWS, size_t NCOLS>
void mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::force_symmetry (  )  [inline]

Copy the upper half of the matrix into the lower half.

Definition at line 583 of file CMatrixFixedNumeric.h.

template<typename T, size_t NROWS, size_t NCOLS>
bool mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::fromMatlabStringFormat ( const std::string &  s  )  [inline]

Read a matrix from a string in Matlab-like format, for example "[1 0 2; 0 4 -1]" The string must start with '[' and end with ']'.

Rows are separated by semicolons ';' and columns in each row by one or more whitespaces ' ' or tabs.

This format is also used for CConfigFile::read_matrix.

This template method can be instantiated for matrices of the types: int, long, unsinged int, unsigned long, float, double, long double

Returns:
true on success. false if the string is malformed, or it is of the wrong size.
See also:
inMatlabFormat, CConfigFile::read_matrix

Definition at line 342 of file CMatrixFixedNumeric.h.

template<typename T, size_t NROWS, size_t NCOLS>
T& mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::get_unsafe ( const size_t  row,
const size_t  col 
) [inline]

Reference access to one element (Use with caution, bounds are not checked!).

Definition at line 274 of file CMatrixFixedNumeric.h.

template<typename T, size_t NROWS, size_t NCOLS>
T mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::get_unsafe ( const size_t  row,
const size_t  col 
) const [inline]

Read-only access to one element (Use with caution, bounds are not checked!).

Definition at line 265 of file CMatrixFixedNumeric.h.

Referenced by mrpt::math::CMatrixFixedNumeric< float, 4, 4 >::add_AAt(), mrpt::math::CMatrixFixedNumeric< float, 4, 4 >::CMatrixFixedNumeric(), mrpt::math::covariancesAndMean(), mrpt::math::detMatrix(), mrpt::random::CRandomGenerator::drawGaussianMultivariate(), mrpt::random::CRandomGenerator::drawGaussianMultivariateMany(), mrpt::math::eigenVectorsMatrix(), mrpt::math::CMatrixFixedNumeric< float, 4, 4 >::force_symmetry(), mrpt::poses::CPoint3D::getHomogeneousMatrix(), mrpt::poses::CPoint2D::getHomogeneousMatrix(), mrpt::math::CMatrixFixedNumeric< float, 4, 4 >::inMatlabFormat(), mrpt::math::detail::VicinityTraits< CMatrixFixedNumeric< T, D, D > >::insertInContainer(), mrpt::math::invMatrix_destroySrc(), mrpt::math::CMatrixFixedNumeric< float, 4, 4 >::loadFromTextFile(), mrpt::math::multiply(), mrpt::math::multiply_AAt(), mrpt::math::multiply_Ab(), mrpt::math::CMatrixFixedNumeric< float, 4, 4 >::multiply_ABC(), mrpt::math::CMatrixFixedNumeric< float, 4, 4 >::multiply_ABCt(), mrpt::math::multiply_HCHt(), mrpt::math::multiply_HCHt_scalar(), mrpt::math::multiply_HtCH(), mrpt::math::CMatrixFixedNumeric< float, 4, 4 >::operator=(), mrpt::math::operator==(), mrpt::math::operator~(), mrpt::math::CMatrixFixedNumeric< float, 4, 4 >::pivot(), mrpt::math::CQuaternion< T >::q_normJac(), mrpt::math::CQuaternion< T >::q_rotation_matrix(), and mrpt::bayes::CKalmanFilterCapable< 6, 3, 3, 6 >::runOneKalmanIteration().

template<typename T, size_t NROWS, size_t NCOLS>
static size_t mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::getColCount (  )  [inline, static]

Get number of columns.

Definition at line 209 of file CMatrixFixedNumeric.h.

template<typename T, size_t NROWS, size_t NCOLS>
static size_t mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::getRowCount (  )  [inline, static]

Get number of rows.

Definition at line 206 of file CMatrixFixedNumeric.h.

template<typename T, size_t NROWS, size_t NCOLS>
template<size_t N, typename ReturnType >
ReturnType mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::getVicinity ( size_t  c,
size_t  r 
) const [inline]

Definition at line 805 of file CMatrixFixedNumeric.h.

template<typename T, size_t NROWS, size_t NCOLS>
std::string mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::inMatlabFormat (  )  const [inline]

Gets the matrix as a string in matlab format, for example: [a11 a12 a12;a21 a22 a23].

See also:
fromMatlabStringFormat

Definition at line 316 of file CMatrixFixedNumeric.h.

template<typename T, size_t NROWS, size_t NCOLS>
void mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::inv ( CMatrixFixedNumeric< T, NROWS, NCOLS > &  out_inv  )  const [inline]

Returns the inverse of the matrix in "out_inv".

See also:
inv_fast

Definition at line 355 of file CMatrixFixedNumeric.h.

Referenced by mrpt::math::normalPDF(), and mrpt::math::operator!().

template<typename T, size_t NROWS, size_t NCOLS>
void mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::inv_fast ( CMatrixFixedNumeric< T, NROWS, NCOLS > &  out_inv  )  [inline]

Returns the inverse of the matrix in "out_inv" , DESTROYING the current matrix.

Definition at line 361 of file CMatrixFixedNumeric.h.

template<typename T, size_t NROWS, size_t NCOLS>
static bool mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::IsSquare (  )  [inline, static]

Is square?

Definition at line 212 of file CMatrixFixedNumeric.h.

template<typename T, size_t NROWS, size_t NCOLS>
void mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::loadFromTextFile ( const std::string &  file  )  [inline]

Load matrix from a text file, compatible with MATLAB text format.

Lines starting with '' or '#' are interpreted as comments and ignored.

See also:
saveToTextFile, fromMatlabStringFormat

Definition at line 613 of file CMatrixFixedNumeric.h.

template<typename T, size_t NROWS, size_t NCOLS>
T mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::maximum (  )  const [inline]

Returns the maximum of all the elements.

See also:
minimumAndmaximum

Definition at line 545 of file CMatrixFixedNumeric.h.

template<typename T, size_t NROWS, size_t NCOLS>
T mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::minimum (  )  const [inline]

Returns the minimum of all the elements.

See also:
minimumAndmaximum

Definition at line 536 of file CMatrixFixedNumeric.h.

template<typename T, size_t NROWS, size_t NCOLS>
void mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::minimumAndMaximum ( T &  val_min,
T &  val_max 
) const [inline]

Returns the minimum & maximum of all the elements.

Definition at line 554 of file CMatrixFixedNumeric.h.

template<typename T, size_t NROWS, size_t NCOLS>
template<size_t NC1>
void mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::multiply ( const CMatrixFixedNumeric< T, NROWS, NC1 > &  A,
const CMatrixFixedNumeric< T, NC1, NCOLS > &  B 
) [inline]
template<typename T, size_t NROWS, size_t NCOLS>
template<size_t NC1>
void mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::multiply_AAt ( const CMatrixFixedNumeric< T, NROWS, NC1 > &  A  )  [inline]

this = A * A^t

Definition at line 377 of file CMatrixFixedNumeric.h.

Referenced by mrpt::math::CMatrixFixedNumeric< float, 4, 4 >::multiply_AAt().

template<typename T, size_t NROWS, size_t NCOLS>
void mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::multiply_Ab ( const std::vector< T > &  a,
std::vector< T > &  out_v 
) const [inline]

Computes the vector v = this * a, where "a" is a column vector of the appropriate length.

Definition at line 383 of file CMatrixFixedNumeric.h.

Referenced by mrpt::math::CMatrixFixedNumeric< float, 4, 4 >::multiply_Ab().

template<typename T, size_t NROWS, size_t NCOLS>
template<size_t N1, size_t N2>
void mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::multiply_ABC ( const CMatrixFixedNumeric< T, NROWS, N1 > &  A,
const CMatrixFixedNumeric< T, N1, N2 > &  B,
const CMatrixFixedNumeric< T, N2, NCOLS > &  C 
) [inline]

Calculate the operation this = A*B*C.

See also:
multiply_ABCT

Definition at line 391 of file CMatrixFixedNumeric.h.

template<typename T, size_t NROWS, size_t NCOLS>
template<size_t N1, size_t N2>
void mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::multiply_ABCt ( const CMatrixFixedNumeric< T, NROWS, N1 > &  A,
const CMatrixFixedNumeric< T, N1, N2 > &  B,
const CMatrixFixedNumeric< T, NCOLS, N2 > &  C 
) [inline]

Calculate the operation this = A*B*Ct.

See also:
multiply_ABC

Definition at line 412 of file CMatrixFixedNumeric.h.

template<typename T, size_t NROWS, size_t NCOLS>
void mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::multiply_HCHt ( const CMatrixFixedNumeric< T, NCOLS, NCOLS > &  C,
CMatrixFixedNumeric< T, NROWS, NROWS > &  R,
bool  accumResultInOutput = false 
) const [inline]

This executes the operation $ \mathbf{R} = \mathbf{H} \mathbf{C} \mathbf{H}^t $, where 'this' matrix is $ \mathbf{H} $ and $ \mathbf{C} $ is symmetric, in an efficient and numerically stable way.

If 'this' matrix is $ N \times M $, then $ \mathbf{C} $ must be $ M \times M $, and the result matrix $ R $ will be $ N \times N $. The result from this method is assured to be symmetric (if $ \mathbf{C} $ is symmetric), whereas executing:

                                 R = H * C * (~H);

may lead to non-symmetric matrixes due to numerical rounding errors. In addition, this method is more efficient that the code above (see the MRPT's code examples on matrixes).

If accumResultInOutput=true, the contents of the output matrix will not be cleared, but added to the result of the operations. In this case it must have the correct size before calling or an exception will be raised since this probably is a bug.

See also:
multiply_HCHt_scalar

Definition at line 692 of file CMatrixFixedNumeric.h.

Referenced by mrpt::math::CMatrixFixedNumeric< float, 4, 4 >::multiply_HCHt(), and mrpt::math::CMatrixFixedNumeric< float, 4, 4 >::multiply_HCHt_scalar().

template<typename T, size_t NROWS, size_t NCOLS>
T mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::multiply_HCHt_scalar ( const CMatrixFixedNumeric< T, NCOLS, NCOLS > &  C  )  const [inline]

Like multiply_HCHt but for resulting matrices of size 1x1, which is returned as a scalar.

Definition at line 714 of file CMatrixFixedNumeric.h.

template<typename T, size_t NROWS, size_t NCOLS>
void mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::multiply_HtCH ( const CMatrixFixedNumeric< T, NROWS, NROWS > &  C,
CMatrixFixedNumeric< T, NCOLS, NCOLS > &  R,
bool  accumResultInOutput = false 
) const [inline]
template<typename T, size_t NROWS, size_t NCOLS>
T mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::multiply_HtCH_scalar ( const CMatrixFixedNumeric< T, NROWS, NROWS > &  C  )  const [inline]

Like multiply_HtCH but for resulting matrices of size 1x1, which is returned as a scalar.

Definition at line 732 of file CMatrixFixedNumeric.h.

template<typename T, size_t NROWS, size_t NCOLS>
void mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::multiplyColumnByScalar ( size_t  c,
scalar 
) [inline]

Definition at line 700 of file CMatrixFixedNumeric.h.

template<typename T, size_t NROWS, size_t NCOLS>
T mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::operator() ( const size_t  row,
const size_t  col 
) const [inline]

Subscript operator to get/set individual elements.

Definition at line 304 of file CMatrixFixedNumeric.h.

template<typename T, size_t NROWS, size_t NCOLS>
T& mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::operator() ( const size_t  row,
const size_t  col 
) [inline]

Subscript operator to get/set individual elements.

Definition at line 293 of file CMatrixFixedNumeric.h.

template<typename T, size_t NROWS, size_t NCOLS>
void mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::operator*= ( const T  val  )  [inline]

Multiplies all elements by a scalar.

Definition at line 475 of file CMatrixFixedNumeric.h.

template<typename T, size_t NROWS, size_t NCOLS>
void mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::operator+= ( const CMatrixFixedNumeric< T, NROWS, NCOLS > &  m  )  [inline]

Sum a matrix to this one.

Definition at line 509 of file CMatrixFixedNumeric.h.

template<typename T, size_t NROWS, size_t NCOLS>
void mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::operator+= ( const T  val  )  [inline]

Sum a scalar to all elements.

Definition at line 492 of file CMatrixFixedNumeric.h.

template<typename T, size_t NROWS, size_t NCOLS>
void mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::operator-= ( const CMatrixFixedNumeric< T, NROWS, NCOLS > &  m  )  [inline]

Substract a matrix to this one.

Definition at line 517 of file CMatrixFixedNumeric.h.

template<typename T, size_t NROWS, size_t NCOLS>
void mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::operator-= ( const T  val  )  [inline]

Substract a scalar to all elements.

Definition at line 500 of file CMatrixFixedNumeric.h.

template<typename T, size_t NROWS, size_t NCOLS>
void mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::operator/= ( const T  val  )  [inline]

Multiplies all elements by a scalar.

Definition at line 483 of file CMatrixFixedNumeric.h.

template<typename T, size_t NROWS, size_t NCOLS>
CMatrixFixedNumeric<T,NROWS,NCOLS>& mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::operator= ( const CPose3D p  )  [inline]

Assigns a pose to a 6x1 or 1x6 matrix.

Definition at line 242 of file CMatrixFixedNumeric.h.

template<typename T, size_t NROWS, size_t NCOLS>
CMatrixFixedNumeric<T,NROWS,NCOLS>& mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::operator= ( const CPose2D p  )  [inline]

Assigns a pose to a 3x1 or 1x3 matrix.

Definition at line 238 of file CMatrixFixedNumeric.h.

template<typename T, size_t NROWS, size_t NCOLS>
CMatrixFixedNumeric<T,NROWS,NCOLS>& mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::operator= ( const CPoint3D p  )  [inline]

Assigns a pose to a 3x1 or 1x3 matrix.

Definition at line 234 of file CMatrixFixedNumeric.h.

template<typename T, size_t NROWS, size_t NCOLS>
CMatrixFixedNumeric<T,NROWS,NCOLS>& mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::operator= ( const CPoint2D p  )  [inline]

Assigns a pose to a 2x1 or 1x2 matrix.

Definition at line 230 of file CMatrixFixedNumeric.h.

template<typename T, size_t NROWS, size_t NCOLS>
template<typename R >
CMatrixFixedNumeric<T,NROWS,NCOLS>& mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::operator= ( const CMatrixTemplate< R > &  B  )  [inline]

Conversion from a dynamic-size matrix of a different data type to a fixed-size one.

Exceptions:
std::exception On wrong sizes

Definition at line 195 of file CMatrixFixedNumeric.h.

template<typename T, size_t NROWS, size_t NCOLS>
CMatrixFixedNumeric<T,NROWS,NCOLS>& mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::operator= ( const CMatrixTemplate< T > &  B  )  [inline]

Conversion from a dynamic-size matrix to a fixed-size one.

Exceptions:
std::exception On wrong sizes

Definition at line 182 of file CMatrixFixedNumeric.h.

template<typename T, size_t NROWS, size_t NCOLS>
int mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::pivot ( const size_t  row  )  [inline]

Used for "det".

Definition at line 741 of file CMatrixFixedNumeric.h.

Referenced by mrpt::math::detMatrix(), and mrpt::math::invMatrix_destroySrc().

template<typename T, size_t NROWS, size_t NCOLS>
void mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::saveToTextFile ( const std::string &  file,
TMatrixTextFileFormat  fileFormat = MATRIX_FORMAT_ENG,
bool  appendMRPTHeader = false,
const std::string &  userHeader = std::string("") 
) const [inline]

Save matrix to a text file, compatible with MATLAB text format.

Parameters:
file The target filename.
fileFormat See TMatrixTextFileFormat. The format of the numbers in the text file.
appendMRPTHeader Insert this header to the file "% File generated by MRPT. Load with MATLAB with: VAR=load(FILENAME);"
userHeader Additional text to be written at the head of the file. Typically MALAB comments "% This file blah blah". Final end-of-line is not needed.
See also:
loadFromTextFile, inMatlabFormat, DEBUG_SAVE_MATRIX

Definition at line 599 of file CMatrixFixedNumeric.h.

template<typename T, size_t NROWS, size_t NCOLS>
void mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::set_unsafe ( const size_t  row,
const size_t  col,
const T  val 
) [inline]

Sets an element (Use with caution, bounds are not checked!).

Definition at line 283 of file CMatrixFixedNumeric.h.

template<typename T, size_t NROWS, size_t NCOLS>
static void mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::setSize ( const size_t  nRows,
const size_t  nCols 
) [inline, static]

This method has no effects in this class.

Definition at line 215 of file CMatrixFixedNumeric.h.

template<typename T, size_t NROWS, size_t NCOLS>
void mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::Sqrt (  )  [inline]

Applies the sqrt to all the elements.

Definition at line 568 of file CMatrixFixedNumeric.h.

template<typename T, size_t NROWS, size_t NCOLS>
void mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::substract ( const CMatrixFixedNumeric< T, NROWS, NCOLS > &  A  )  [inline]

Substract A from this matrix: this = this - A.

Definition at line 454 of file CMatrixFixedNumeric.h.

template<typename T, size_t NROWS, size_t NCOLS>
void mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::substract_Ac ( const CMatrixFixedNumeric< T, NROWS, NCOLS > &  A,
const T  c 
) [inline]

Substract A times a scalar from this matrix: this = this - A*c.

Definition at line 468 of file CMatrixFixedNumeric.h.

template<typename T, size_t NROWS, size_t NCOLS>
T mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::sumAll (  )  const [inline]

Returns the sum of all the elements.

Definition at line 527 of file CMatrixFixedNumeric.h.

template<typename T, size_t NROWS, size_t NCOLS>
void mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::swap_cols ( size_t  i1,
size_t  i2 
) [inline]

Definition at line 774 of file CMatrixFixedNumeric.h.

template<typename T, size_t NROWS, size_t NCOLS>
void mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::swap_rows ( size_t  i1,
size_t  i2 
) [inline]
template<typename T, size_t NROWS, size_t NCOLS>
void mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::unit (  )  [inline]
template<typename T, size_t NROWS, size_t NCOLS>
void mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::zeros ( size_t  N,
size_t  M 
) [inline]

Set all elements to zero.

Definition at line 259 of file CMatrixFixedNumeric.h.

template<typename T, size_t NROWS, size_t NCOLS>
void mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::zeros (  )  [inline]

Member Data Documentation

template<typename T, size_t NROWS, size_t NCOLS>
CArray<T,NROWS*NCOLS> mrpt::math::CMatrixFixedNumeric< T, NROWS, NCOLS >::m_Val

The stored data of the matrix: elements are saved by rows, left to right, from top to bottom.

Definition at line 99 of file CMatrixFixedNumeric.h.

Referenced by mrpt::math::CMatrixFixedNumeric< float, 4, 4 >::_E(), mrpt::math::CMatrixFixedNumeric< float, 4, 4 >::add(), mrpt::math::CMatrixFixedNumeric< float, 4, 4 >::add_Ac(), mrpt::math::CMatrixFixedNumeric< float, 4, 4 >::CMatrixFixedNumeric(), mrpt::math::detMatrix(), mrpt::math::CMatrixFixedNumeric< float, 4, 4 >::get_unsafe(), mrpt::math::invMatrix(), mrpt::math::maximumMatrix(), mrpt::math::minimumAndMaximumMatrix(), mrpt::math::minimumMatrix(), mrpt::math::multiply(), mrpt::math::CMatrixFixedNumeric< float, 4, 4 >::multiply_HCHt_scalar(), mrpt::math::CMatrixFixedNumeric< float, 4, 4 >::multiply_HtCH_scalar(), mrpt::math::CMatrixFixedNumeric< float, 4, 4 >::multiplyColumnByScalar(), mrpt::math::CMatrixFixedNumeric< float, 4, 4 >::operator()(), mrpt::math::operator-(), mrpt::math::CMatrixFixedNumeric< float, 4, 4 >::operator=(), mrpt::math::CMatrixFixedNumeric< float, 4, 4 >::set_unsafe(), mrpt::math::sqrtMatrix(), mrpt::math::CMatrixFixedNumeric< float, 4, 4 >::substract(), mrpt::math::CMatrixFixedNumeric< float, 4, 4 >::substract_Ac(), mrpt::math::substractInPlace(), mrpt::math::sumInPlace(), mrpt::math::sumMatrixAllElements(), mrpt::math::CMatrixFixedNumeric< float, 4, 4 >::swap_cols(), mrpt::math::CMatrixFixedNumeric< float, 4, 4 >::swap_rows(), mrpt::math::CMatrixFixedNumeric< float, 4, 4 >::unit(), and mrpt::math::CMatrixFixedNumeric< float, 4, 4 >::zeros().




Page generated by Doxygen 1.6.2 for MRPT 0.8.1 SVN:exported at Mon Feb 15 22:01:07 UTC 2010