MRPT
1.9.9
|
This template class provides the basic functionality for a general 2D any-size, resizable container of numerical or non-numerical elements.
NOTES:
Definition at line 70 of file CMatrixTemplate.h.
#include <mrpt/math/CMatrixTemplate.h>
Public Types | |
using | value_type = T |
The type of the matrix elements. More... | |
using | reference = T & |
using | const_reference = const T & |
using | size_type = std::size_t |
using | difference_type = std::ptrdiff_t |
Public Member Functions | |
template<size_t N> | |
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... | |
CMatrixTemplate (const CMatrixTemplate &m) | |
Constructors. More... | |
CMatrixTemplate (size_t row=1, size_t col=1) | |
CMatrixTemplate (const CMatrixTemplate &m, const size_t cropRowCount, const size_t cropColCount) | |
Copy constructor & crop from another matrix. More... | |
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. More... | |
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,...) with the initial values. More... | |
virtual | ~CMatrixTemplate () |
Destructor. More... | |
CMatrixTemplate & | operator= (const CMatrixTemplate &m) |
Assignment operator from another matrix. More... | |
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) More... | |
size_t | rows () const |
Number of rows in the matrix. More... | |
size_t | cols () 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... | |
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... | |
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 | 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... | |
template<class EIGEN_MATRIX > | |
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 |
using mrpt::math::CMatrixTemplate< T >::const_reference = const T& |
Definition at line 77 of file CMatrixTemplate.h.
using mrpt::math::CMatrixTemplate< T >::difference_type = std::ptrdiff_t |
Definition at line 79 of file CMatrixTemplate.h.
using mrpt::math::CMatrixTemplate< T >::reference = T& |
Definition at line 76 of file CMatrixTemplate.h.
using mrpt::math::CMatrixTemplate< T >::size_type = std::size_t |
Definition at line 78 of file CMatrixTemplate.h.
using mrpt::math::CMatrixTemplate< T >::value_type = T |
The type of the matrix elements.
Definition at line 75 of file CMatrixTemplate.h.
|
inline |
Constructors.
Definition at line 172 of file CMatrixTemplate.h.
|
inline |
Definition at line 178 of file CMatrixTemplate.h.
|
inline |
Copy constructor & crop from another matrix.
Definition at line 186 of file CMatrixTemplate.h.
|
inline |
Constructor from a given size and a C array.
The array length must match cols x row.
Definition at line 208 of file CMatrixTemplate.h.
|
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 232 of file CMatrixTemplate.h.
|
inlinevirtual |
Destructor.
Definition at line 252 of file CMatrixTemplate.h.
|
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 647 of file CMatrixTemplate.h.
Referenced by mrpt::opengl::CGeneralizedCylinder::getClosedSection().
|
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.
std::exception | On incorrect vector length. |
Definition at line 618 of file CMatrixTemplate.h.
|
inline |
Checks whether the rows [r-N,r+N] and the columns [c-N,c+N] are present in the matrix.
Definition at line 148 of file CMatrixTemplate.h.
|
inline |
Number of columns in the matrix.
Definition at line 300 of file CMatrixTemplate.h.
Referenced by mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::ASSERT_ENOUGHROOM(), mrpt::detectors::CFaceDetection::checkIfFaceRegions(), mrpt::vision::generateMask(), mrpt::opengl::CGeneralizedCylinder::getClosedSection(), and mrpt::math::CMatrixTemplateObjects< T >::operator=().
|
inline |
Returns a given column to a vector (without modifying the matrix)
std::exception | On index out of bounds |
Definition at line 572 of file CMatrixTemplate.h.
Referenced by mrpt::opengl::CGeneralizedCylinder::getClosedSection().
|
inline |
Gets a given column to a vector (without modifying the matrix)
std::exception | On index out of bounds |
Definition at line 589 of file CMatrixTemplate.h.
|
inline |
Gets a series of contiguous columns.
std::logic_error | On index out of bounds |
Definition at line 562 of file CMatrixTemplate.h.
|
inline |
Gets a series of contiguous rows.
std::logic_error | On index out of bounds |
Definition at line 550 of file CMatrixTemplate.h.
|
inline |
Get a submatrix, given its bounds.
Definition at line 506 of file CMatrixTemplate.h.
Referenced by mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::operator()().
|
inline |
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 526 of file CMatrixTemplate.h.
|
inline |
Fill all the elements with a given value (Note: named "fillAll" since "fill" will be used by child classes)
Definition at line 156 of file CMatrixTemplate.h.
Referenced by mrpt::vision::CFeatureExtraction::extractFeaturesFAST(), mrpt::vision::CFeatureExtraction::extractFeaturesFASTER_N(), mrpt::vision::CFeatureExtraction::extractFeaturesORB(), and mrpt::vision::detail::trackFeatures_addNewFeats_simple_list().
|
inline |
Fast but unsafe method to read a value from the matrix.
Definition at line 439 of file CMatrixTemplate.h.
Referenced by mrpt::detectors::CFaceDetection::checkIfDiagonalSurface(), mrpt::detectors::CFaceDetection::checkIfDiagonalSurface2(), mrpt::detectors::CFaceDetection::checkIfFacePlaneCov(), mrpt::detectors::CFaceDetection::checkIfFaceRegions(), mrpt::detectors::CFaceDetection::experimental_calcHist(), mrpt::detectors::CFaceDetection::experimental_segmentFace(), and mrpt::vision::detail::trackFeatures_addNewFeats_simple_list().
|
inline |
Fast but unsafe method to get a reference from the matrix.
Definition at line 456 of file CMatrixTemplate.h.
|
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 474 of file CMatrixTemplate.h.
|
inline |
Fast but unsafe method to obtain a pointer to a given row of the matrix (Use only in critical applications)
Definition at line 491 of file CMatrixTemplate.h.
|
inline |
Returns a vector containing the matrix's values.
Definition at line 680 of file CMatrixTemplate.h.
Referenced by mrpt::opengl::CGeneralizedCylinder::getClosedSection().
|
inline |
Inserts a column from a vector, replacing the current contents of that column.
std::exception | On index out of bounds |
Definition at line 667 of file CMatrixTemplate.h.
|
inline |
Subscript operator to get/set individual elements.
Definition at line 326 of file CMatrixTemplate.h.
|
inline |
Subscript operator to get individual elements.
Definition at line 343 of file CMatrixTemplate.h.
|
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 362 of file CMatrixTemplate.h.
|
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 393 of file CMatrixTemplate.h.
|
inline |
Subscript operator to get a submatrix.
Definition at line 494 of file CMatrixTemplate.h.
|
inline |
Assignment operator from another matrix.
Definition at line 254 of file CMatrixTemplate.h.
Referenced by mrpt::math::CMatrixBool::operator=().
|
inline |
Assignment operator for initializing from a C array (The matrix must be set to the correct size before invoking this asignament)
Refer also to the constructor with initialization data CMatrixTemplate::CMatrixTemplate
Definition at line 275 of file CMatrixTemplate.h.
|
inlineprotected |
Internal use only: It reallocs the memory for the 2D matrix, maintaining the previous contents if posible.
Definition at line 88 of file CMatrixTemplate.h.
Referenced by mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::appendCol(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::appendRow(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::CMatrixTemplate(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::extractSubmatrix(), mrpt::math::CMatrixTemplateObjects< T >::operator=(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::operator=(), mrpt::math::CMatrixTemplateObjects< T >::setSize(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::setSize(), and mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::~CMatrixTemplate().
|
inline |
This method just checks has no effects in this class, but raises an exception if the expected size does not match.
Definition at line 318 of file CMatrixTemplate.h.
|
inline |
Number of rows in the matrix.
Definition at line 296 of file CMatrixTemplate.h.
Referenced by mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::ASSERT_ENOUGHROOM(), mrpt::detectors::CFaceDetection::checkIfFaceRegions(), mrpt::vision::generateMask(), mrpt::opengl::CGeneralizedCylinder::getClosedSection(), and mrpt::math::CMatrixTemplateObjects< T >::operator=().
|
inline |
Fast but unsafe method to write a value in the matrix.
Definition at line 422 of file CMatrixTemplate.h.
Referenced by mrpt::detectors::CFaceDetection::checkIfDiagonalSurface(), mrpt::detectors::CFaceDetection::experimental_calcHist(), mrpt::detectors::CFaceDetection::experimental_segmentFace(), mrpt::vision::CFeatureExtraction::extractFeaturesFAST(), mrpt::vision::CFeatureExtraction::extractFeaturesFASTER_N(), mrpt::vision::CFeatureExtraction::extractFeaturesORB(), and mrpt::vision::generateMask().
|
inline |
Changes the size of matrix, maintaining the previous contents.
Definition at line 311 of file CMatrixTemplate.h.
Referenced by mrpt::detectors::CFaceDetection::checkIfDiagonalSurface(), mrpt::detectors::CFaceDetection::checkIfFaceRegions(), mrpt::slam::TDataAssociationResults::clear(), mrpt::detectors::CFaceDetection::experimental_segmentFace(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::extractCol(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::extractColumns(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::extractRows(), mrpt::hwdrivers::CRoboticHeadInterface::Get3SoundBuffer(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::resize(), and mrpt::vision::detail::trackFeatures_addNewFeats_simple_list().
|
inline |
Get a 2-vector with [NROWS NCOLS] (as in MATLAB command size(x))
Definition at line 302 of file CMatrixTemplate.h.
|
inline |
Swap with another matrix very efficiently (just swaps a pointer and two integer values).
Definition at line 164 of file CMatrixTemplate.h.
|
protected |
Definition at line 83 of file CMatrixTemplate.h.
Referenced by mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::appendCol(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::appendRow(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::CMatrixTemplate(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::cols(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::extractCol(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::extractRows(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::extractSubmatrix(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::fillAll(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::get_unsafe(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::get_unsafe_row(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::getAsVector(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::insertCol(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::operator()(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::operator=(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::realloc(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::set_unsafe(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::size(), and mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::swap().
|
protected |
Definition at line 83 of file CMatrixTemplate.h.
Referenced by mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::appendCol(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::appendRow(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::CMatrixTemplate(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::extractCol(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::extractColumns(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::extractSubmatrix(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::fillAll(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::get_unsafe(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::get_unsafe_row(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::getAsVector(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::insertCol(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::operator()(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::operator=(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::realloc(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::rows(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::set_unsafe(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::size(), and mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::swap().
|
protected |
Definition at line 82 of file CMatrixTemplate.h.
Referenced by mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::appendCol(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::appendRow(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::CMatrixTemplate(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::extractCol(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::extractSubmatrix(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::fillAll(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::get_unsafe(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::get_unsafe_row(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::getAsVector(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::insertCol(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::operator()(), mrpt::math::CMatrixTemplateObjects< T >::operator=(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::operator=(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::realloc(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::set_unsafe(), and mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::swap().
Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020 |