#include <mrpt/math/CMatrixTemplateNumeric.h>
Public Member Functions | |
template<class R > | |
CMatrixTemplateNumeric (const CMatrixTemplate< R > &m) | |
Copy constructor from a matrix of any type. | |
CMatrixTemplateNumeric () | |
Default constructor, builds a 1x1 matrix. | |
CMatrixTemplateNumeric (size_t row, size_t col) | |
Constructor. | |
CMatrixTemplateNumeric (const CMatrixTemplate< T > &m, const size_t cropRowCount, const size_t cropColCount) | |
Copy & crop constructor, which copies the given matrix but only up to the given size. | |
template<typename V , size_t N> | |
CMatrixTemplateNumeric (size_t row, size_t col, V(&theArray)[N]) | |
Constructor from a given size and a C array. | |
template<typename V > | |
CMatrixTemplateNumeric (size_t row, size_t col, const V &theVector) | |
Constructor from a given size and a STL container (std::vector, std::list,. | |
virtual | ~CMatrixTemplateNumeric () |
Destructor. | |
CMatrixTemplateNumeric (const mrpt::poses::CPose2D &p) | |
Constructor from a mrpt::poses::CPose2D, which generates a 3x1 matrix ![]() | |
CMatrixTemplateNumeric (const mrpt::poses::CPose3D &p) | |
Constructor from a mrpt::poses::CPose6D, which generates a 6x1 matrix ![]() | |
CMatrixTemplateNumeric (const mrpt::poses::CPoint2D &p) | |
Constructor from a mrpt::poses::CPoint2D, which generates a 2x1 matrix ![]() | |
CMatrixTemplateNumeric (const mrpt::poses::CPoint3D &p) | |
Constructor from a mrpt::poses::CPoint3D, which generates a 3x1 matrix ![]() | |
template<size_t NROWS, size_t NCOLS> | |
CMatrixTemplateNumeric (const CMatrixFixedNumeric< T, NROWS, NCOLS > &M) | |
Copy constructor from a fixed-size matrix. | |
template<size_t NROWS, size_t NCOLS> | |
CMatrixTemplateNumeric & | operator= (const CMatrixFixedNumeric< T, NROWS, NCOLS > &M) |
Copy operator from a fixed-size matrix. | |
template<class R > | |
CMatrixTemplateNumeric< T > & | operator= (const CMatrixTemplateNumeric< R > &m) |
Assignment operator of other types. | |
template<typename V , size_t N> | |
CMatrixTemplateNumeric & | operator= (V(&theArray)[N]) |
Assignment operator for initializing from a C array (The matrix must be set to the correct size before invoking this asignament). | |
CMatrixTemplateNumeric< T > & | operator= (const CMatrixTemplateNumeric< T > &m) |
Assignment operator for the same type. | |
void | setSize (size_t row, size_t col) |
Changes the size of matrix, maintaining its previous content as possible and padding with zeros where applicable. | |
void | resize (size_t row, size_t col) |
Changes the size of matrix, maintaining its previous content as possible and padding with zeros where applicable. | |
void | laplacian (CMatrixTemplateNumeric< T > &ret) const |
Computes the laplacian of the matrix, useful for graph matrixes. | |
void | svd (CMatrixTemplateNumeric< T > &U, std::vector< T > &W, CMatrixTemplateNumeric< T > &V) const |
Computes the SVD (Singular Value Decomposition) of the matrix. | |
void | eigenVectors (CMatrixTemplateNumeric< T > &Z, CMatrixTemplateNumeric< T > &D) const |
Computes the eigenvalues/eigenvector decomposition of a symmetric matrix. | |
CMatrixTemplateNumeric< T > | largestEigenvector (T resolution=0.01f, size_t maxIterations=6, int *out_Iterations=NULL, float *out_estimatedResolution=NULL) const |
Efficiently computes only the biggest eigenvector of the matrix using the Power Method, and returns it as a column vector. | |
CMatrixTemplateNumeric< T > & | Sqrt () |
Computes the sqrt of each element in the matrix, replacing current values;. | |
CMatrixTemplateNumeric< T > & | Abs () |
Computes the absolute value of each element in the matrix, replacing current values. | |
CMatrixTemplateNumeric< T > & | Square () |
Computes the square of each element in the matrix, replacing current values. | |
template<class F > | |
CMatrixTemplateNumeric< T > & | applyToAllElements (F function) |
Applies a generic operation to all the elements of the matrix. | |
CMatrixTemplateNumeric< T > | operator+ () |
Unary operator. | |
CMatrixTemplateNumeric< T > | operator- () |
Unary operator. | |
CMatrixTemplateNumeric< T > & | operator+= (const CMatrixTemplateNumeric< T > &m) |
combined addition and assignment operator | |
CMatrixTemplateNumeric< T > & | add_At (const CMatrixTemplateNumeric< T > &m) |
Add to this matrix the transpose of A. | |
CMatrixTemplateNumeric< T > & | add_AAt (const CMatrixTemplateNumeric< T > &m) |
Add to this matrix A and its transpose (this = this + A + At). | |
CMatrixTemplateNumeric< T > & | add_Ac (const CMatrixTemplateNumeric< T > &m, const T c) |
Add A times a scalar c to this matrix: this = this + A * c. | |
CMatrixTemplateNumeric< T > & | operator-= (const CMatrixTemplateNumeric< T > &m) |
combined subtraction and assignment operator | |
CMatrixTemplateNumeric< T > & | substract_Ac (const CMatrixTemplateNumeric< T > &m, const T c) |
Substract A times a scalar c to this matrix: this = this - A * c. | |
CMatrixTemplateNumeric< T > & | operator*= (const T &c) |
combined scalar multiplication and assignment operator | |
CMatrixTemplateNumeric< T > & | operator*= (const CMatrixTemplateNumeric< T > &m) |
combined matrix multiplication and assignment operator | |
void | multiply (const CMatrixTemplateNumeric< T > &m1, const CMatrixTemplateNumeric< T > &m2) |
Multiply 2 matrices and save the result in "this" object. | |
void | multiply (const CMatrixTemplateNumeric< T > &m1, const CVectorTemplate< T > &m2) |
Multiply one matrix by a column vector and save the result in "this" object. | |
void | multiply_ABt (const CMatrixTemplateNumeric< T > &m1, const CMatrixTemplateNumeric< T > &m2) |
Makes this = M1 * M2^T. | |
void | multiply_AAt (const CMatrixTemplateNumeric< T > &m1) |
Makes this = M1 * M1^T, taking into account that the result is symmetric and only half the computations must be done. | |
void | multiply_AtA (const CMatrixTemplateNumeric< T > &m1) |
Makes this = M1^T * M1, taking into account that the result is symmetric and only half the computations must be done. | |
void | multiply_Ab (const std::vector< T > &a, std::vector< T > &out_v) |
Computes the vector v = this * a, where "a" is a column vector of the appropriate length. | |
void | multiply_Atb (const std::vector< T > &a, std::vector< T > &out_v) |
Computes the vector v = this^T * a, where "a" is a column vector of the appropriate length. | |
void | multiply_result_is_symmetric (const CMatrixTemplateNumeric< T > &m1, const CMatrixTemplateNumeric< T > &m2) |
Multiply 2 matrices and save the result in "this" object, for the cases in which we know in advance that the result will be a symmetrical matrix (DO NOT USE OTHERWISE!!). | |
void | multiplySubMatrix (const CMatrixTemplateNumeric< T > &A, CMatrixTemplateNumeric< T > &outResult, const size_t &A_cols_offset, const size_t &A_rows_offset, const size_t &A_col_count) |
Matrix multiplication of this matrix with a submatrix of 'A', saving the result in a third matrix. | |
CMatrixTemplateNumeric< T > & | operator/= (const CMatrixTemplateNumeric< T > &m) |
Dot division by another matrix (element by element division). | |
CMatrixTemplateNumeric< T > & | operator/= (const T &c) |
combined scalar division and assignment operator | |
CMatrixTemplateNumeric< T > & | operator+= (const T &c) |
Combined scalar addition and assignment operator. | |
CMatrixTemplateNumeric< T > & | operator-= (const T &c) |
Combined scalar substraction and assignment operator. | |
CMatrixTemplateNumeric< T > & | operator^= (const unsigned int &pow) |
combined power and assignment operator | |
void | scalarPow (T s) |
Scalar power of all elements to a given power, this is diferent of ^ operator. | |
void | zeros (const size_t &row, const size_t &col) |
Set all elements to zero. | |
void | zeros () |
Set all elements to zero. | |
void | ones (const size_t &row, const size_t &col) |
Set all elements to one. | |
void | ones () |
Set all elements to one. | |
void | unit (const size_t &row) |
Build an unit matrix. | |
void | unit () |
Build an unit matrix. | |
CMatrixTemplateNumeric< T > | solve (const CMatrixTemplateNumeric< T > &v) |
Solve the matrix as linear equations system. | |
CMatrixTemplateNumeric< T > | adj () const |
Computes the adjunt of matrix. | |
void | inv (CMatrixTemplateNumeric< T > &out_inv) const |
Computes the Inverse of matrix. | |
CMatrixTemplateNumeric< T > | inv () const |
Computes the Inverse of matrix. | |
void | inv_fast (CMatrixTemplateNumeric< T > &out_inv) |
Computes the Inverse of matrix, DESTROYING the current matrix and returning the inverse in an user-supplied matrix. | |
void | pseudoInverse (CMatrixTemplateNumeric< T > &out) const |
Compute the pseudo-inverse of this matrix M, given by ![]() | |
CMatrixTemplateNumeric< T > | pseudoInverse () const |
Compute the pseudo-inverse of this matrix M, given by ![]() | |
T | det () const |
Computes the determinant of matrix. | |
size_t | rank (T eps=0.0) const |
Computes the rank of the matrix using a slight variation of Gauss method. | |
T | norm () const |
Computes the norm of matrix. | |
T | cofact (size_t row, size_t col) const |
Computes the cofact. | |
T | cond () |
Computes the cond. | |
bool | isSingular () const |
Checks for matrix type. | |
bool | isDiagonal () const |
Checks for matrix type. | |
bool | isScalar () const |
Checks for matrix type. | |
bool | isUnit () const |
Checks for matrix type. | |
bool | isNull () const |
Checks for matrix type. | |
bool | isSymmetric () const |
Checks for matrix type. | |
bool | isSkewSymmetric () const |
Checks for matrix type. | |
bool | isUpperTriangular () const |
Checks for matrix type. | |
bool | isLowerTriangular () const |
Checks for matrix type. | |
void | matrix_floor () |
Round towards minus infinity modifying the matrix (by AJOGD @ JAN-2007). | |
void | matrix_floor (CMatrixTemplateNumeric< T > &out) |
Round towards minus infinity (by AJOGD @ JAN-2007). | |
void | matrix_ceil () |
Round towards plus infinity (by AJOGD @ JAN-2007). | |
void | find_index_max_value (size_t &umax, size_t &vmax, T &max_val) const |
Finds the maximum value in the matrix, and returns its position. | |
T | maximumDiagonal () const |
Finds the maximum value in the diagonal of the matrix. | |
T | maximum () const |
Finds the maximum value in the matrix. | |
T | minimum () const |
Finds the minimum value in the matrix. | |
void | find_index_min_value (size_t &umin, size_t &vmin, T &min_val) const |
Finds the minimum value in the matrix, and returns its position. | |
void | force_symmetry () |
Force symmetry in the matrix (by AJOGD @ JAN-2007). | |
void | mean (std::vector< T > &outMeanVector) const |
Computes a row with the mean values of each column in the matrix. | |
void | meanAndStd (std::vector< T > &outMeanVector, std::vector< T > &outStdVector) const |
Computes a row with the mean values of each column in the matrix and the associated vector with the standard deviation of each column. | |
void | meanAndStdAll (T &outMean, T &outStd) const |
Computes the mean and standard deviation of all the elements in the matrix as a whole. | |
void | asCol (CMatrixTemplateNumeric< T > &aux) const |
void | asRow (CMatrixTemplateNumeric< T > &aux) const |
void | findElementsPassingMahalanobisThreshold (double stdTimes, std::vector< size_t > &rowIndexes, std::vector< size_t > &colIndexes, bool below=false) const |
Finds elements whose values are a given number of times above (or below) the mean, in 1D Mahalanobis distance. | |
void | normalize (T minVal=0, T maxVal=1) |
Adjusts the range of elements in the matrix such as the minimum and maximum values being those supplied by the user. | |
void | adjustRange (T minVal=0, T maxVal=1) |
Adjusts the range of elements in the matrix such as the minimum and maximum values being those supplied by the user. | |
T | sumAll () const |
Returns the sum of all the elements in the matrix. | |
T | sum (size_t firstRow=0, size_t firstCol=0, size_t lastRow=std::numeric_limits< size_t >::max(), size_t lastCol=std::numeric_limits< size_t >::max()) const |
Returns the sum of a given part of the matrix. | |
void | multiplyByMatrixAndByTransposeNonSymmetric (const CMatrixTemplateNumeric< T > &C, CMatrixTemplateNumeric< T > &R, bool accumOnOutput=false, bool substractInsteadOfSum=false) const |
Computes: R = H * C * H^t , where H is this matrix. | |
void | multiply_ABC (const CMatrixTemplateNumeric< T > &A, const CMatrixTemplateNumeric< T > &B, const CMatrixTemplateNumeric< T > &C) |
Calculate the operation S = ABC where S is this object. | |
void | multiply_ABCt (const CMatrixTemplateNumeric< T > &A, const CMatrixTemplateNumeric< T > &B, const CMatrixTemplateNumeric< T > &C) |
Calculate the operation S = ABCt where S is this object. | |
void | multiply_HCHt (const CMatrixTemplateNumeric< T > &C, CMatrixTemplateNumeric< T > &R, bool allowSubMatrixMultiplication=false, size_t subMatrixOffset=0, bool accumResultInOutput=false) const |
This executes the operation ![]() ![]() ![]() | |
T | multiply_HCHt_scalar (const CMatrixTemplateNumeric< T > &C) const |
An special case of multiply_HCHt for the case of the resulting matrix being a scalar (that is, a 1x1 matrix) - This method directly returns this as a scalar avoiding the construction of a 1x1 matrix. | |
Private Member Functions | |
int | pivot (size_t row) |
Internal use. |
The template can be instanced for data types: float, double, long double
The following operators have been implemented:
Implemented Operators | |
x=M(i,j) M(i,j)=x | This () operator is used to access/change the element at i'th row, j'th column. First index is 0. |
!M | The matrix inverse M-1 |
~M | The matrix transpose MT |
(M^n) | Power of a matrix: (M*M*M*...M) n times. Use parenthesis with this operator. Use "scalarPow" for the power of individual elements in the matrix. |
M1 = M2 | Assignment operator: Copy matrix M2 to M1 |
M1 == M2 M1 != M2 | Logical comparison: Returns true or false if all elements are identical. |
x * M | Scalar multiplication |
M1 * M2 | Matrix multiplication, with the usual mathematical meaning |
M1 + M2 M1 M2 | Matrixes addition and substraction. |
M / x | Scalar division |
M1 / M2 | Equivalent to (M1 * M2-1) |
stream << M; | Write to a binary CStream, since this class is CSerializable |
stream >> M; | Read from a binary CStream, since this class is CSerializable |
Definition at line 112 of file CMatrixTemplateNumeric.h.
mrpt::math::CMatrixTemplateNumeric< T >::CMatrixTemplateNumeric | ( | const CMatrixTemplate< R > & | m | ) | [inline] |
Copy constructor from a matrix of any type.
Definition at line 118 of file CMatrixTemplateNumeric.h.
mrpt::math::CMatrixTemplateNumeric< T >::CMatrixTemplateNumeric | ( | ) |
Default constructor, builds a 1x1 matrix.
mrpt::math::CMatrixTemplateNumeric< T >::CMatrixTemplateNumeric | ( | size_t | row, | |
size_t | col | |||
) |
Constructor.
mrpt::math::CMatrixTemplateNumeric< T >::CMatrixTemplateNumeric | ( | const CMatrixTemplate< T > & | m, | |
const size_t | cropRowCount, | |||
const size_t | cropColCount | |||
) | [inline] |
Copy & crop constructor, which copies the given matrix but only up to the given size.
Definition at line 134 of file CMatrixTemplateNumeric.h.
mrpt::math::CMatrixTemplateNumeric< T >::CMatrixTemplateNumeric | ( | size_t | row, | |
size_t | col, | |||
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 }; CMatrixDouble M(3,2, numbers);
Definition at line 146 of file CMatrixTemplateNumeric.h.
mrpt::math::CMatrixTemplateNumeric< T >::CMatrixTemplateNumeric | ( | size_t | row, | |
size_t | col, | |||
const V & | theVector | |||
) | [inline] |
Constructor from a given size and a STL container (std::vector, std::list,.
..) with the initial values. The vector length must match cols x row.
Definition at line 152 of file CMatrixTemplateNumeric.h.
virtual mrpt::math::CMatrixTemplateNumeric< T >::~CMatrixTemplateNumeric | ( | ) | [inline, virtual] |
mrpt::math::CMatrixTemplateNumeric< T >::CMatrixTemplateNumeric | ( | const mrpt::poses::CPose2D & | p | ) | [explicit] |
Constructor from a mrpt::poses::CPose2D, which generates a 3x1 matrix .
mrpt::math::CMatrixTemplateNumeric< T >::CMatrixTemplateNumeric | ( | const mrpt::poses::CPose3D & | p | ) | [explicit] |
Constructor from a mrpt::poses::CPose6D, which generates a 6x1 matrix .
mrpt::math::CMatrixTemplateNumeric< T >::CMatrixTemplateNumeric | ( | const mrpt::poses::CPoint2D & | p | ) | [explicit] |
Constructor from a mrpt::poses::CPoint2D, which generates a 2x1 matrix .
mrpt::math::CMatrixTemplateNumeric< T >::CMatrixTemplateNumeric | ( | const mrpt::poses::CPoint3D & | p | ) | [explicit] |
Constructor from a mrpt::poses::CPoint3D, which generates a 3x1 matrix .
mrpt::math::CMatrixTemplateNumeric< T >::CMatrixTemplateNumeric | ( | const CMatrixFixedNumeric< T, NROWS, NCOLS > & | M | ) | [inline, explicit] |
Copy constructor from a fixed-size matrix.
Definition at line 180 of file CMatrixTemplateNumeric.h.
CMatrixTemplateNumeric<T>& mrpt::math::CMatrixTemplateNumeric< T >::Abs | ( | ) |
Computes the absolute value of each element in the matrix, replacing current values.
CMatrixTemplateNumeric<T>& mrpt::math::CMatrixTemplateNumeric< T >::add_AAt | ( | const CMatrixTemplateNumeric< T > & | m | ) |
Add to this matrix A and its transpose (this = this + A + At).
CMatrixTemplateNumeric<T>& mrpt::math::CMatrixTemplateNumeric< T >::add_Ac | ( | const CMatrixTemplateNumeric< T > & | m, | |
const T | c | |||
) |
Add A times a scalar c to this matrix: this = this + A * c.
CMatrixTemplateNumeric<T>& mrpt::math::CMatrixTemplateNumeric< T >::add_At | ( | const CMatrixTemplateNumeric< T > & | m | ) |
Add to this matrix the transpose of A.
CMatrixTemplateNumeric<T> mrpt::math::CMatrixTemplateNumeric< T >::adj | ( | ) | const |
Computes the adjunt of matrix.
void mrpt::math::CMatrixTemplateNumeric< T >::adjustRange | ( | T | minVal = 0 , |
|
T | maxVal = 1 | |||
) |
Adjusts the range of elements in the matrix such as the minimum and maximum values being those supplied by the user.
CMatrixTemplateNumeric<T>& mrpt::math::CMatrixTemplateNumeric< T >::applyToAllElements | ( | F | function | ) | [inline] |
Applies a generic operation to all the elements of the matrix.
The passed functor object must implement the "T operator(T val)" operator.
Definition at line 293 of file CMatrixTemplateNumeric.h.
void mrpt::math::CMatrixTemplateNumeric< T >::asCol | ( | CMatrixTemplateNumeric< T > & | aux | ) | const |
void mrpt::math::CMatrixTemplateNumeric< T >::asRow | ( | CMatrixTemplateNumeric< T > & | aux | ) | const |
T mrpt::math::CMatrixTemplateNumeric< T >::cofact | ( | size_t | row, | |
size_t | col | |||
) | const |
Computes the cofact.
T mrpt::math::CMatrixTemplateNumeric< T >::cond | ( | ) |
Computes the cond.
T mrpt::math::CMatrixTemplateNumeric< T >::det | ( | ) | const |
Computes the determinant of matrix.
Referenced by mrpt::math::normalPDF().
void mrpt::math::CMatrixTemplateNumeric< T >::eigenVectors | ( | CMatrixTemplateNumeric< T > & | Z, | |
CMatrixTemplateNumeric< T > & | D | |||
) | const |
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.
Referenced by mrpt::utils::CEnhancedMetaFile::ellipseGaussian(), and mrpt::utils::CCanvas::ellipseGaussian().
void mrpt::math::CMatrixTemplateNumeric< T >::find_index_max_value | ( | size_t & | umax, | |
size_t & | vmax, | |||
T & | max_val | |||
) | const |
Finds the maximum value in the matrix, and returns its position.
(by AJOGD @ JAN-2007)
void mrpt::math::CMatrixTemplateNumeric< T >::find_index_min_value | ( | size_t & | umin, | |
size_t & | vmin, | |||
T & | min_val | |||
) | const |
Finds the minimum value in the matrix, and returns its position.
(by AJOGD @ JAN-2007)
void mrpt::math::CMatrixTemplateNumeric< T >::findElementsPassingMahalanobisThreshold | ( | double | stdTimes, | |
std::vector< size_t > & | rowIndexes, | |||
std::vector< size_t > & | colIndexes, | |||
bool | below = false | |||
) | const |
Finds elements whose values are a given number of times above (or below) the mean, in 1D Mahalanobis distance.
This returns two lists with the "row" and "column" indexes (i,j) of those elements m[i][j] such as: m[i][j] > mean(matrix) + stdTimes·std(matrix) The elements below the threshold mean(matrix) - stdTimes·std(matrix) can also be obtained setting "below" to "true".
void mrpt::math::CMatrixTemplateNumeric< T >::force_symmetry | ( | ) |
Force symmetry in the matrix (by AJOGD @ JAN-2007).
CMatrixTemplateNumeric<T> mrpt::math::CMatrixTemplateNumeric< T >::inv | ( | ) | const [inline] |
Computes the Inverse of matrix.
Return the inverse of a matrix without modifying the original matrix
Definition at line 448 of file CMatrixTemplateNumeric.h.
void mrpt::math::CMatrixTemplateNumeric< T >::inv | ( | CMatrixTemplateNumeric< T > & | out_inv | ) | const |
Computes the Inverse of matrix.
Return the inverse of a matrix without modifying the original matrix
Referenced by mrpt::math::normalPDF(), and mrpt::math::operator!().
void mrpt::math::CMatrixTemplateNumeric< T >::inv_fast | ( | CMatrixTemplateNumeric< T > & | out_inv | ) |
Computes the Inverse of matrix, DESTROYING the current matrix and returning the inverse in an user-supplied matrix.
Referenced by mrpt::math::CLevenbergMarquardtTempl< NUMTYPE, USERPARAM >::execute().
bool mrpt::math::CMatrixTemplateNumeric< T >::isDiagonal | ( | ) | const |
Checks for matrix type.
bool mrpt::math::CMatrixTemplateNumeric< T >::isLowerTriangular | ( | ) | const |
Checks for matrix type.
bool mrpt::math::CMatrixTemplateNumeric< T >::isNull | ( | ) | const |
Checks for matrix type.
bool mrpt::math::CMatrixTemplateNumeric< T >::isScalar | ( | ) | const |
Checks for matrix type.
bool mrpt::math::CMatrixTemplateNumeric< T >::isSingular | ( | ) | const |
Checks for matrix type.
bool mrpt::math::CMatrixTemplateNumeric< T >::isSkewSymmetric | ( | ) | const |
Checks for matrix type.
bool mrpt::math::CMatrixTemplateNumeric< T >::isSymmetric | ( | ) | const |
Checks for matrix type.
bool mrpt::math::CMatrixTemplateNumeric< T >::isUnit | ( | ) | const |
Checks for matrix type.
bool mrpt::math::CMatrixTemplateNumeric< T >::isUpperTriangular | ( | ) | const |
Checks for matrix type.
void mrpt::math::CMatrixTemplateNumeric< T >::laplacian | ( | CMatrixTemplateNumeric< T > & | ret | ) | const |
Computes the laplacian of the matrix, useful for graph matrixes.
CMatrixTemplateNumeric<T> mrpt::math::CMatrixTemplateNumeric< T >::largestEigenvector | ( | T | resolution = 0.01f , |
|
size_t | maxIterations = 6 , |
|||
int * | out_Iterations = NULL , |
|||
float * | out_estimatedResolution = NULL | |||
) | const |
Efficiently computes only the biggest eigenvector of the matrix using the Power Method, and returns it as a column vector.
The computation time for this method, in a Pentium 4 1.4Ghz is:
T = 7.0867e-008*n2 + 1.9191e-005*n + 0.0017494 seconds
where N is the matrix size.
void mrpt::math::CMatrixTemplateNumeric< T >::matrix_ceil | ( | ) |
Round towards plus infinity (by AJOGD @ JAN-2007).
void mrpt::math::CMatrixTemplateNumeric< T >::matrix_floor | ( | CMatrixTemplateNumeric< T > & | out | ) |
Round towards minus infinity (by AJOGD @ JAN-2007).
void mrpt::math::CMatrixTemplateNumeric< T >::matrix_floor | ( | ) |
Round towards minus infinity modifying the matrix (by AJOGD @ JAN-2007).
T mrpt::math::CMatrixTemplateNumeric< T >::maximum | ( | ) | const |
Finds the maximum value in the matrix.
T mrpt::math::CMatrixTemplateNumeric< T >::maximumDiagonal | ( | ) | const |
Finds the maximum value in the diagonal of the matrix.
Referenced by mrpt::math::CLevenbergMarquardtTempl< NUMTYPE, USERPARAM >::execute().
void mrpt::math::CMatrixTemplateNumeric< T >::mean | ( | std::vector< T > & | outMeanVector | ) | const |
void mrpt::math::CMatrixTemplateNumeric< T >::meanAndStd | ( | std::vector< T > & | outMeanVector, | |
std::vector< T > & | outStdVector | |||
) | const |
Computes a row with the mean values of each column in the matrix and the associated vector with the standard deviation of each column.
void mrpt::math::CMatrixTemplateNumeric< T >::meanAndStdAll | ( | T & | outMean, | |
T & | outStd | |||
) | const |
Computes the mean and standard deviation of all the elements in the matrix as a whole.
T mrpt::math::CMatrixTemplateNumeric< T >::minimum | ( | ) | const |
Finds the minimum value in the matrix.
void mrpt::math::CMatrixTemplateNumeric< T >::multiply | ( | const CMatrixTemplateNumeric< T > & | m1, | |
const CVectorTemplate< T > & | m2 | |||
) |
Multiply one matrix by a column vector and save the result in "this" object.
void mrpt::math::CMatrixTemplateNumeric< T >::multiply | ( | const CMatrixTemplateNumeric< T > & | m1, | |
const CMatrixTemplateNumeric< T > & | m2 | |||
) |
Multiply 2 matrices and save the result in "this" object.
void mrpt::math::CMatrixTemplateNumeric< T >::multiply_AAt | ( | const CMatrixTemplateNumeric< T > & | m1 | ) |
Makes this = M1 * M1^T, taking into account that the result is symmetric and only half the computations must be done.
void mrpt::math::CMatrixTemplateNumeric< T >::multiply_Ab | ( | const std::vector< T > & | a, | |
std::vector< T > & | out_v | |||
) |
Computes the vector v = this * a, where "a" is a column vector of the appropriate length.
Referenced by mrpt::math::CLevenbergMarquardtTempl< NUMTYPE, USERPARAM >::execute().
void mrpt::math::CMatrixTemplateNumeric< T >::multiply_ABC | ( | const CMatrixTemplateNumeric< T > & | A, | |
const CMatrixTemplateNumeric< T > & | B, | |||
const CMatrixTemplateNumeric< T > & | C | |||
) |
void mrpt::math::CMatrixTemplateNumeric< T >::multiply_ABCt | ( | const CMatrixTemplateNumeric< T > & | A, | |
const CMatrixTemplateNumeric< T > & | B, | |||
const CMatrixTemplateNumeric< T > & | C | |||
) |
void mrpt::math::CMatrixTemplateNumeric< T >::multiply_ABt | ( | const CMatrixTemplateNumeric< T > & | m1, | |
const CMatrixTemplateNumeric< T > & | m2 | |||
) |
Makes this = M1 * M2^T.
void mrpt::math::CMatrixTemplateNumeric< T >::multiply_AtA | ( | const CMatrixTemplateNumeric< T > & | m1 | ) |
Makes this = M1^T * M1, taking into account that the result is symmetric and only half the computations must be done.
Referenced by mrpt::math::CLevenbergMarquardtTempl< NUMTYPE, USERPARAM >::execute().
void mrpt::math::CMatrixTemplateNumeric< T >::multiply_Atb | ( | const std::vector< T > & | a, | |
std::vector< T > & | out_v | |||
) |
Computes the vector v = this^T * a, where "a" is a column vector of the appropriate length.
Referenced by mrpt::math::CLevenbergMarquardtTempl< NUMTYPE, USERPARAM >::execute().
void mrpt::math::CMatrixTemplateNumeric< T >::multiply_HCHt | ( | const CMatrixTemplateNumeric< T > & | C, | |
CMatrixTemplateNumeric< T > & | R, | |||
bool | allowSubMatrixMultiplication = false , |
|||
size_t | subMatrixOffset = 0 , |
|||
bool | accumResultInOutput = false | |||
) | const |
This executes the operation , where 'this' matrix is
and
is symmetric, in an efficient and numerically stable way.
If 'this' matrix is , then
must be
, and the result matrix
will be
. The result from this method is assured to be symmetric (if
is symmetric), whereas executing:
R = H * C * (~H);
If allowSubMatrixMultiplication=true, the multiplication will be performed with a submatrix of C only, with M being the number of columns of H, and C being possibly larger. This is useful in some SLAM problems. In this case, an optional offset 'subMatrixOffset' can be supplied such as a submatrix from the diagonal of C is used, starting at a given column and row index (first=0).
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.
T mrpt::math::CMatrixTemplateNumeric< T >::multiply_HCHt_scalar | ( | const CMatrixTemplateNumeric< T > & | C | ) | const |
An special case of multiply_HCHt for the case of the resulting matrix being a scalar (that is, a 1x1 matrix) - This method directly returns this as a scalar avoiding the construction of a 1x1 matrix.
This matrix (H) must be or a
matrix and C must by
, or an exception will be raised. Refer to multiply_HCHt for more information.
return = ( H * C * (~H) ) (0,0);
void mrpt::math::CMatrixTemplateNumeric< T >::multiply_result_is_symmetric | ( | const CMatrixTemplateNumeric< T > & | m1, | |
const CMatrixTemplateNumeric< T > & | m2 | |||
) |
Multiply 2 matrices and save the result in "this" object, for the cases in which we know in advance that the result will be a symmetrical matrix (DO NOT USE OTHERWISE!!).
void mrpt::math::CMatrixTemplateNumeric< T >::multiplyByMatrixAndByTransposeNonSymmetric | ( | const CMatrixTemplateNumeric< T > & | C, | |
CMatrixTemplateNumeric< T > & | R, | |||
bool | accumOnOutput = false , |
|||
bool | substractInsteadOfSum = false | |||
) | const |
Computes: R = H * C * H^t , where H is this matrix.
void mrpt::math::CMatrixTemplateNumeric< T >::multiplySubMatrix | ( | const CMatrixTemplateNumeric< T > & | A, | |
CMatrixTemplateNumeric< T > & | outResult, | |||
const size_t & | A_cols_offset, | |||
const size_t & | A_rows_offset, | |||
const size_t & | A_col_count | |||
) |
Matrix multiplication of this matrix with a submatrix of 'A', saving the result in a third matrix.
OUT = THIS * A
T mrpt::math::CMatrixTemplateNumeric< T >::norm | ( | ) | const |
Computes the norm of matrix.
void mrpt::math::CMatrixTemplateNumeric< T >::normalize | ( | T | minVal = 0 , |
|
T | maxVal = 1 | |||
) | [inline] |
Adjusts the range of elements in the matrix such as the minimum and maximum values being those supplied by the user.
This method is just a shortcut for adjustRange.
Definition at line 609 of file CMatrixTemplateNumeric.h.
void mrpt::math::CMatrixTemplateNumeric< T >::ones | ( | ) |
Set all elements to one.
void mrpt::math::CMatrixTemplateNumeric< T >::ones | ( | const size_t & | row, | |
const size_t & | col | |||
) |
Set all elements to one.
CMatrixTemplateNumeric<T>& mrpt::math::CMatrixTemplateNumeric< T >::operator*= | ( | const CMatrixTemplateNumeric< T > & | m | ) |
combined matrix multiplication and assignment operator
CMatrixTemplateNumeric<T>& mrpt::math::CMatrixTemplateNumeric< T >::operator*= | ( | const T & | c | ) |
combined scalar multiplication and assignment operator
CMatrixTemplateNumeric<T> mrpt::math::CMatrixTemplateNumeric< T >::operator+ | ( | ) |
Unary operator.
CMatrixTemplateNumeric<T>& mrpt::math::CMatrixTemplateNumeric< T >::operator+= | ( | const T & | c | ) |
Combined scalar addition and assignment operator.
CMatrixTemplateNumeric<T>& mrpt::math::CMatrixTemplateNumeric< T >::operator+= | ( | const CMatrixTemplateNumeric< T > & | m | ) |
combined addition and assignment operator
CMatrixTemplateNumeric<T> mrpt::math::CMatrixTemplateNumeric< T >::operator- | ( | ) |
Unary operator.
CMatrixTemplateNumeric<T>& mrpt::math::CMatrixTemplateNumeric< T >::operator-= | ( | const T & | c | ) |
Combined scalar substraction and assignment operator.
CMatrixTemplateNumeric<T>& mrpt::math::CMatrixTemplateNumeric< T >::operator-= | ( | const CMatrixTemplateNumeric< T > & | m | ) |
combined subtraction and assignment operator
CMatrixTemplateNumeric<T>& mrpt::math::CMatrixTemplateNumeric< T >::operator/= | ( | const T & | c | ) |
combined scalar division and assignment operator
CMatrixTemplateNumeric<T>& mrpt::math::CMatrixTemplateNumeric< T >::operator/= | ( | const CMatrixTemplateNumeric< T > & | m | ) |
Dot division by another matrix (element by element division).
CMatrixTemplateNumeric<T>& mrpt::math::CMatrixTemplateNumeric< T >::operator= | ( | const CMatrixTemplateNumeric< T > & | m | ) |
Assignment operator for the same type.
CMatrixTemplateNumeric& mrpt::math::CMatrixTemplateNumeric< T >::operator= | ( | V(&) | theArray[N] | ) | [inline] |
Assignment operator for initializing from a C array (The matrix must be set to the correct size before invoking this asignament).
CMatrixDouble M(3,2); const double numbers[] = { 1,2,3, 4,5,6 }; M = numbers;
Reimplemented from mrpt::math::CMatrixTemplate< T >.
Definition at line 217 of file CMatrixTemplateNumeric.h.
CMatrixTemplateNumeric<T>& mrpt::math::CMatrixTemplateNumeric< T >::operator= | ( | const CMatrixTemplateNumeric< R > & | m | ) | [inline] |
CMatrixTemplateNumeric& mrpt::math::CMatrixTemplateNumeric< T >::operator= | ( | const CMatrixFixedNumeric< T, NROWS, NCOLS > & | M | ) | [inline] |
Copy operator from a fixed-size matrix.
Definition at line 188 of file CMatrixTemplateNumeric.h.
Referenced by mrpt::math::CMatrixD::operator=().
CMatrixTemplateNumeric<T>& mrpt::math::CMatrixTemplateNumeric< T >::operator^= | ( | const unsigned int & | pow | ) |
combined power and assignment operator
int mrpt::math::CMatrixTemplateNumeric< T >::pivot | ( | size_t | row | ) | [private] |
Internal use.
CMatrixTemplateNumeric<T> mrpt::math::CMatrixTemplateNumeric< T >::pseudoInverse | ( | ) | const [inline] |
Compute the pseudo-inverse of this matrix M, given by .
Definition at line 464 of file CMatrixTemplateNumeric.h.
void mrpt::math::CMatrixTemplateNumeric< T >::pseudoInverse | ( | CMatrixTemplateNumeric< T > & | out | ) | const |
Compute the pseudo-inverse of this matrix M, given by .
size_t mrpt::math::CMatrixTemplateNumeric< T >::rank | ( | T | eps = 0.0 |
) | const |
Computes the rank of the matrix using a slight variation of Gauss method.
void mrpt::math::CMatrixTemplateNumeric< T >::resize | ( | size_t | row, | |
size_t | col | |||
) |
Changes the size of matrix, maintaining its previous content as possible and padding with zeros where applicable.
setSize and resize are exactly equivalent methods.
Referenced by mrpt::math::covariancesAndMean(), mrpt::math::fixedToDynMatrix(), and mrpt::monoslam::CMonoSlam::get_pkk().
void mrpt::math::CMatrixTemplateNumeric< T >::scalarPow | ( | T | s | ) |
Scalar power of all elements to a given power, this is diferent of ^ operator.
void mrpt::math::CMatrixTemplateNumeric< T >::setSize | ( | size_t | row, | |
size_t | col | |||
) |
Changes the size of matrix, maintaining its previous content as possible and padding with zeros where applicable.
setSize and resize are exactly equivalent methods.
Reimplemented from mrpt::math::CMatrixTemplate< T >.
Referenced by mrpt::math::chol(), mrpt::math::estimateJacobian(), mrpt::math::CLevenbergMarquardtTempl< NUMTYPE, USERPARAM >::execute(), mrpt::math::CVectorTemplate< double >::likeMatrix(), mrpt::math::CQuaternion< T >::q_normJac(), and mrpt::math::CQuaternion< T >::q_rotation_matrix().
CMatrixTemplateNumeric<T> mrpt::math::CMatrixTemplateNumeric< T >::solve | ( | const CMatrixTemplateNumeric< T > & | v | ) |
Solve the matrix as linear equations system.
CMatrixTemplateNumeric<T>& mrpt::math::CMatrixTemplateNumeric< T >::Sqrt | ( | ) |
Computes the sqrt of each element in the matrix, replacing current values;.
Referenced by mrpt::utils::CEnhancedMetaFile::ellipseGaussian(), and mrpt::utils::CCanvas::ellipseGaussian().
CMatrixTemplateNumeric<T>& mrpt::math::CMatrixTemplateNumeric< T >::Square | ( | ) |
Computes the square of each element in the matrix, replacing current values.
CMatrixTemplateNumeric<T>& mrpt::math::CMatrixTemplateNumeric< T >::substract_Ac | ( | const CMatrixTemplateNumeric< T > & | m, | |
const T | c | |||
) |
Substract A times a scalar c to this matrix: this = this - A * c.
T mrpt::math::CMatrixTemplateNumeric< T >::sum | ( | size_t | firstRow = 0 , |
|
size_t | firstCol = 0 , |
|||
size_t | lastRow = std::numeric_limits< size_t >::max() , |
|||
size_t | lastCol = std::numeric_limits< size_t >::max() | |||
) | const |
Returns the sum of a given part of the matrix.
The default value (std::numeric_limits<size_t>::max()) for the last column/row means to sum up to the last column/row.
T mrpt::math::CMatrixTemplateNumeric< T >::sumAll | ( | ) | const |
void mrpt::math::CMatrixTemplateNumeric< T >::svd | ( | CMatrixTemplateNumeric< T > & | U, | |
std::vector< T > & | W, | |||
CMatrixTemplateNumeric< T > & | V | |||
) | const |
Computes the SVD (Singular Value Decomposition) of the matrix.
If "this" matrix is named A with dimensions M x N, this method computes:
A = U * W * V'
, where U is a M x N column orthogonal matrix, W is a diagonal matrix containing the singular values, and V is a NxN matrix.
This method returns the U matrix, the N elements in the diagonal of W as a vector, and the matrix V, NOT TRANSPOSED.
void mrpt::math::CMatrixTemplateNumeric< T >::unit | ( | ) |
Build an unit matrix.
void mrpt::math::CMatrixTemplateNumeric< T >::unit | ( | const size_t & | row | ) |
Build an unit matrix.
void mrpt::math::CMatrixTemplateNumeric< T >::zeros | ( | ) |
Set all elements to zero.
void mrpt::math::CMatrixTemplateNumeric< T >::zeros | ( | const size_t & | row, | |
const size_t & | col | |||
) |
Page generated by Doxygen 1.5.7.1 for MRPT 0.7.1 SVN: at Mon Aug 17 23:10:56 EDT 2009 |