This template class extends the class "CMatrixTemplate" for storing "objects" at each matrix entry.
This class allows a very efficient representation of sparse matrixes where each cell is an arbitrary C++ class, but its use must carefully observe the following rules:
#include <mrpt/math/CMatrixTemplateObjects.h>

Public Types | |||
| typedef T | value_type | ||
| The type of the matrix elements. | |||
| typedef T & | reference | ||
| typedef const T & | const_reference | ||
| typedef std::size_t | size_type | ||
| typedef std::ptrdiff_t | difference_type | ||
Public Member Functions | |||
| CMatrixTemplateObjects (const CMatrixTemplate< T > &m) | |||
| Copy constructor. | |||
| CMatrixTemplateObjects (size_t row=3, size_t col=3) | |||
| Constructor. | |||
| virtual void | setSize (size_t row, size_t col) | ||
| Changes the size of matrix. | |||
| virtual | ~CMatrixTemplateObjects () | ||
| Destructor. | |||
| void | freeAllObjects () | ||
| Delete all the objects in the matrix and set all entries to NULL pointers. | |||
| CMatrixTemplateObjects & | operator= (const CMatrixTemplateObjects &m) | ||
| Assignment operator. | |||
| void | setDestroyBehavior (bool freeObjects=true) | ||
| Sets the behavior on matrix destroy. | |||
| void | allocAllObjects () | ||
| Alloc memory for all the non-NULL entries in the matrix. | |||
| void | ASSERT_ENOUGHROOM (size_t r, size_t c) const | ||
| Checks whether the rows [r-N,r+N] and the columns [c-N,c+N] are present in the matrix. | |||
| void | fillAll (const T &val) | ||
| void | swap (CMatrixTemplate< T > &o) | ||
| Swap with another matrix very efficiently (just swaps a pointer and two integer values). | |||
| size_t | getRowCount () const | ||
| Number of rows in the matrix. | |||
| size_t | getColCount () const | ||
| Number of columns in the matrix. | |||
| CMatrixTemplateSize | size () const | ||
| Get a 2-vector with [NROWS NCOLS] (as in MATLAB command size(x)) | |||
| void | setSize (size_t row, size_t col, bool zeroNewElements=false) | ||
| Changes the size of matrix, maintaining the previous contents. | |||
| void | resize (const CMatrixTemplateSize &siz, bool zeroNewElements=false) | ||
| This method just checks has no effects in this class, but raises an exception if the expected size does not match. | |||
| T & | operator() (size_t row, size_t col) | ||
| Subscript operator to get/set individual elements. | |||
| const T & | operator() (size_t row, size_t col) const | ||
| Subscript operator to get 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. | |||
| 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 | set_unsafe (size_t row, size_t col, const T &v) | ||
| Fast but unsafe method to write a value in the matrix. | |||
| const 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) | ||
| Fast but unsafe method to obtain a pointer to a given row of the matrix (Use only in time critical applications) | |||
| const 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 critical applications) | |||
| 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. | |||
| void | extractSubmatrix (const size_t row1, const size_t row2, const size_t col1, const size_t col2, Eigen::MatrixBase< Derived > &out) const | ||
| 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 | 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 | 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. | |||
| void | getAsVector (std::vector< T > &out) const | ||
| Returns a vector containing the matrix's values. | |||
Protected Member Functions | |||
| void | realloc (size_t row, size_t col, bool newElementsToZero=false) | ||
| Internal use only: It reallocs 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 | ||
Private Attributes | |||
| bool | m_freeObjects | ||
typedef const T& mrpt::math::CMatrixTemplate::const_reference [inherited] |
Definition at line 66 of file CMatrixTemplate.h.
typedef std::ptrdiff_t mrpt::math::CMatrixTemplate::difference_type [inherited] |
Definition at line 68 of file CMatrixTemplate.h.
typedef T& mrpt::math::CMatrixTemplate::reference [inherited] |
Definition at line 65 of file CMatrixTemplate.h.
typedef std::size_t mrpt::math::CMatrixTemplate::size_type [inherited] |
Definition at line 67 of file CMatrixTemplate.h.
typedef T mrpt::math::CMatrixTemplate::value_type [inherited] |
The type of the matrix elements.
Definition at line 64 of file CMatrixTemplate.h.
| mrpt::math::CMatrixTemplateObjects::CMatrixTemplateObjects | ( | const CMatrixTemplate< T > & | m | ) | [inline] |
Copy constructor.
Definition at line 59 of file CMatrixTemplateObjects.h.
| mrpt::math::CMatrixTemplateObjects::CMatrixTemplateObjects | ( | size_t | row = 3, |
| size_t | col = 3 |
||
| ) | [inline] |
Constructor.
Definition at line 65 of file CMatrixTemplateObjects.h.
References getRowCount(), and getColCount().
| virtual mrpt::math::CMatrixTemplateObjects::~CMatrixTemplateObjects | ( | ) | [inline, virtual] |
Destructor.
Definition at line 82 of file CMatrixTemplateObjects.h.
References m_freeObjects, and freeAllObjects().
| void mrpt::math::CMatrixTemplateObjects::allocAllObjects | ( | ) | [inline] |
Alloc memory for all the non-NULL entries in the matrix.
See the general description of the class on the top.
Definition at line 124 of file CMatrixTemplateObjects.h.
References getRowCount(), and getColCount().
| void mrpt::math::CMatrixTemplate::appendCol | ( | const std::vector< T > & | in | ) | [inline, inherited] |
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 538 of file CMatrixTemplate.h.
| void mrpt::math::CMatrixTemplate::appendRow | ( | const std::vector< T > & | in | ) | [inline, inherited] |
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 509 of file CMatrixTemplate.h.
| void mrpt::math::CMatrixTemplate::ASSERT_ENOUGHROOM | ( | size_t | r, |
| size_t | c | ||
| ) | const [inline, inherited] |
Checks whether the rows [r-N,r+N] and the columns [c-N,c+N] are present in the matrix.
Definition at line 127 of file CMatrixTemplate.h.
| void mrpt::math::CMatrixTemplate::extractCol | ( | size_t | nCol, |
| std::vector< T > & | out, | ||
| int | startingRow = 0 |
||
| ) | const [inline, inherited] |
Returns a given column to a vector (without modifying the matrix)
| std::exception | On index out of bounds. |
Definition at line 463 of file CMatrixTemplate.h.
| void mrpt::math::CMatrixTemplate::extractCol | ( | size_t | nCol, |
| CMatrixTemplate< T > & | out, | ||
| int | startingRow = 0 |
||
| ) | const [inline, inherited] |
Gets a given column to a vector (without modifying the matrix)
| std::exception | On index out of bounds. |
Definition at line 481 of file CMatrixTemplate.h.
| void mrpt::math::CMatrixTemplate::extractColumns | ( | size_t | firstCol, |
| size_t | lastCol, | ||
| CMatrixTemplate< T > & | out | ||
| ) | const [inline, inherited] |
Gets a series of contiguous columns.
| std::logic_error | On index out of bounds |
Definition at line 455 of file CMatrixTemplate.h.
| void mrpt::math::CMatrixTemplate::extractRows | ( | size_t | firstRow, |
| size_t | lastRow, | ||
| CMatrixTemplate< T > & | out | ||
| ) | const [inline, inherited] |
Gets a series of contiguous rows.
| std::logic_error | On index out of bounds |
Definition at line 445 of file CMatrixTemplate.h.
| void mrpt::math::CMatrixTemplate::extractSubmatrix | ( | const size_t | row1, |
| const size_t | row2, | ||
| const size_t | col1, | ||
| const size_t | col2, | ||
| CMatrixTemplate< T > & | out | ||
| ) | const [inline, inherited] |
Get a submatrix, given its bounds.
Definition at line 412 of file CMatrixTemplate.h.
| void mrpt::math::CMatrixTemplate::extractSubmatrix | ( | const size_t | row1, |
| const size_t | row2, | ||
| const size_t | col1, | ||
| const size_t | col2, | ||
| Eigen::MatrixBase< Derived > & | out | ||
| ) | const [inline, inherited] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 426 of file CMatrixTemplate.h.
| void mrpt::math::CMatrixTemplate::fillAll | ( | const T & | val | ) | [inline, inherited] |
Fill all the elements with a given value (Note: named "fillAll" since "fill" will be used by child classes)
Definition at line 133 of file CMatrixTemplate.h.
| void mrpt::math::CMatrixTemplateObjects::freeAllObjects | ( | ) | [inline] |
Delete all the objects in the matrix and set all entries to NULL pointers.
Definition at line 90 of file CMatrixTemplateObjects.h.
References getRowCount(), and getColCount().
Referenced by ~CMatrixTemplateObjects().
| const T& mrpt::math::CMatrixTemplate::get_unsafe | ( | size_t | row, |
| size_t | col | ||
| ) | const [inline, inherited] |
Fast but unsafe method to read a value from the matrix.
Definition at line 364 of file CMatrixTemplate.h.
| T& mrpt::math::CMatrixTemplate::get_unsafe | ( | size_t | row, |
| size_t | col | ||
| ) | [inline, inherited] |
Fast but unsafe method to get a reference from the matrix.
Definition at line 375 of file CMatrixTemplate.h.
| T* mrpt::math::CMatrixTemplate::get_unsafe_row | ( | size_t | row | ) | [inline, inherited] |
Fast but unsafe method to obtain a pointer to a given row of the matrix (Use only in time critical applications)
Definition at line 386 of file CMatrixTemplate.h.
| const T* mrpt::math::CMatrixTemplate::get_unsafe_row | ( | size_t | row | ) | const [inline, inherited] |
Fast but unsafe method to obtain a pointer to a given row of the matrix (Use only in critical applications)
Definition at line 397 of file CMatrixTemplate.h.
| void mrpt::math::CMatrixTemplate::getAsVector | ( | std::vector< T > & | out | ) | const [inline, inherited] |
Returns a vector containing the matrix's values.
Definition at line 566 of file CMatrixTemplate.h.
| size_t mrpt::math::CMatrixTemplate::getColCount | ( | ) | const [inline, inherited] |
Number of columns in the matrix.
Definition at line 250 of file CMatrixTemplate.h.
| size_t mrpt::math::CMatrixTemplate::getRowCount | ( | ) | const [inline, inherited] |
Number of rows in the matrix.
Definition at line 245 of file CMatrixTemplate.h.
| void mrpt::math::CMatrixTemplate::insertCol | ( | size_t | nCol, |
| const std::vector< T > & | in | ||
| ) | [inline, inherited] |
Inserts a column from a vector, replacing the current contents of that column.
| std::exception | On index out of bounds |
Definition at line 553 of file CMatrixTemplate.h.
| T& mrpt::math::CMatrixTemplate::operator() | ( | size_t | row, |
| size_t | col | ||
| ) | [inline, inherited] |
Subscript operator to get/set individual elements.
Definition at line 275 of file CMatrixTemplate.h.
| const T& mrpt::math::CMatrixTemplate::operator() | ( | size_t | row, |
| size_t | col | ||
| ) | const [inline, inherited] |
Subscript operator to get individual elements.
Definition at line 286 of file CMatrixTemplate.h.
| T& mrpt::math::CMatrixTemplate::operator() | ( | size_t | ith | ) | [inline, inherited] |
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 298 of file CMatrixTemplate.h.
| T mrpt::math::CMatrixTemplate::operator() | ( | size_t | ith | ) | const [inline, inherited] |
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 326 of file CMatrixTemplate.h.
| CMatrixTemplate<T> mrpt::math::CMatrixTemplate::operator() | ( | const size_t | row1, |
| const size_t | row2, | ||
| const size_t | col1, | ||
| const size_t | col2 | ||
| ) | const [inline, inherited] |
Subscript operator to get a submatrix.
Definition at line 403 of file CMatrixTemplate.h.
| CMatrixTemplateObjects& mrpt::math::CMatrixTemplateObjects::operator= | ( | const CMatrixTemplateObjects & | m | ) | [inline] |
Assignment operator.
Definition at line 103 of file CMatrixTemplateObjects.h.
References mrpt::math::CMatrixTemplate< T * >::realloc(), getRowCount(), and getColCount().
| void mrpt::math::CMatrixTemplate::realloc | ( | size_t | row, |
| size_t | col, | ||
| bool | newElementsToZero = false |
||
| ) | [inline, protected, inherited] |
Internal use only: It reallocs the memory for the 2D matrix, maintaining the previous contents if posible.
Definition at line 77 of file CMatrixTemplate.h.
Referenced by setSize(), and operator=().
| void mrpt::math::CMatrixTemplate::resize | ( | const CMatrixTemplateSize & | siz, |
| bool | zeroNewElements = false |
||
| ) | [inline, inherited] |
This method just checks has no effects in this class, but raises an exception if the expected size does not match.
Definition at line 268 of file CMatrixTemplate.h.
| void mrpt::math::CMatrixTemplate::set_unsafe | ( | size_t | row, |
| size_t | col, | ||
| const T & | v | ||
| ) | [inline, inherited] |
Fast but unsafe method to write a value in the matrix.
Definition at line 353 of file CMatrixTemplate.h.
| void mrpt::math::CMatrixTemplateObjects::setDestroyBehavior | ( | bool | freeObjects = true | ) | [inline] |
Sets the behavior on matrix destroy.
See the general description of the class on the top.
Definition at line 116 of file CMatrixTemplateObjects.h.
References m_freeObjects.
| virtual void mrpt::math::CMatrixTemplateObjects::setSize | ( | size_t | row, |
| size_t | col | ||
| ) | [inline, virtual] |
Changes the size of matrix.
Definition at line 74 of file CMatrixTemplateObjects.h.
References mrpt::math::CMatrixTemplate< T * >::realloc().
| void mrpt::math::CMatrixTemplate::setSize | ( | size_t | row, |
| size_t | col, | ||
| bool | zeroNewElements = false |
||
| ) | [inline, inherited] |
Changes the size of matrix, maintaining the previous contents.
Definition at line 262 of file CMatrixTemplate.h.
| CMatrixTemplateSize mrpt::math::CMatrixTemplate::size | ( | ) | const [inline, inherited] |
Get a 2-vector with [NROWS NCOLS] (as in MATLAB command size(x))
Definition at line 253 of file CMatrixTemplate.h.
| void mrpt::math::CMatrixTemplate::swap | ( | CMatrixTemplate< T > & | o | ) | [inline, inherited] |
Swap with another matrix very efficiently (just swaps a pointer and two integer values).
Definition at line 140 of file CMatrixTemplate.h.
size_t mrpt::math::CMatrixTemplate::m_Cols [protected, inherited] |
Definition at line 73 of file CMatrixTemplate.h.
bool mrpt::math::CMatrixTemplateObjects::m_freeObjects [private] |
Definition at line 54 of file CMatrixTemplateObjects.h.
Referenced by ~CMatrixTemplateObjects(), and setDestroyBehavior().
size_t mrpt::math::CMatrixTemplate::m_Rows [protected, inherited] |
Definition at line 73 of file CMatrixTemplate.h.
T** mrpt::math::CMatrixTemplate::m_Val [protected, inherited] |
Definition at line 72 of file CMatrixTemplate.h.
| Page generated by Doxygen 1.7.5 for MRPT 0.9.5 SVN: at Thu Oct 13 21:25:36 UTC 2011 |