#include <mrpt/math/CMatrixTemplate.h>
Public Types | ||||
typedef T | value_type | |||
The type of the matrix elements. | ||||
Public Member Functions | ||||
void | extractCol (size_t nCol, std::vector< T > &out, int startingRow=0) const | |||
Returns a given column to a vector (without modifying the matrix)
| ||||
void | extractCol (size_t nCol, CMatrixTemplate< T > &out, int startingRow=0) const | |||
Gets a given column to a vector (without modifying the matrix)
| ||||
void | swapCols (size_t nCol1, size_t nCol2) | |||
Swap two columns
| ||||
void | swapRows (size_t nRow1, size_t nRow2) | |||
Swap two rows
| ||||
template<class F > | ||||
void | extractRow (size_t nRow, std::vector< F > &out, size_t startingCol=0) const | |||
Gets a given row to a vector (without modifying the matrix)
| ||||
template<class F > | ||||
void | extractRow (size_t nRow, CMatrixTemplate< F > &out, size_t startingCol=0) const | |||
Gets a given row to a vector (without modifying the matrix)
| ||||
CMatrixTemplate (const CMatrixTemplate &m) | ||||
Constructors. | ||||
CMatrixTemplate (size_t row=3, size_t col=3) | ||||
CMatrixTemplate (const CMatrixTemplate &m, const size_t cropRowCount, const size_t cropColCount) | ||||
Copy constructor & crop from another matrix. | ||||
template<typename V , size_t N> | ||||
CMatrixTemplate (size_t row, size_t col, V(&theArray)[N]) | ||||
Constructor from a given size and a C array. | ||||
template<typename V > | ||||
CMatrixTemplate (size_t row, size_t col, const V &theVector) | ||||
Constructor from a given size and a STL container (std::vector, std::list,. | ||||
virtual | ~CMatrixTemplate () | |||
Destructor. | ||||
CMatrixTemplate & | operator= (const CMatrixTemplate &m) | |||
Assignment operator from another matrix. | ||||
template<typename V , size_t N> | ||||
CMatrixTemplate & | 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). | ||||
size_t | getRowCount () const | |||
Number of rows in the matrix. | ||||
size_t | getColCount () const | |||
Number of columns in the matrix. | ||||
void | setSize (size_t row, size_t col) | |||
Changes the size of matrix, maintaining the previous contents. | ||||
bool | IsSquare () const | |||
Check for type of matrix. | ||||
T & | operator() (size_t row, size_t col) | |||
Subscript operator to get/set individual elements. | ||||
T | operator() (size_t row, size_t col) const | |||
Subscript operator to get/set individual elements. | ||||
T & | operator() (size_t ith) | |||
Subscript operator to get/set an individual element from a row or column matrix. | ||||
T | operator() (size_t ith) const | |||
Subscript operator to get/set an individual element from a row or column matrix. | ||||
void | set_unsafe (size_t row, size_t col, const T &v) | |||
Fast but unsafe method to write a value in the matrix. | ||||
T | get_unsafe (size_t row, size_t col) const | |||
Fast but unsafe method to read a value from the matrix. | ||||
T & | get_unsafe (size_t row, size_t col) | |||
Fast but unsafe method to get a reference from the matrix. | ||||
T * | get_unsafe_row (size_t row) const | |||
Fast but unsafe method to obtain a pointer to a given row of the matrix (Use only in time critical applications). | ||||
void | extractRows (size_t firstRow, size_t lastRow, CMatrixTemplate< T > &out) const | |||
Gets a series of contiguous rows. | ||||
void | extractColumns (size_t firstCol, size_t lastCol, CMatrixTemplate< T > &out) const | |||
Gets a series of contiguous columns. | ||||
void | insertRow (size_t nRow, const std::vector< T > &in) | |||
Inserts a row from a vector, replacing the current contents of that row. | ||||
void | appendRow (const std::vector< T > &in) | |||
Appends a new row to the MxN matrix from a 1xN vector. | ||||
void | appendCol (const std::vector< T > &in) | |||
Appends a new column to the matrix from a vector. | ||||
void | insertCol (size_t nCol, const std::vector< T > &in) | |||
Inserts a column from a vector, replacing the current contents of that column. | ||||
template<class R > | ||||
void | insertMatrix (const size_t nRow, const size_t nCol, const CMatrixTemplate< R > &in) | |||
Inserts a matrix into this matrix Notice that the matrix must "fit" into the existing size of this matrix. | ||||
void | insertMatrixTranspose (const size_t nRow, const size_t nCol, const CMatrixTemplate< T > &in) | |||
Inserts the transpose of a given matrix into this matrix Notice that the matrix must "fit" into the existing size of this matrix. | ||||
template<size_t NROWS, size_t NCOLS> | ||||
void | insertMatrix (const size_t nRow, const size_t nCol, const CMatrixFixedNumeric< T, NROWS, NCOLS > &in) | |||
Inserts a fixed-size matrix into this matrix Notice that the matrix must "fit" into the existing size of this matrix. | ||||
template<size_t NROWS, size_t NCOLS> | ||||
void | insertMatrixTranspose (const size_t nRow, const size_t nCol, const CMatrixFixedNumeric< T, NROWS, NCOLS > &in) | |||
Inserts the transpose of a given fixed-size matrix into this matrix Notice that the matrix must "fit" into the existing size of this matrix. | ||||
void | insertMatrix (size_t nRow, size_t nCol, const std::vector< T > &in) | |||
Inserts a matrix line (vector) into this matrix Notice that the matrix must "fit" into the existing size of this matrix. | ||||
void | joinMatrix (const CMatrixTemplate< T > &left_up, const CMatrixTemplate< T > &right_up, const CMatrixTemplate< T > &left_down, const CMatrixTemplate< T > &right_down) | |||
Inserts 4 matrixes corresponding to the "four corners" into this matrix. | ||||
void | fill (const T &val) | |||
Fill the matrix with a given value:. | ||||
void | extractSubmatrix (const size_t row1, const size_t row2, const size_t col1, const size_t col2, CMatrixTemplate< T > &out) const | |||
Get a submatrix, given its bounds. | ||||
CMatrixTemplate< T > | operator() (const size_t row1, const size_t row2, const size_t col1, const size_t col2) const | |||
Subscript operator to get a submatrix. | ||||
void | exchangeColumns (size_t col1, size_t col2) | |||
Interchanges two columns of the matrix. | ||||
void | exchangeRows (size_t row1, size_t row2) | |||
Interchanges two rows of the matrix. | ||||
void | deleteRow (size_t row) | |||
Deletes a row of the matrix. | ||||
void | deleteColumn (size_t col) | |||
Deletes a column of the matrix. | ||||
template<class R > | ||||
void | extractMatrix (size_t nRow, size_t nCol, CMatrixTemplate< R > &in) const | |||
Extract a sub matrix from a matrix:
| ||||
void | extractMatrix (size_t nRow, size_t nCol, size_t nrows, size_t ncols, CMatrixTemplate< T > &outMat) const | |||
Extract a sub matrix from a matrix:
| ||||
void | extractMatrix (size_t nRow, size_t nCol, std::vector< T > &in) const | |||
Extract a sub matrix (vector) from a matrix:
| ||||
template<size_t NROWS, size_t NCOLS> | ||||
void | extractMatrix (const size_t nRow, const size_t nCol, CMatrixFixedNumeric< T, NROWS, NCOLS > &outMat) const | |||
Extract a sub matrix from a matrix (in the form of a fixed-size matrix)
| ||||
std::vector< T > | extractMatrix (size_t nRow, size_t nCol, size_t ncols) const | |||
Extract a sub matrix (vector) from a matrix:
| ||||
std::string | inMatlabFormat () const | |||
Dump matrix in matlab format. | ||||
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 | removeColumns (const mrpt::vector_size_t &idxsToRemove, bool vectorIsAlreadySorted=false) | |||
Removes a set of columns by their indexes (0:first), given by the vector "idxsToRemove". | ||||
void | getAsVector (std::vector< T > &out) const | |||
Returns a vector containing the matrix's values. | ||||
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. | ||||
Protected Member Functions | ||||
void | realloc (size_t row, size_t col, bool newElementsToZero=false) | |||
Internal use only: It realloc the memory for the 2D matrix, maintaining the previous contents if posible. | ||||
Protected Attributes | ||||
T ** | m_Val | |||
size_t | m_Rows | |||
size_t | m_Cols |
NOTES:
Definition at line 74 of file CMatrixTemplate.h.
typedef T mrpt::math::CMatrixTemplate< T >::value_type |
mrpt::math::CMatrixTemplate< T >::CMatrixTemplate | ( | const CMatrixTemplate< T > & | m | ) | [inline] |
mrpt::math::CMatrixTemplate< T >::CMatrixTemplate | ( | size_t | row = 3 , |
|
size_t | col = 3 | |||
) | [inline] |
Definition at line 242 of file CMatrixTemplate.h.
mrpt::math::CMatrixTemplate< T >::CMatrixTemplate | ( | const CMatrixTemplate< T > & | m, | |
const size_t | cropRowCount, | |||
const size_t | cropColCount | |||
) | [inline] |
mrpt::math::CMatrixTemplate< T >::CMatrixTemplate | ( | 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 270 of file CMatrixTemplate.h.
mrpt::math::CMatrixTemplate< T >::CMatrixTemplate | ( | 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 289 of file CMatrixTemplate.h.
virtual mrpt::math::CMatrixTemplate< T >::~CMatrixTemplate | ( | ) | [inline, virtual] |
void mrpt::math::CMatrixTemplate< T >::appendCol | ( | const std::vector< T > & | in | ) | [inline] |
Appends a new column to the matrix from a vector.
The length of the vector must match the number of rows of the matrix, unless it is (0,0).
std::exception | On size mismatch. |
Definition at line 563 of file CMatrixTemplate.h.
void mrpt::math::CMatrixTemplate< T >::appendRow | ( | const std::vector< T > & | in | ) | [inline] |
Appends a new row to the MxN matrix from a 1xN vector.
The lenght of the vector must match the width of the matrix, unless it's empty: in that case the matrix is resized to 1xN.
CMatrixDouble M(0,0); vector_double v(7),w(7); // ... M.appendRow(v); M.appendRow(w);
std::exception | On incorrect vector length. |
Definition at line 534 of file CMatrixTemplate.h.
void mrpt::math::CMatrixTemplate< T >::deleteColumn | ( | size_t | col | ) | [inline] |
void mrpt::math::CMatrixTemplate< T >::deleteRow | ( | size_t | row | ) | [inline] |
void mrpt::math::CMatrixTemplate< T >::exchangeColumns | ( | size_t | col1, | |
size_t | col2 | |||
) | [inline] |
void mrpt::math::CMatrixTemplate< T >::exchangeRows | ( | size_t | row1, | |
size_t | row2 | |||
) | [inline] |
void mrpt::math::CMatrixTemplate< T >::extractCol | ( | size_t | nCol, | |
CMatrixTemplate< T > & | out, | |||
int | startingRow = 0 | |||
) | const [inline] |
Gets a given column to a vector (without modifying the matrix)
std::exception | On index out of bounds. |
Definition at line 156 of file CMatrixTemplate.h.
void mrpt::math::CMatrixTemplate< T >::extractCol | ( | size_t | nCol, | |
std::vector< T > & | out, | |||
int | startingRow = 0 | |||
) | const [inline] |
Returns a given column to a vector (without modifying the matrix)
std::exception | On index out of bounds. |
Definition at line 138 of file CMatrixTemplate.h.
void mrpt::math::CMatrixTemplate< T >::extractColumns | ( | size_t | firstCol, | |
size_t | lastCol, | |||
CMatrixTemplate< T > & | out | |||
) | const [inline] |
Gets a series of contiguous columns.
std::logic_error | On index out of bounds |
Definition at line 502 of file CMatrixTemplate.h.
std::vector<T> mrpt::math::CMatrixTemplate< T >::extractMatrix | ( | size_t | nRow, | |
size_t | nCol, | |||
size_t | ncols | |||
) | const [inline] |
Extract a sub matrix (vector) from a matrix:
std::exception | On index out of bounds The output matrix must have been previously set to the desired size. |
(by AJOGD @ JAN-2007)
Definition at line 847 of file CMatrixTemplate.h.
void mrpt::math::CMatrixTemplate< T >::extractMatrix | ( | const size_t | nRow, | |
const size_t | nCol, | |||
CMatrixFixedNumeric< T, NROWS, NCOLS > & | outMat | |||
) | const [inline] |
Extract a sub matrix from a matrix (in the form of a fixed-size matrix)
std::exception | On index out of bounds The output matrix settles the size of the submatrix to extract, and (nRow,nCol) are the indices of the first element in the submatrix: e.g. |
(0,0) means extract a submatrix from the top-left corner
Definition at line 838 of file CMatrixTemplate.h.
void mrpt::math::CMatrixTemplate< T >::extractMatrix | ( | size_t | nRow, | |
size_t | nCol, | |||
std::vector< T > & | in | |||
) | const [inline] |
Extract a sub matrix (vector) from a matrix:
std::exception | On index out of bounds The output matrix must have been previously set to the desired size. |
(by AJOGD @ JAN-2007)
Definition at line 819 of file CMatrixTemplate.h.
void mrpt::math::CMatrixTemplate< T >::extractMatrix | ( | size_t | nRow, | |
size_t | nCol, | |||
size_t | nrows, | |||
size_t | ncols, | |||
CMatrixTemplate< T > & | outMat | |||
) | const [inline] |
Extract a sub matrix from a matrix:
std::exception | On index out of bounds The output matrix must have been previously set to the desired size. |
(by AJOGD @ JAN-2007)
Definition at line 801 of file CMatrixTemplate.h.
void mrpt::math::CMatrixTemplate< T >::extractMatrix | ( | size_t | nRow, | |
size_t | nCol, | |||
CMatrixTemplate< R > & | in | |||
) | const [inline] |
Extract a sub matrix from a matrix:
std::exception | On index out of bounds The output matrix must have been previously set to the desired size. |
(by AJOGD @ JAN-2007)
Definition at line 782 of file CMatrixTemplate.h.
Referenced by mrpt::math::CMatrixTemplate< TPoint3D >::extractColumns(), and mrpt::math::CMatrixTemplate< TPoint3D >::extractRows().
void mrpt::math::CMatrixTemplate< T >::extractRow | ( | size_t | nRow, | |
CMatrixTemplate< F > & | out, | |||
size_t | startingCol = 0 | |||
) | const [inline] |
Gets a given row to a vector (without modifying the matrix)
std::exception | On index out of bounds. |
Definition at line 221 of file CMatrixTemplate.h.
void mrpt::math::CMatrixTemplate< T >::extractRow | ( | size_t | nRow, | |
std::vector< F > & | out, | |||
size_t | startingCol = 0 | |||
) | const [inline] |
Gets a given row to a vector (without modifying the matrix)
std::exception | On index out of bounds. |
Definition at line 203 of file CMatrixTemplate.h.
void mrpt::math::CMatrixTemplate< T >::extractRows | ( | size_t | firstRow, | |
size_t | lastRow, | |||
CMatrixTemplate< T > & | out | |||
) | const [inline] |
Gets a series of contiguous rows.
std::logic_error | On index out of bounds |
Definition at line 493 of file CMatrixTemplate.h.
void mrpt::math::CMatrixTemplate< T >::extractSubmatrix | ( | const size_t | row1, | |
const size_t | row2, | |||
const size_t | col1, | |||
const size_t | col2, | |||
CMatrixTemplate< T > & | out | |||
) | const [inline] |
Get a submatrix, given its bounds.
Definition at line 706 of file CMatrixTemplate.h.
Referenced by mrpt::math::CMatrixTemplate< TPoint3D >::operator()().
void mrpt::math::CMatrixTemplate< T >::fill | ( | const T & | val | ) | [inline] |
bool mrpt::math::CMatrixTemplate< T >::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
Definition at line 896 of file CMatrixTemplate.h.
Referenced by mrpt::math::CMatrixFixedNumeric< float, 4, 4 >::fromMatlabStringFormat().
T& mrpt::math::CMatrixTemplate< T >::get_unsafe | ( | size_t | row, | |
size_t | col | |||
) | [inline] |
Fast but unsafe method to get a reference from the matrix.
Definition at line 477 of file CMatrixTemplate.h.
T mrpt::math::CMatrixTemplate< T >::get_unsafe | ( | size_t | row, | |
size_t | col | |||
) | const [inline] |
Fast but unsafe method to read a value from the matrix.
Definition at line 470 of file CMatrixTemplate.h.
Referenced by mrpt::math::CMatrixFixedNumeric< float, 4, 4 >::CMatrixFixedNumeric(), mrpt::math::CMatrixTemplateNumeric< KFTYPE >::CMatrixTemplateNumeric(), mrpt::math::CMatrixTemplate< TPoint3D >::insertMatrix(), mrpt::math::insertMatrixFixTransposeIntoDyn(), mrpt::math::CMatrixTemplate< TPoint3D >::insertMatrixTranspose(), mrpt::math::meanAndCov(), mrpt::math::CMatrixFixedNumeric< float, 4, 4 >::operator=(), and mrpt::math::CMatrix::operator=().
T* mrpt::math::CMatrixTemplate< T >::get_unsafe_row | ( | size_t | row | ) | const [inline] |
Fast but unsafe method to obtain a pointer to a given row of the matrix (Use only in time critical applications).
Definition at line 483 of file CMatrixTemplate.h.
Referenced by mrpt::math::extractFixMatrixFromDynMatrix(), mrpt::math::insertMatrixFixIntoDyn(), and mrpt::math::CMatrixFixedNumeric< float, 4, 4 >::operator=().
void mrpt::math::CMatrixTemplate< T >::getAsVector | ( | std::vector< T > & | out | ) | const [inline] |
size_t mrpt::math::CMatrixTemplate< T >::getColCount | ( | ) | const [inline] |
Number of columns in the matrix.
Definition at line 364 of file CMatrixTemplate.h.
Referenced by mrpt::math::CConstMatrixColumnAccessor< T >::CConstMatrixColumnAccessor(), mrpt::math::CConstMatrixColumnAccessorExtended< T >::CConstMatrixColumnAccessorExtended(), mrpt::math::CMatrixColumnAccessor< T >::CMatrixColumnAccessor(), mrpt::math::CMatrixColumnAccessorExtended< T >::CMatrixColumnAccessorExtended(), mrpt::math::CMatrixFixedNumeric< float, 4, 4 >::CMatrixFixedNumeric(), mrpt::math::CMatrixTemplateNumeric< KFTYPE >::CMatrixTemplateNumeric(), mrpt::math::CLevenbergMarquardtTempl< NUMTYPE, USERPARAM >::execute(), mrpt::math::extractFixMatrixFromDynMatrix(), mrpt::math::CMatrixTemplate< TPoint3D >::extractMatrix(), mrpt::math::CMatrixFixedNumeric< float, 4, 4 >::fromMatlabStringFormat(), mrpt::math::insertMatrixFixIntoDyn(), mrpt::math::insertMatrixFixTransposeIntoDyn(), mrpt::math::CMatrixTemplate< TPoint3D >::joinMatrix(), mrpt::math::CMatrixTemplateObjects< T >::operator=(), mrpt::math::CMatrixFixedNumeric< float, 4, 4 >::operator=(), mrpt::math::CMatrixD::operator=(), mrpt::math::CMatrix::operator=(), and mrpt::math::size().
size_t mrpt::math::CMatrixTemplate< T >::getRowCount | ( | ) | const [inline] |
Number of rows in the matrix.
Definition at line 356 of file CMatrixTemplate.h.
Referenced by mrpt::math::CConstMatrixRowAccessor< T >::CConstMatrixRowAccessor(), mrpt::math::CConstMatrixRowAccessorExtended< T >::CConstMatrixRowAccessorExtended(), mrpt::math::CMatrixFixedNumeric< float, 4, 4 >::CMatrixFixedNumeric(), mrpt::math::CMatrixRowAccessor< T >::CMatrixRowAccessor(), mrpt::math::CMatrixRowAccessorExtended< T >::CMatrixRowAccessorExtended(), mrpt::math::CMatrixTemplateNumeric< KFTYPE >::CMatrixTemplateNumeric(), mrpt::math::extractFixMatrixFromDynMatrix(), mrpt::math::CMatrixTemplate< TPoint3D >::extractMatrix(), mrpt::math::CMatrixFixedNumeric< float, 4, 4 >::fromMatlabStringFormat(), mrpt::math::insertMatrixFixIntoDyn(), mrpt::math::insertMatrixFixTransposeIntoDyn(), mrpt::math::CMatrixTemplate< TPoint3D >::joinMatrix(), mrpt::math::CMatrixTemplateObjects< T >::operator=(), mrpt::math::CMatrixFixedNumeric< float, 4, 4 >::operator=(), mrpt::math::CMatrixD::operator=(), mrpt::math::CMatrix::operator=(), and mrpt::math::size().
std::string mrpt::math::CMatrixTemplate< T >::inMatlabFormat | ( | ) | const [inline] |
Dump matrix in matlab format.
This template method can be instantiated for matrices of the types: int, long, unsinged int, unsigned long, float, double, long double
Definition at line 866 of file CMatrixTemplate.h.
void mrpt::math::CMatrixTemplate< T >::insertCol | ( | size_t | nCol, | |
const std::vector< T > & | in | |||
) | [inline] |
Inserts a column from a vector, replacing the current contents of that column.
std::exception | On index out of bounds |
Definition at line 578 of file CMatrixTemplate.h.
void mrpt::math::CMatrixTemplate< T >::insertMatrix | ( | size_t | nRow, | |
size_t | nCol, | |||
const std::vector< T > & | in | |||
) | [inline] |
Inserts a matrix line (vector) into this matrix Notice that the matrix must "fit" into the existing size of this matrix.
std::exception | On index out of bounds |
Definition at line 666 of file CMatrixTemplate.h.
void mrpt::math::CMatrixTemplate< T >::insertMatrix | ( | const size_t | nRow, | |
const size_t | nCol, | |||
const CMatrixFixedNumeric< T, NROWS, NCOLS > & | in | |||
) | [inline] |
Inserts a fixed-size matrix into this matrix Notice that the matrix must "fit" into the existing size of this matrix.
in | The submatrix to insert into 'this' matrix. | |
nRow | The row in 'this' matrix where the submatrix will be inserted (0:first). | |
nCol | The column in 'this' matrix where the submatrix will be inserted (0:first). |
std::exception | On index out of bounds |
Definition at line 643 of file CMatrixTemplate.h.
void mrpt::math::CMatrixTemplate< T >::insertMatrix | ( | const size_t | nRow, | |
const size_t | nCol, | |||
const CMatrixTemplate< R > & | in | |||
) | [inline] |
Inserts a matrix into this matrix Notice that the matrix must "fit" into the existing size of this matrix.
in | The submatrix to insert into 'this' matrix. | |
nRow | The row in 'this' matrix where the submatrix will be inserted (0:first). | |
nCol | The column in 'this' matrix where the submatrix will be inserted (0:first). |
std::exception | On index out of bounds |
Definition at line 598 of file CMatrixTemplate.h.
Referenced by mrpt::math::CMatrixTemplate< TPoint3D >::joinMatrix().
void mrpt::math::CMatrixTemplate< T >::insertMatrixTranspose | ( | const size_t | nRow, | |
const size_t | nCol, | |||
const CMatrixFixedNumeric< T, NROWS, NCOLS > & | in | |||
) | [inline] |
Inserts the transpose of a given fixed-size matrix into this matrix Notice that the matrix must "fit" into the existing size of this matrix.
in | The submatrix to insert into 'this' matrix. | |
nRow | The row in 'this' matrix where the submatrix will be inserted (0:first). | |
nCol | The column in 'this' matrix where the submatrix will be inserted (0:first). |
std::exception | On index out of bounds |
Definition at line 656 of file CMatrixTemplate.h.
void mrpt::math::CMatrixTemplate< T >::insertMatrixTranspose | ( | const size_t | nRow, | |
const size_t | nCol, | |||
const CMatrixTemplate< T > & | in | |||
) | [inline] |
Inserts the transpose of a given matrix into this matrix Notice that the matrix must "fit" into the existing size of this matrix.
in | The submatrix to insert into 'this' matrix. | |
nRow | The row in 'this' matrix where the submatrix will be inserted (0:first). | |
nCol | The column in 'this' matrix where the submatrix will be inserted (0:first). |
std::exception | On index out of bounds |
Definition at line 620 of file CMatrixTemplate.h.
void mrpt::math::CMatrixTemplate< T >::insertRow | ( | size_t | nRow, | |
const std::vector< T > & | in | |||
) | [inline] |
Inserts a row from a vector, replacing the current contents of that row.
std::exception | On index out of bounds |
Definition at line 510 of file CMatrixTemplate.h.
Referenced by mrpt::math::CLevenbergMarquardtTempl< NUMTYPE, USERPARAM >::execute().
bool mrpt::math::CMatrixTemplate< T >::IsSquare | ( | ) | const [inline] |
void mrpt::math::CMatrixTemplate< T >::joinMatrix | ( | const CMatrixTemplate< T > & | left_up, | |
const CMatrixTemplate< T > & | right_up, | |||
const CMatrixTemplate< T > & | left_down, | |||
const CMatrixTemplate< T > & | right_down | |||
) | [inline] |
Inserts 4 matrixes corresponding to the "four corners" into this matrix.
std::exception | On index out of bounds |
Definition at line 682 of file CMatrixTemplate.h.
void mrpt::math::CMatrixTemplate< T >::loadFromTextFile | ( | const std::string & | file | ) | [inline] |
Load matrix from a text file, compatible with MATLAB text format.
Lines starting with '' or '#' are interpreted as comments and ignored.
Definition at line 986 of file CMatrixTemplate.h.
CMatrixTemplate<T> mrpt::math::CMatrixTemplate< T >::operator() | ( | const size_t | row1, | |
const size_t | row2, | |||
const size_t | col1, | |||
const size_t | col2 | |||
) | const [inline] |
T mrpt::math::CMatrixTemplate< T >::operator() | ( | size_t | ith | ) | const [inline] |
Subscript operator to get/set an individual element from a row or column matrix.
std::exception | If the object is not a column or row matrix. |
Definition at line 436 of file CMatrixTemplate.h.
T& mrpt::math::CMatrixTemplate< T >::operator() | ( | size_t | ith | ) | [inline] |
Subscript operator to get/set an individual element from a row or column matrix.
std::exception | If the object is not a column or row matrix. |
Definition at line 408 of file CMatrixTemplate.h.
T mrpt::math::CMatrixTemplate< T >::operator() | ( | size_t | row, | |
size_t | col | |||
) | const [inline] |
Subscript operator to get/set individual elements.
Definition at line 396 of file CMatrixTemplate.h.
T& mrpt::math::CMatrixTemplate< T >::operator() | ( | size_t | row, | |
size_t | col | |||
) | [inline] |
Subscript operator to get/set individual elements.
Definition at line 385 of file CMatrixTemplate.h.
CMatrixTemplate& mrpt::math::CMatrixTemplate< 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 in mrpt::math::CMatrixTemplateNumeric< T >, mrpt::math::CMatrixTemplateNumeric< NUMTYPE >, mrpt::math::CMatrixTemplateNumeric< double >, mrpt::math::CMatrixTemplateNumeric< float >, and mrpt::math::CMatrixTemplateNumeric< KFTYPE >.
Definition at line 336 of file CMatrixTemplate.h.
CMatrixTemplate& mrpt::math::CMatrixTemplate< T >::operator= | ( | const CMatrixTemplate< T > & | m | ) | [inline] |
void mrpt::math::CMatrixTemplate< T >::realloc | ( | size_t | row, | |
size_t | col, | |||
bool | newElementsToZero = false | |||
) | [inline, protected] |
Internal use only: It realloc the memory for the 2D matrix, maintaining the previous contents if posible.
Definition at line 85 of file CMatrixTemplate.h.
Referenced by mrpt::math::CMatrixTemplate< TPoint3D >::appendCol(), mrpt::math::CMatrixTemplate< TPoint3D >::appendRow(), mrpt::math::CMatrixTemplate< TPoint3D >::CMatrixTemplate(), mrpt::math::CMatrixTemplate< TPoint3D >::deleteColumn(), mrpt::math::CMatrixTemplate< TPoint3D >::deleteRow(), mrpt::math::CMatrixTemplate< TPoint3D >::extractSubmatrix(), mrpt::math::CMatrixTemplate< TPoint3D >::fromMatlabStringFormat(), mrpt::math::CMatrixTemplate< TPoint3D >::loadFromTextFile(), mrpt::math::CMatrixTemplate< TPoint3D >::operator=(), mrpt::math::CMatrixTemplate< TPoint3D >::setSize(), and mrpt::math::CMatrixTemplate< TPoint3D >::~CMatrixTemplate().
void mrpt::math::CMatrixTemplate< T >::removeColumns | ( | const mrpt::vector_size_t & | idxsToRemove, | |
bool | vectorIsAlreadySorted = false | |||
) | [inline] |
Removes a set of columns by their indexes (0:first), given by the vector "idxsToRemove".
vectorIsAlreadySorted | Can be set to true only when it can be assured that the vector of indices is sorted in ascending order. Otherwise, the method will sort it internally. |
std::exception | On index out of bounds |
Definition at line 1075 of file CMatrixTemplate.h.
void mrpt::math::CMatrixTemplate< T >::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.
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. |
Definition at line 972 of file CMatrixTemplate.h.
void mrpt::math::CMatrixTemplate< T >::set_unsafe | ( | size_t | row, | |
size_t | col, | |||
const T & | v | |||
) | [inline] |
Fast but unsafe method to write a value in the matrix.
Definition at line 463 of file CMatrixTemplate.h.
Referenced by mrpt::math::CMatrixTemplate< TPoint3D >::extractMatrix(), mrpt::math::CMatrixTemplate< TPoint3D >::insertMatrix(), and mrpt::math::CMatrixTemplate< TPoint3D >::insertMatrixTranspose().
void mrpt::math::CMatrixTemplate< T >::setSize | ( | size_t | row, | |
size_t | col | |||
) | [inline] |
Changes the size of matrix, maintaining the previous contents.
Reimplemented in mrpt::math::CMatrixTemplateNumeric< T >, mrpt::math::CMatrixTemplateObjects< T >, mrpt::math::CMatrixTemplateNumeric< NUMTYPE >, mrpt::math::CMatrixTemplateNumeric< double >, mrpt::math::CMatrixTemplateNumeric< float >, and mrpt::math::CMatrixTemplateNumeric< KFTYPE >.
Definition at line 371 of file CMatrixTemplate.h.
Referenced by mrpt::math::CMatrixTemplate< TPoint3D >::extractCol(), mrpt::math::CMatrixTemplate< TPoint3D >::extractMatrix(), mrpt::math::CMatrixTemplate< TPoint3D >::extractRow(), mrpt::math::CMatrixTemplate< TPoint3D >::fromMatlabStringFormat(), mrpt::poses::CPose2DGridTemplate< double >::getAsMatrix(), mrpt::math::CMatrixTemplate< TPoint3D >::joinMatrix(), and mrpt::math::CMatrixTemplate< TPoint3D >::removeColumns().
void mrpt::math::CMatrixTemplate< T >::swapCols | ( | size_t | nCol1, | |
size_t | nCol2 | |||
) | [inline] |
Swap two columns
std::exception | On index out of bounds. |
Definition at line 174 of file CMatrixTemplate.h.
void mrpt::math::CMatrixTemplate< T >::swapRows | ( | size_t | nRow1, | |
size_t | nRow2 | |||
) | [inline] |
Swap two rows
std::exception | On index out of bounds. |
Definition at line 188 of file CMatrixTemplate.h.
size_t mrpt::math::CMatrixTemplate< T >::m_Cols [protected] |
Definition at line 81 of file CMatrixTemplate.h.
Referenced by mrpt::math::CMatrixTemplate< TPoint3D >::appendCol(), mrpt::math::CMatrixTemplate< TPoint3D >::appendRow(), mrpt::math::CMatrixTemplate< TPoint3D >::CMatrixTemplate(), mrpt::math::CMatrixTemplate< TPoint3D >::deleteColumn(), mrpt::math::CMatrixTemplate< TPoint3D >::deleteRow(), mrpt::math::CMatrixTemplate< TPoint3D >::exchangeColumns(), mrpt::math::CMatrixTemplate< TPoint3D >::exchangeRows(), mrpt::math::CMatrixTemplate< TPoint3D >::extractCol(), mrpt::math::CMatrixTemplate< TPoint3D >::extractRow(), mrpt::math::CMatrixTemplate< TPoint3D >::extractRows(), mrpt::math::CMatrixTemplate< TPoint3D >::extractSubmatrix(), mrpt::math::CMatrixTemplate< TPoint3D >::fill(), mrpt::math::CMatrixTemplate< TPoint3D >::fromMatlabStringFormat(), mrpt::math::CMatrixTemplate< TPoint3D >::getAsVector(), mrpt::math::CMatrixTemplate< TPoint3D >::getColCount(), mrpt::math::CMatrixTemplate< TPoint3D >::inMatlabFormat(), mrpt::math::CMatrixTemplate< TPoint3D >::insertCol(), mrpt::math::CMatrixTemplate< TPoint3D >::insertMatrix(), mrpt::math::CMatrixTemplate< TPoint3D >::insertMatrixTranspose(), mrpt::math::CMatrixTemplate< TPoint3D >::insertRow(), mrpt::math::CMatrixTemplate< TPoint3D >::IsSquare(), mrpt::math::CMatrixTemplate< TPoint3D >::operator()(), mrpt::math::CMatrixTemplate< TPoint3D >::operator=(), mrpt::math::CMatrixTemplate< TPoint3D >::realloc(), mrpt::math::CMatrixTemplate< TPoint3D >::removeColumns(), mrpt::math::CMatrixTemplate< TPoint3D >::swapCols(), and mrpt::math::CMatrixTemplate< TPoint3D >::swapRows().
size_t mrpt::math::CMatrixTemplate< T >::m_Rows [protected] |
Definition at line 81 of file CMatrixTemplate.h.
Referenced by mrpt::math::CMatrixTemplate< TPoint3D >::appendCol(), mrpt::math::CMatrixTemplate< TPoint3D >::appendRow(), mrpt::math::CMatrixTemplate< TPoint3D >::CMatrixTemplate(), mrpt::math::CMatrixTemplate< TPoint3D >::deleteColumn(), mrpt::math::CMatrixTemplate< TPoint3D >::deleteRow(), mrpt::math::CMatrixTemplate< TPoint3D >::exchangeColumns(), mrpt::math::CMatrixTemplate< TPoint3D >::exchangeRows(), mrpt::math::CMatrixTemplate< TPoint3D >::extractCol(), mrpt::math::CMatrixTemplate< TPoint3D >::extractColumns(), mrpt::math::CMatrixTemplate< TPoint3D >::extractRow(), mrpt::math::CMatrixTemplate< TPoint3D >::extractSubmatrix(), mrpt::math::CMatrixTemplate< TPoint3D >::fill(), mrpt::math::CMatrixTemplate< TPoint3D >::getAsVector(), mrpt::math::CMatrixTemplate< TPoint3D >::getRowCount(), mrpt::math::CMatrixTemplate< TPoint3D >::inMatlabFormat(), mrpt::math::CMatrixTemplate< TPoint3D >::insertCol(), mrpt::math::CMatrixTemplate< TPoint3D >::insertMatrix(), mrpt::math::CMatrixTemplate< TPoint3D >::insertMatrixTranspose(), mrpt::math::CMatrixTemplate< TPoint3D >::insertRow(), mrpt::math::CMatrixTemplate< TPoint3D >::IsSquare(), mrpt::math::CMatrixTemplate< TPoint3D >::operator()(), mrpt::math::CMatrixTemplate< TPoint3D >::operator=(), mrpt::math::CMatrixTemplate< TPoint3D >::realloc(), mrpt::math::CMatrixTemplate< TPoint3D >::removeColumns(), mrpt::math::CMatrixTemplate< TPoint3D >::swapCols(), and mrpt::math::CMatrixTemplate< TPoint3D >::swapRows().
T** mrpt::math::CMatrixTemplate< T >::m_Val [protected] |
Definition at line 80 of file CMatrixTemplate.h.
Referenced by mrpt::math::CMatrixTemplate< TPoint3D >::appendCol(), mrpt::math::CMatrixTemplate< TPoint3D >::appendRow(), mrpt::math::CMatrixTemplate< TPoint3D >::CMatrixTemplate(), mrpt::math::CMatrixTemplate< TPoint3D >::deleteColumn(), mrpt::math::CMatrixTemplate< TPoint3D >::deleteRow(), mrpt::math::CMatrixTemplate< TPoint3D >::exchangeColumns(), mrpt::math::CMatrixTemplate< TPoint3D >::exchangeRows(), mrpt::math::CMatrixTemplate< TPoint3D >::extractCol(), mrpt::math::CMatrixTemplate< TPoint3D >::extractRow(), mrpt::math::CMatrixTemplate< TPoint3D >::extractSubmatrix(), mrpt::math::CMatrixTemplate< TPoint3D >::fill(), mrpt::math::CMatrixTemplate< TPoint3D >::fromMatlabStringFormat(), mrpt::math::CMatrixTemplate< TPoint3D >::get_unsafe(), mrpt::math::CMatrixTemplate< TPoint3D >::get_unsafe_row(), mrpt::math::CMatrixTemplate< TPoint3D >::getAsVector(), mrpt::math::CMatrixTemplate< TPoint3D >::inMatlabFormat(), mrpt::math::CMatrixTemplate< TPoint3D >::insertCol(), mrpt::math::CMatrixTemplate< TPoint3D >::insertRow(), mrpt::math::CMatrixTemplate< TPoint3D >::operator()(), mrpt::math::CMatrixTemplateObjects< T >::operator=(), mrpt::math::CMatrixTemplate< TPoint3D >::operator=(), mrpt::math::CMatrixTemplate< TPoint3D >::realloc(), mrpt::math::CMatrixTemplate< TPoint3D >::removeColumns(), mrpt::math::CMatrixTemplate< TPoint3D >::set_unsafe(), mrpt::math::CMatrixTemplate< TPoint3D >::swapCols(), and mrpt::math::CMatrixTemplate< TPoint3D >::swapRows().
Page generated by Doxygen 1.5.9 for MRPT 0.7.1 SVN: at Mon Aug 17 22:20:53 EDT 2009 |