| 
    MRPT
    2.0.0
    
   | 
 
A sparse matrix container (with cells of any type), with iterators.
This class stores only those elements created by assigning them a value, for example: "M(2,3)=8;".
This class doesn't implement math operations since it's a generic sparse container, but it can be used to initialize the contents of a CSparse library-based matrix of type mrpt::math::CSparseMatrix.
Note that reading non-existing cell elements will return the default value (0 for numbers) and that cell will remain non-created in the matrix.
There is an additional method "exists(i,j)" to check whether a given element exists in the matrix.
Definition at line 40 of file CSparseMatrixTemplate.h.
#include <mrpt/math/CSparseMatrixTemplate.h>
Public Types | |
| using | SparseMatrixMap = typename std::map< std::pair< size_t, size_t >, T > | 
| Internal map type, used to store the actual matrix.  More... | |
| using | const_iterator = typename SparseMatrixMap::const_iterator | 
| Const iterator to move through the matrix.  More... | |
| using | const_reverse_iterator = typename SparseMatrixMap::const_reverse_iterator | 
| Const reverse iterator to move through the matrix.  More... | |
Public Member Functions | |
| CSparseMatrixTemplate ()=default | |
| Basic constructor with no data.  More... | |
| CSparseMatrixTemplate (size_t nR, size_t nC) | |
| Constructor with default size.  More... | |
| T | operator() (size_t r, size_t c) const | 
| Element access operator.  More... | |
| bool | exists (size_t r, size_t c) const | 
| Element access operator.  More... | |
| T & | operator() (size_t r, size_t c) | 
| Reference access operator.  More... | |
| size_t | rows () const | 
| Returns the amount of rows in this matrix.  More... | |
| size_t | cols () const | 
| Returns the amount of columns in this matrix.  More... | |
| template<typename VECTOR > | |
| void | getRow (size_t nRow, VECTOR &vec) const | 
| Extracts a full row from the matrix.  More... | |
| template<typename VECTOR > | |
| void | getColumn (size_t nCol, VECTOR &vec) const | 
| Extracts a full column from the matrix.  More... | |
| void | insert (size_t row, size_t column, const T &obj) | 
| Inserts an element into the matrix.  More... | |
| template<class MATRIX_LIKE > | |
| void | insertMatrix (size_t row, size_t column, const MATRIX_LIKE &mat) | 
| Inserts submatrix at a given location.  More... | |
| const_iterator | begin () const | 
| Returns an iterator which points to the starting point of the matrix.  More... | |
| const_iterator | end () const | 
| Returns an iterator which points to the end of the matrix.  More... | |
| const_reverse_iterator | rbegin () const | 
| Returns an iterator which points to the end of the matrix, and can be used to move backwards.  More... | |
| const_reverse_iterator | rend () const | 
| Returns an iterator which points to the starting point of the matrix, although it's the upper limit of the matrix since it's a reverse iterator.  More... | |
| template<typename VECTOR > | |
| void | setRow (size_t nRow, const VECTOR &vec, const T &nullObject=T()) | 
| Inserts a full row into the matrix.  More... | |
| template<typename VECTOR > | |
| void | setColumn (size_t nCol, const VECTOR &vec, const T &nullObject=T()) | 
| Inserts a full column into the matrix.  More... | |
| void | resize (size_t nRows, size_t nCols) | 
| Changes the size of the matrix.  More... | |
| CSparseMatrixTemplate< T > | operator() (size_t firstRow, size_t lastRow, size_t firstColumn, size_t lastColumn) const | 
| Extracts a submatrix form the matrix.  More... | |
| template<typename VECTOR > | |
| void | asVector (VECTOR &vec) const | 
| Gets a vector containing all the elements of the matrix, ignoring their position.  More... | |
| size_t | getNonNullElements () const | 
| Gets the amount of non-null elements inside the matrix.  More... | |
| bool | empty () const | 
| Are there no elements set to !=0 ?  More... | |
| size_t | getNullElements () const | 
| Gets the amount of null elements inside the matrix.  More... | |
| bool | isNull (size_t nRow, size_t nCol) const | 
| Checks whether an element of the matrix is the default object.  More... | |
| bool | isNotNull (size_t nRow, size_t nCol) const | 
| Checks whether an element of the matrix is not the default object.  More... | |
| void | clear () | 
| Completely removes all elements, although maintaining the matrix's size.  More... | |
| void | purge (T nullObject=T()) | 
| Checks each non-null elements against the basic objects, erasing unnecesary references to it.  More... | |
Protected Attributes | |
| size_t | mRows {0} | 
| Size of the matrix.  More... | |
| size_t | mColumns {0} | 
| SparseMatrixMap | objectList | 
| Actual matrix.  More... | |
| using mrpt::math::CSparseMatrixTemplate< T >::const_iterator = typename SparseMatrixMap::const_iterator | 
Const iterator to move through the matrix.
Definition at line 52 of file CSparseMatrixTemplate.h.
| using mrpt::math::CSparseMatrixTemplate< T >::const_reverse_iterator = typename SparseMatrixMap::const_reverse_iterator | 
Const reverse iterator to move through the matrix.
Definition at line 58 of file CSparseMatrixTemplate.h.
| using mrpt::math::CSparseMatrixTemplate< T >::SparseMatrixMap = typename std::map<std::pair<size_t, size_t>, T> | 
Internal map type, used to store the actual matrix.
Definition at line 47 of file CSparseMatrixTemplate.h.
      
  | 
  default | 
Basic constructor with no data.
Size is set to (0,0).
      
  | 
  inline | 
Constructor with default size.
Definition at line 78 of file CSparseMatrixTemplate.h.
      
  | 
  inline | 
Gets a vector containing all the elements of the matrix, ignoring their position.
Definition at line 330 of file CSparseMatrixTemplate.h.
References mrpt::math::CSparseMatrixTemplate< T >::objectList.
      
  | 
  inline | 
Returns an iterator which points to the starting point of the matrix.
It's a const_iterator, so that the usar isn't able to modify the matrix content into an invalid state.
Definition at line 205 of file CSparseMatrixTemplate.h.
References mrpt::math::CSparseMatrixTemplate< T >::objectList.
Referenced by mrpt::math::CSparseMatrixTemplate< T >::operator()(), and mrpt::math::CSparseMatrixTemplate< T >::purge().
      
  | 
  inline | 
Completely removes all elements, although maintaining the matrix's size.
Definition at line 380 of file CSparseMatrixTemplate.h.
References mrpt::math::CSparseMatrixTemplate< T >::objectList.
Referenced by mrpt::math::intersect().
      
  | 
  inline | 
Returns the amount of columns in this matrix.
Definition at line 120 of file CSparseMatrixTemplate.h.
References mrpt::math::CSparseMatrixTemplate< T >::mColumns.
Referenced by depthFirstSearch(), and mrpt::math::intersect().
      
  | 
  inline | 
Are there no elements set to !=0 ?
Definition at line 347 of file CSparseMatrixTemplate.h.
References mrpt::math::CSparseMatrixTemplate< T >::objectList.
      
  | 
  inline | 
Returns an iterator which points to the end of the matrix.
It's a const_iterator, so that the usar isn't able to modify the matrix content into an invalid state.
Definition at line 212 of file CSparseMatrixTemplate.h.
References mrpt::math::CSparseMatrixTemplate< T >::objectList.
Referenced by mrpt::math::CSparseMatrixTemplate< T >::operator()(), mrpt::math::CSparseSymmetricalMatrix< T >::operator()(), and mrpt::math::CSparseMatrixTemplate< T >::purge().
      
  | 
  inline | 
Element access operator.
Checks bounds.
Definition at line 93 of file CSparseMatrixTemplate.h.
References mrpt::math::CSparseMatrixTemplate< T >::mColumns, mrpt::math::CSparseMatrixTemplate< T >::mRows, and mrpt::math::CSparseMatrixTemplate< T >::objectList.
      
  | 
  inline | 
Extracts a full column from the matrix.
| std::logic_error | on out of range. | 
Definition at line 159 of file CSparseMatrixTemplate.h.
References mrpt::math::CSparseMatrixTemplate< T >::mColumns, mrpt::math::CSparseMatrixTemplate< T >::mRows, and mrpt::math::CSparseMatrixTemplate< T >::objectList.
      
  | 
  inline | 
Gets the amount of non-null elements inside the matrix.
Definition at line 343 of file CSparseMatrixTemplate.h.
References mrpt::math::CSparseMatrixTemplate< T >::objectList.
Referenced by mrpt::math::CSparseMatrixTemplate< T >::getNullElements(), and mrpt::math::intersect().
      
  | 
  inline | 
Gets the amount of null elements inside the matrix.
Definition at line 352 of file CSparseMatrixTemplate.h.
References mrpt::math::CSparseMatrixTemplate< T >::getNonNullElements(), mrpt::math::CSparseMatrixTemplate< T >::mColumns, and mrpt::math::CSparseMatrixTemplate< T >::mRows.
      
  | 
  inline | 
Extracts a full row from the matrix.
| std::logic_error | on out of range. | 
Definition at line 127 of file CSparseMatrixTemplate.h.
References mrpt::math::CSparseMatrixTemplate< T >::mColumns, mrpt::math::CSparseMatrixTemplate< T >::mRows, and mrpt::math::CSparseMatrixTemplate< T >::objectList.
      
  | 
  inline | 
Inserts an element into the matrix.
Definition at line 183 of file CSparseMatrixTemplate.h.
References mrpt::math::CSparseMatrixTemplate< T >::operator()().
      
  | 
  inline | 
Inserts submatrix at a given location.
Definition at line 190 of file CSparseMatrixTemplate.h.
      
  | 
  inline | 
Checks whether an element of the matrix is not the default object.
Definition at line 371 of file CSparseMatrixTemplate.h.
References mrpt::math::CSparseMatrixTemplate< T >::mColumns, mrpt::math::CSparseMatrixTemplate< T >::mRows, and mrpt::math::CSparseMatrixTemplate< T >::objectList.
Referenced by depthFirstSearch().
      
  | 
  inline | 
Checks whether an element of the matrix is the default object.
| std::logic_error | on out of range | 
Definition at line 361 of file CSparseMatrixTemplate.h.
References mrpt::math::CSparseMatrixTemplate< T >::mColumns, mrpt::math::CSparseMatrixTemplate< T >::mRows, and mrpt::math::CSparseMatrixTemplate< T >::objectList.
      
  | 
  inline | 
Element access operator.
Doesn't check bounds.
Definition at line 82 of file CSparseMatrixTemplate.h.
References mrpt::math::CSparseMatrixTemplate< T >::objectList.
Referenced by mrpt::math::CSparseMatrixTemplate< T >::insert().
      
  | 
  inline | 
Reference access operator.
Checks for bounds.
Definition at line 104 of file CSparseMatrixTemplate.h.
References mrpt::math::CSparseMatrixTemplate< T >::mColumns, mrpt::math::CSparseMatrixTemplate< T >::mRows, and mrpt::math::CSparseMatrixTemplate< T >::objectList.
      
  | 
  inline | 
Extracts a submatrix form the matrix.
| std::logic_error | on invalid bounds. | 
Definition at line 303 of file CSparseMatrixTemplate.h.
References mrpt::math::CSparseMatrixTemplate< T >::begin(), mrpt::math::CSparseMatrixTemplate< T >::end(), mrpt::math::CSparseMatrixTemplate< T >::mColumns, and mrpt::math::CSparseMatrixTemplate< T >::mRows.
      
  | 
  inline | 
Checks each non-null elements against the basic objects, erasing unnecesary references to it.
Definition at line 385 of file CSparseMatrixTemplate.h.
References mrpt::math::CSparseMatrixTemplate< T >::begin(), mrpt::math::CSparseMatrixTemplate< T >::end(), and mrpt::math::CSparseMatrixTemplate< T >::objectList.
      
  | 
  inline | 
Returns an iterator which points to the end of the matrix, and can be used to move backwards.
It's a const_reverse_iterator, so that the usar isn't able to modify the matrix content into an invalid state.
Definition at line 219 of file CSparseMatrixTemplate.h.
References mrpt::math::CSparseMatrixTemplate< T >::objectList.
      
  | 
  inline | 
Returns an iterator which points to the starting point of the matrix, although it's the upper limit of the matrix since it's a reverse iterator.
Also, it's a const_reverse_iterator, so that the usar isn't able to modify the matrix content into an invalid state.
Definition at line 227 of file CSparseMatrixTemplate.h.
References mrpt::math::CSparseMatrixTemplate< T >::objectList.
      
  | 
  inline | 
Changes the size of the matrix.
Definition at line 281 of file CSparseMatrixTemplate.h.
References mrpt::math::CSparseMatrixTemplate< T >::mColumns, mrpt::math::CSparseMatrixTemplate< T >::mRows, and mrpt::math::CSparseMatrixTemplate< T >::objectList.
Referenced by mrpt::math::intersect(), and mrpt::math::CSparseSymmetricalMatrix< T >::resize().
      
  | 
  inline | 
Returns the amount of rows in this matrix.
Definition at line 115 of file CSparseMatrixTemplate.h.
References mrpt::math::CSparseMatrixTemplate< T >::mRows.
Referenced by mrpt::math::intersect().
      
  | 
  inline | 
Inserts a full column into the matrix.
The third argument is used to specify a null object (which won't be inserted, since the matrix is sparse).
| std::logic_error | on out of range or wrong sized vector. | 
Definition at line 261 of file CSparseMatrixTemplate.h.
References mrpt::math::CSparseMatrixTemplate< T >::mColumns, mrpt::math::CSparseMatrixTemplate< T >::mRows, and mrpt::math::CSparseMatrixTemplate< T >::objectList.
      
  | 
  inline | 
Inserts a full row into the matrix.
The third argument is used to specify a null object (which won't be inserted, since the matrix is sparse).
| std::logic_error | on out of range or wrong sized vector. | 
Definition at line 236 of file CSparseMatrixTemplate.h.
References mrpt::math::CSparseMatrixTemplate< T >::mColumns, mrpt::math::CSparseMatrixTemplate< T >::mRows, and mrpt::math::CSparseMatrixTemplate< T >::objectList.
      
  | 
  protected | 
Definition at line 64 of file CSparseMatrixTemplate.h.
Referenced by mrpt::math::CSparseMatrixTemplate< T >::cols(), mrpt::math::CSparseMatrixTemplate< T >::exists(), mrpt::math::CSparseMatrixTemplate< T >::getColumn(), mrpt::math::CSparseMatrixTemplate< T >::getNullElements(), mrpt::math::CSparseMatrixTemplate< T >::getRow(), mrpt::math::CSparseMatrixTemplate< T >::isNotNull(), mrpt::math::CSparseMatrixTemplate< T >::isNull(), mrpt::math::CSparseMatrixTemplate< T >::operator()(), mrpt::math::CSparseMatrixTemplate< T >::resize(), mrpt::math::CSparseMatrixTemplate< T >::setColumn(), and mrpt::math::CSparseMatrixTemplate< T >::setRow().
      
  | 
  protected | 
Size of the matrix.
Definition at line 64 of file CSparseMatrixTemplate.h.
Referenced by mrpt::math::CSparseMatrixTemplate< T >::exists(), mrpt::math::CSparseMatrixTemplate< T >::getColumn(), mrpt::math::CSparseMatrixTemplate< T >::getNullElements(), mrpt::math::CSparseMatrixTemplate< T >::getRow(), mrpt::math::CSparseMatrixTemplate< T >::isNotNull(), mrpt::math::CSparseMatrixTemplate< T >::isNull(), mrpt::math::CSparseMatrixTemplate< T >::operator()(), mrpt::math::CSparseMatrixTemplate< T >::resize(), mrpt::math::CSparseMatrixTemplate< T >::rows(), mrpt::math::CSparseMatrixTemplate< T >::setColumn(), and mrpt::math::CSparseMatrixTemplate< T >::setRow().
      
  | 
  protected | 
Actual matrix.
Definition at line 68 of file CSparseMatrixTemplate.h.
Referenced by mrpt::math::CSparseMatrixTemplate< T >::asVector(), mrpt::math::CSparseMatrixTemplate< T >::begin(), mrpt::math::CSparseMatrixTemplate< T >::clear(), mrpt::math::CSparseMatrixTemplate< T >::empty(), mrpt::math::CSparseMatrixTemplate< T >::end(), mrpt::math::CSparseMatrixTemplate< T >::exists(), mrpt::math::CSparseMatrixTemplate< T >::getColumn(), mrpt::math::CSparseMatrixTemplate< T >::getNonNullElements(), mrpt::math::CSparseMatrixTemplate< T >::getRow(), mrpt::math::CSparseMatrixTemplate< T >::isNotNull(), mrpt::math::CSparseMatrixTemplate< T >::isNull(), mrpt::math::CSparseMatrixTemplate< T >::operator()(), mrpt::math::CSparseMatrixTemplate< T >::purge(), mrpt::math::CSparseMatrixTemplate< T >::rbegin(), mrpt::math::CSparseMatrixTemplate< T >::rend(), mrpt::math::CSparseMatrixTemplate< T >::resize(), mrpt::math::CSparseMatrixTemplate< T >::setColumn(), and mrpt::math::CSparseMatrixTemplate< T >::setRow().
| Page generated by Doxygen 1.8.14 for MRPT 2.0.0 Git: b38439d21 Tue Mar 31 19:58:06 2020 +0200 at miƩ abr 1 00:50:30 CEST 2020 |