Template Struct MatrixBlockSparseCols

Nested Relationships

Nested Types

Struct Documentation

template<typename Scalar, int NROWS, int NCOLS, typename INFO, bool HAS_REMAP, typename INDEX_REMAP_MAP_IMPL = mrpt::containers::map_as_vector<size_t, size_t>>
struct MatrixBlockSparseCols

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.

Template Parameters:
  • 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::containers::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.

Public Types

using matrix_t = Eigen::Matrix<Scalar, NROWS, NCOLS>
using symbolic_t = INFO
using col_t = std::map<size_t, TEntry>

Each compressed sparse column

Public Functions

inline MatrixBlockSparseCols()
inline col_t &getCol(size_t idx)
inline const col_t &getCol(size_t idx) const
inline const mrpt::containers::map_as_vector<size_t, size_t> &getColInverseRemappedIndices() const
inline const std::vector<size_t> &getColRemappedIndices() const
inline col_t &appendCol(size_t remapIndex)

Append one column, returning a ref to the new col_t data

inline void setColCount(size_t nCols)

Change the number of columns (keep old contents)

inline size_t cols() const

Get current number of cols.

inline void clearColEntries()

Clear all the entries in each column (do not change the number of columns, though!)

See also

getColCount

inline void clearAll()

Clear all the entries in each column (do not change the number of columns, though!)

See also

getColCount

inline 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.

inline 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.

Parameters:

is_col_compressed – true: interpret this object as compressed by cols; false: compressed by rows

inline size_t findCurrentNumberOfRows() const

Goes over all the columns and keep the largest column length.

See also

cols()

template<class MATRIX>
inline void getBinaryBlocksRepresentation(MATRIX &out) const

Builds a binary matrix with 1s where an elementary matrix is stored, 0s elsewhere.

inline 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

struct TEntry

Public Members

matrix_t num

Numeric matrix

symbolic_t sym

Extra symbolic info