A templated column-indexed efficient storage of block-sparse Jacobian or Hessian matrices, together with other arbitrary information.
Columns are stored in a non-associative container, but the contents of each column are kept within an std::map<> indexed by row. All submatrix blocks have the same size, which allows dense storage of them in fixed-size matrices, avoiding costly memory allocations.
NROWS | Rows in each elementary matrix. |
NCOLS | Cols in each elementary matrix. |
INFO | Type of the extra data fields within each block |
HAS_REMAP | Is true, an inverse mapping between column indices and "user IDs" is kept. |
INDEX_REMAP_MAP_IMPL | Ignore if HAS_REMAP=false. Defaults to "mrpt::utils::map_as_vector<size_t,size_t>" for amortized O(1). Can be set to "std::map<size_t,size_t>" in very sparse systems to save memory at the cost of a O(log N) access time when using the remap indices. |
Definition at line 41 of file MatrixBlockSparseCols.h.
#include <mrpt/math/MatrixBlockSparseCols.h>
Classes | |
struct | TEntry |
Public Types | |
typedef Eigen::Matrix< Scalar, NROWS, NCOLS > | matrix_t |
typedef INFO | symbolic_t |
typedef mrpt::aligned_containers< size_t, TEntry >::map_t | col_t |
Each compressed sparse column. More... | |
Public Member Functions | |
MatrixBlockSparseCols () | |
col_t & | getCol (const size_t idx) |
const col_t & | getCol (const size_t idx) const |
const mrpt::utils::map_as_vector< size_t, size_t > & | getColInverseRemappedIndices () const |
const std::vector< size_t > & | getColRemappedIndices () const |
col_t & | appendCol (const size_t remapIndex) |
Append one column, returning a ref to the new col_t data. More... | |
void | setColCount (const size_t nCols) |
Change the number of columns (keep old contents) More... | |
size_t | getColCount () const |
Get current number of cols. More... | |
void | clearColEntries () |
Clear all the entries in each column (do not change the number of columns, though!) More... | |
void | clearAll () |
Clear all the entries in each column (do not change the number of columns, though!) More... | |
void | saveToTextFileAsDense (const std::string &filename, const bool force_symmetry=false, const bool is_col_compressed=true) const |
Builds a dense representation of the matrix and saves to a text file. More... | |
void | getAsDense (mrpt::math::CMatrixDouble &D, const bool force_symmetry=false, const bool is_col_compressed=true) const |
Builds a dense representation of the matrix and saves to a text file. More... | |
size_t | findCurrentNumberOfRows () const |
Goes over all the columns and keep the largest column length. More... | |
template<class MATRIX > | |
void | getBinaryBlocksRepresentation (MATRIX &out) const |
Builds a binary matrix with 1s where an elementary matrix is stored, 0s elsewhere. More... | |
void | copyNumericalValuesFrom (const MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP > &o) |
Clear the current contents of this objects and replicates the sparse structure and numerical values of o. More... | |
Private Attributes | |
std::deque< col_t > | cols |
-> cols[i]: i'th column. More... | |
mrpt::utils::map_as_vector< size_t, size_t > | col_inverse_remapped_indices |
"remapped index" is the index of some global variable, interpreted by the external user of this class. More... | |
std::vector< size_t > | col_remapped_indices |
typedef mrpt::aligned_containers<size_t,TEntry>::map_t mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::col_t |
Each compressed sparse column.
Definition at line 52 of file MatrixBlockSparseCols.h.
typedef Eigen::Matrix<Scalar,NROWS,NCOLS> mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::matrix_t |
Definition at line 43 of file MatrixBlockSparseCols.h.
typedef INFO mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::symbolic_t |
Definition at line 44 of file MatrixBlockSparseCols.h.
|
inline |
Definition at line 65 of file MatrixBlockSparseCols.h.
|
inline |
Append one column, returning a ref to the new col_t data.
Definition at line 74 of file MatrixBlockSparseCols.h.
References mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::col_inverse_remapped_indices, mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::col_remapped_indices, and mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::cols.
|
inline |
Clear all the entries in each column (do not change the number of columns, though!)
Definition at line 101 of file MatrixBlockSparseCols.h.
References mrpt::utils::map_as_vector< KEY, VALUE, VECTOR_T >::clear(), mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::col_inverse_remapped_indices, mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::col_remapped_indices, and mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::cols.
|
inline |
Clear all the entries in each column (do not change the number of columns, though!)
Definition at line 96 of file MatrixBlockSparseCols.h.
References mrpt::utils::clear(), and mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::cols.
|
inline |
Clear the current contents of this objects and replicates the sparse structure and numerical values of o.
Definition at line 177 of file MatrixBlockSparseCols.h.
References mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::cols.
|
inline |
Goes over all the columns and keep the largest column length.
Definition at line 151 of file MatrixBlockSparseCols.h.
References begin(), mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::cols, and mrpt::mrpt::utils::keep_max().
Referenced by mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::getAsDense(), and mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::getBinaryBlocksRepresentation().
|
inline |
Builds a dense representation of the matrix and saves to a text file.
is_col_compressed | true: interpret this object as compressed by cols; false: compressed by rows |
Definition at line 124 of file MatrixBlockSparseCols.h.
References begin(), mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::cols, and mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::findCurrentNumberOfRows().
Referenced by mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::saveToTextFileAsDense().
|
inline |
Builds a binary matrix with 1s where an elementary matrix is stored, 0s elsewhere.
Definition at line 163 of file MatrixBlockSparseCols.h.
References begin(), mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::cols, and mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::findCurrentNumberOfRows().
|
inline |
Definition at line 67 of file MatrixBlockSparseCols.h.
References mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::cols.
|
inline |
Definition at line 68 of file MatrixBlockSparseCols.h.
References mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::cols.
|
inline |
Get current number of cols.
Definition at line 93 of file MatrixBlockSparseCols.h.
References mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::cols.
|
inline |
Definition at line 70 of file MatrixBlockSparseCols.h.
|
inline |
Definition at line 71 of file MatrixBlockSparseCols.h.
|
inline |
Builds a dense representation of the matrix and saves to a text file.
Definition at line 111 of file MatrixBlockSparseCols.h.
|
inline |
Change the number of columns (keep old contents)
Definition at line 90 of file MatrixBlockSparseCols.h.
References mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::cols.
|
private |
"remapped index" is the index of some global variable, interpreted by the external user of this class.
Definition at line 61 of file MatrixBlockSparseCols.h.
Referenced by mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::appendCol(), mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::clearAll(), and mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::getColInverseRemappedIndices().
|
private |
Definition at line 62 of file MatrixBlockSparseCols.h.
Referenced by mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::appendCol(), mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::clearAll(), and mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::getColRemappedIndices().
|
private |
-> cols[i]: i'th column.
-> Each column is a map [row] -> TEntry
Definition at line 58 of file MatrixBlockSparseCols.h.
Referenced by mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::appendCol(), mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::clearAll(), mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::clearColEntries(), mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::copyNumericalValuesFrom(), mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::findCurrentNumberOfRows(), mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::getAsDense(), mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::getBinaryBlocksRepresentation(), mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::getCol(), mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::getColCount(), and mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::setColCount().
Page generated by Doxygen 1.8.14 for MRPT 1.5.7 Git: 5902e14cc Wed Apr 24 15:04:01 2019 +0200 at lun oct 28 01:39:17 CET 2019 |