#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 (size_t row=1, size_t col=1) | |
Constructor. | |
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. | |
virtual | ~CMatrixTemplateNumeric () |
Destructor. | |
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 > & | addAt (const CMatrixTemplateNumeric< T > &m) |
Add to this matrix the transpose of A. | |
CMatrixTemplateNumeric< T > & | addAAt (const CMatrixTemplateNumeric< T > &m) |
Add to this matrix A and its transpose (this = this + A + At). | |
CMatrixTemplateNumeric< T > & | operator-= (const CMatrixTemplateNumeric< T > &m) |
combined subtraction and assignment operator | |
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. | |
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. | |
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 | multiplyABC (const CMatrixTemplateNumeric< T > &A, const CMatrixTemplateNumeric< T > &B, const CMatrixTemplateNumeric< T > &C) |
Calculate the operation S = ABC where S is this object. | |
void | multiplyABCt (const CMatrixTemplateNumeric< T > &A, const CMatrixTemplateNumeric< T > &B, const CMatrixTemplateNumeric< T > &C) |
Calculate the operation S = ABCt where S is this object. | |
void | multiplyByMatrixAndByTranspose (const CMatrixTemplateNumeric< T > &C, CMatrixTemplateNumeric< T > &R, bool allowSubMatrixMultiplication=false, size_t subMatrixOffset=0, bool accumResultInOutput=false) const |
This executes the operation ![]() ![]() ![]() | |
T | multiplyByMatrixAndByTransposeScalar (const CMatrixTemplateNumeric< T > &C) const |
An special case of multiplyByMatrixAndByTranspose 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. | |
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. | |
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 109 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 115 of file CMatrixTemplateNumeric.h.
mrpt::math::CMatrixTemplateNumeric< T >::CMatrixTemplateNumeric | ( | size_t | row = 1 , |
|
size_t | col = 1 | |||
) |
Constructor.
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 136 of file CMatrixTemplateNumeric.h.
virtual mrpt::math::CMatrixTemplateNumeric< T >::~CMatrixTemplateNumeric | ( | ) | [inline, virtual] |
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 >::addAAt | ( | const CMatrixTemplateNumeric< T > & | m | ) |
Add to this matrix A and its transpose (this = this + A + At).
CMatrixTemplateNumeric<T>& mrpt::math::CMatrixTemplateNumeric< T >::addAt | ( | 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 269 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 |
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::CMRPTCanvas::ellipseGaussian(), and mrpt::utils::CEnhancedMetaFile::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 |
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.
By AJOGD/JLBC
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 >::loadFromTextFile | ( | const std::string & | file | ) |
Load matrix from a text file, compatible with MATLAB text format.
Lines starting with '' or '#' are interpreted as comments and ignored.
Referenced by mrpt::math::CVectorTemplate< KFTYPE >::loadFromTextFile().
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.
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.
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.
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.
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 >::multiplyABC | ( | const CMatrixTemplateNumeric< T > & | A, | |
const CMatrixTemplateNumeric< T > & | B, | |||
const CMatrixTemplateNumeric< T > & | C | |||
) |
void mrpt::math::CMatrixTemplateNumeric< T >::multiplyABCt | ( | const CMatrixTemplateNumeric< T > & | A, | |
const CMatrixTemplateNumeric< T > & | B, | |||
const CMatrixTemplateNumeric< T > & | C | |||
) |
void mrpt::math::CMatrixTemplateNumeric< T >::multiplyByMatrixAndByTranspose | ( | 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.
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.
T mrpt::math::CMatrixTemplateNumeric< T >::multiplyByMatrixAndByTransposeScalar | ( | const CMatrixTemplateNumeric< T > & | C | ) | const |
An special case of multiplyByMatrixAndByTranspose 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 multiplyByMatrixAndByTranspose for more information.
return = ( H * C * (~H) ) (0,0);
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 555 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.
Reimplemented in mrpt::math::CMatrix, and mrpt::math::CMatrixD.
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 168 of file CMatrixTemplateNumeric.h.
CMatrixTemplateNumeric<T>& mrpt::math::CMatrixTemplateNumeric< T >::operator= | ( | const CMatrixTemplateNumeric< R > & | m | ) | [inline] |
Assignment operator of other types.
Definition at line 147 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.
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.
void mrpt::math::CMatrixTemplateNumeric< T >::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.
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. |
Referenced by mrpt::math::CVectorTemplate< KFTYPE >::saveToTextFile().
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::CVectorTemplate< KFTYPE >::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::CMRPTCanvas::ellipseGaussian(), and mrpt::utils::CEnhancedMetaFile::ellipseGaussian().
CMatrixTemplateNumeric<T>& mrpt::math::CMatrixTemplateNumeric< T >::Square | ( | ) |
Computes the square of each element in the matrix, replacing current values.
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 | |||
) |
Set all elements to zero.
Page generated by Doxygen 1.5.8 for MRPT 0.6.5 SVN: at Thu Feb 26 02:18:33 EST 2009 |