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:
Definition at line 47 of file CMatrixTemplateObjects.h.
#include <mrpt/math/CMatrixTemplateObjects.h>
Public Types | |
typedef T * | value_type |
The type of the matrix elements. More... | |
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. More... | |
CMatrixTemplateObjects (size_t row=3, size_t col=3) | |
Constructor. More... | |
virtual void | setSize (size_t row, size_t col) |
Changes the size of matrix. More... | |
virtual | ~CMatrixTemplateObjects () |
Destructor. More... | |
void | freeAllObjects () |
Delete all the objects in the matrix and set all entries to nullptr. More... | |
CMatrixTemplateObjects & | operator= (const CMatrixTemplateObjects &m) |
Assignment operator. More... | |
void | setDestroyBehavior (bool freeObjects=true) |
Sets the behavior on matrix destroy. More... | |
void | allocAllObjects () |
Alloc memory for all the non-NULL entries in the matrix. More... | |
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. More... | |
void | fillAll (const T * &val) |
void | swap (CMatrixTemplate< T * > &o) |
Swap with another matrix very efficiently (just swaps a pointer and two integer values). More... | |
size_t | getRowCount () const |
Number of rows in the matrix. More... | |
size_t | getColCount () const |
Number of columns in the matrix. More... | |
CMatrixTemplateSize | size () const |
Get a 2-vector with [NROWS NCOLS] (as in MATLAB command size(x)) More... | |
void | setSize (size_t row, size_t col, bool zeroNewElements=false) |
Changes the size of matrix, maintaining the previous contents. More... | |
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. More... | |
T * & | operator() (size_t row, size_t col) |
Subscript operator to get/set individual elements. More... | |
const T * & | operator() (size_t row, size_t col) const |
Subscript operator to get individual elements. More... | |
T * & | operator() (size_t ith) |
Subscript operator to get/set an individual element from a row or column matrix. More... | |
T * | operator() (size_t ith) const |
Subscript operator to get/set an individual element from a row or column matrix. More... | |
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. More... | |
void | set_unsafe (size_t row, size_t col, const T * &v) |
Fast but unsafe method to write a value in the matrix. More... | |
const T * & | get_unsafe (size_t row, size_t col) const |
Fast but unsafe method to read a value from the matrix. More... | |
T * & | get_unsafe (size_t row, size_t col) |
Fast but unsafe method to get a reference from the matrix. More... | |
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) More... | |
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) More... | |
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. More... | |
void | extractSubmatrix (const size_t row1, const size_t row2, const size_t col1, const size_t col2, EIGEN_MATRIX &out) const |
void | extractRows (size_t firstRow, size_t lastRow, CMatrixTemplate< T * > &out) const |
Gets a series of contiguous rows. More... | |
void | extractColumns (size_t firstCol, size_t lastCol, CMatrixTemplate< T * > &out) const |
Gets a series of contiguous columns. More... | |
void | extractCol (size_t nCol, std::vector< T * > &out, int startingRow=0) const |
Returns a given column to a vector (without modifying the matrix) More... | |
void | extractCol (size_t nCol, CMatrixTemplate< T * > &out, int startingRow=0) const |
Gets a given column to a vector (without modifying the matrix) More... | |
void | appendRow (const std::vector< T * > &in) |
Appends a new row to the MxN matrix from a 1xN vector. More... | |
void | appendCol (const std::vector< T * > &in) |
Appends a new column to the matrix from a vector. More... | |
void | insertCol (size_t nCol, const std::vector< T * > &in) |
Inserts a column from a vector, replacing the current contents of that column. More... | |
void | getAsVector (std::vector< T * > &out) const |
Returns a vector containing the matrix's values. More... | |
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. More... | |
Protected Attributes | |
T * ** | m_Val |
size_t | m_Rows |
size_t | m_Cols |
Private Attributes | |
bool | m_freeObjects |
|
inherited |
Definition at line 80 of file CMatrixTemplate.h.
|
inherited |
Definition at line 82 of file CMatrixTemplate.h.
|
inherited |
Definition at line 79 of file CMatrixTemplate.h.
|
inherited |
Definition at line 81 of file CMatrixTemplate.h.
|
inherited |
The type of the matrix elements.
Definition at line 78 of file CMatrixTemplate.h.
|
inline |
Copy constructor.
Definition at line 55 of file CMatrixTemplateObjects.h.
|
inline |
Constructor.
Definition at line 62 of file CMatrixTemplateObjects.h.
References getColCount(), and getRowCount().
|
inlinevirtual |
Destructor.
Definition at line 80 of file CMatrixTemplateObjects.h.
References mrpt::math::CMatrixTemplateObjects< T >::freeAllObjects(), and mrpt::math::CMatrixTemplateObjects< T >::m_freeObjects.
|
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 121 of file CMatrixTemplateObjects.h.
References getColCount(), and getRowCount().
|
inlineinherited |
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 654 of file CMatrixTemplate.h.
|
inlineinherited |
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.
std::exception | On incorrect vector length. |
Definition at line 625 of file CMatrixTemplate.h.
|
inlineinherited |
Checks whether the rows [r-N,r+N] and the columns [c-N,c+N] are present in the matrix.
Definition at line 153 of file CMatrixTemplate.h.
|
inlineinherited |
Returns a given column to a vector (without modifying the matrix)
std::exception | On index out of bounds |
Definition at line 579 of file CMatrixTemplate.h.
|
inlineinherited |
Gets a given column to a vector (without modifying the matrix)
std::exception | On index out of bounds |
Definition at line 596 of file CMatrixTemplate.h.
|
inlineinherited |
Gets a series of contiguous columns.
std::logic_error | On index out of bounds |
Definition at line 569 of file CMatrixTemplate.h.
|
inlineinherited |
Gets a series of contiguous rows.
std::logic_error | On index out of bounds |
Definition at line 557 of file CMatrixTemplate.h.
|
inlineinherited |
Get a submatrix, given its bounds.
Definition at line 513 of file CMatrixTemplate.h.
|
inlineinherited |
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 533 of file CMatrixTemplate.h.
|
inlineinherited |
Fill all the elements with a given value (Note: named "fillAll" since "fill" will be used by child classes)
Definition at line 163 of file CMatrixTemplate.h.
|
inline |
Delete all the objects in the matrix and set all entries to nullptr.
Definition at line 87 of file CMatrixTemplateObjects.h.
References getColCount(), and getRowCount().
Referenced by mrpt::math::CMatrixTemplateObjects< T >::~CMatrixTemplateObjects().
|
inlineinherited |
Fast but unsafe method to read a value from the matrix.
Definition at line 446 of file CMatrixTemplate.h.
|
inlineinherited |
Fast but unsafe method to get a reference from the matrix.
Definition at line 463 of file CMatrixTemplate.h.
|
inlineinherited |
Fast but unsafe method to obtain a pointer to a given row of the matrix (Use only in time critical applications)
Definition at line 481 of file CMatrixTemplate.h.
|
inlineinherited |
Fast but unsafe method to obtain a pointer to a given row of the matrix (Use only in critical applications)
Definition at line 498 of file CMatrixTemplate.h.
|
inlineinherited |
Returns a vector containing the matrix's values.
Definition at line 687 of file CMatrixTemplate.h.
|
inlineinherited |
Number of columns in the matrix.
Definition at line 307 of file CMatrixTemplate.h.
|
inlineinherited |
Number of rows in the matrix.
Definition at line 303 of file CMatrixTemplate.h.
|
inlineinherited |
Inserts a column from a vector, replacing the current contents of that column.
std::exception | On index out of bounds |
Definition at line 674 of file CMatrixTemplate.h.
|
inlineinherited |
Subscript operator to get/set individual elements.
Definition at line 333 of file CMatrixTemplate.h.
|
inlineinherited |
Subscript operator to get individual elements.
Definition at line 350 of file CMatrixTemplate.h.
|
inlineinherited |
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 369 of file CMatrixTemplate.h.
|
inlineinherited |
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 400 of file CMatrixTemplate.h.
|
inlineinherited |
Subscript operator to get a submatrix.
Definition at line 501 of file CMatrixTemplate.h.
|
inline |
Assignment operator.
Definition at line 100 of file CMatrixTemplateObjects.h.
References getColCount(), mrpt::math::CMatrixTemplate< T >::getColCount(), getRowCount(), mrpt::math::CMatrixTemplate< T >::getRowCount(), mrpt::math::CMatrixTemplate< T >::m_Val, and mrpt::math::CMatrixTemplate< T >::realloc().
|
inlineprotectedinherited |
Internal use only: It reallocs the memory for the 2D matrix, maintaining the previous contents if posible.
Definition at line 91 of file CMatrixTemplate.h.
|
inlineinherited |
This method just checks has no effects in this class, but raises an exception if the expected size does not match.
Definition at line 325 of file CMatrixTemplate.h.
|
inlineinherited |
Fast but unsafe method to write a value in the matrix.
Definition at line 429 of file CMatrixTemplate.h.
|
inline |
Sets the behavior on matrix destroy.
See the general description of the class on the top.
Definition at line 113 of file CMatrixTemplateObjects.h.
References mrpt::math::CMatrixTemplateObjects< T >::m_freeObjects.
|
inlinevirtual |
Changes the size of matrix.
Definition at line 72 of file CMatrixTemplateObjects.h.
References mrpt::math::CMatrixTemplate< T >::realloc().
|
inlineinherited |
Changes the size of matrix, maintaining the previous contents.
Definition at line 318 of file CMatrixTemplate.h.
|
inlineinherited |
Get a 2-vector with [NROWS NCOLS] (as in MATLAB command size(x))
Definition at line 309 of file CMatrixTemplate.h.
|
inlineinherited |
Swap with another matrix very efficiently (just swaps a pointer and two integer values).
Definition at line 171 of file CMatrixTemplate.h.
|
protectedinherited |
Definition at line 86 of file CMatrixTemplate.h.
|
private |
Definition at line 50 of file CMatrixTemplateObjects.h.
Referenced by mrpt::math::CMatrixTemplateObjects< T >::setDestroyBehavior(), and mrpt::math::CMatrixTemplateObjects< T >::~CMatrixTemplateObjects().
|
protectedinherited |
Definition at line 86 of file CMatrixTemplate.h.
|
protectedinherited |
Definition at line 85 of file CMatrixTemplate.h.
Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019 |