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>

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!).
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.
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.
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 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.
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)
_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)

Static Public Member Functions

static size_t getRowCount ()
 Get number of rows.
static size_t getColCount ()
 Get number of columns.

Public Attributes

m_Val [NROWS *NCOLS]
 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 83 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 86 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 96 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!).

Definition at line 105 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 117 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 131 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 143 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 154 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 206 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 208 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 210 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 212 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 663 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 659 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 414 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 399 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 428 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 530 of file CMatrixFixedNumeric.h.

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

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 545 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 550 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 309 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 249 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]

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 201 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 197 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 283 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 322 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 328 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 512 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 503 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 521 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 344 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 350 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 358 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 379 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 591 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 600 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 618 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 271 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 260 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 442 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 476 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 459 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 484 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 467 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 450 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 227 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 223 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 219 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 215 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 186 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 173 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 627 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, CMatrixTemplate::inMatlabFormat, DEBUG_SAVE_MATRIX

Definition at line 566 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 254 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 535 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 421 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 435 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 494 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 (  )  [inline]


Member Data Documentation

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

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

Definition at line 92 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::extractFixMatrixFromDynMatrix(), mrpt::math::fixedToDynMatrix(), mrpt::math::CMatrixFixedNumeric< float, 4, 4 >::get_unsafe(), mrpt::math::insertMatrixFixIntoDyn(), 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 >::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_rows(), mrpt::math::CMatrixFixedNumeric< float, 4, 4 >::unit(), and mrpt::math::CMatrixFixedNumeric< float, 4, 4 >::zeros().




Page generated by Doxygen 1.5.7.1 for MRPT 0.7.1 SVN: at Mon Aug 17 22:58:25 EDT 2009