MRPT  2.0.1
List of all members | Classes | Public Types | Public Member Functions | Private Attributes
mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL > Struct Template Reference

Detailed Description

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 mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >

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
NROWSRows in each elementary matrix.
NCOLSCols in each elementary matrix.
INFOType of the extra data fields within each block
HAS_REMAPIs true, an inverse mapping between column indices and "user IDs" is kept.
INDEX_REMAP_MAP_IMPLIgnore 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.

Definition at line 41 of file MatrixBlockSparseCols.h.

#include <mrpt/math/MatrixBlockSparseCols.h>

Classes

struct  TEntry
 

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

Public Member Functions

 MatrixBlockSparseCols ()
 
col_tgetCol (const size_t idx)
 
const col_tgetCol (const size_t idx) const
 
const mrpt::containers::map_as_vector< size_t, size_t > & getColInverseRemappedIndices () const
 
const std::vector< size_t > & getColRemappedIndices () const
 
col_tappendCol (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 cols () 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_tm_cols
 -> cols[i]: i'th column. More...
 
mrpt::containers::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
 

Member Typedef Documentation

◆ col_t

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>>
using mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::col_t = std::map<size_t, TEntry>

Each compressed sparse column.

Definition at line 55 of file MatrixBlockSparseCols.h.

◆ matrix_t

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>>
using mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::matrix_t = Eigen::Matrix<Scalar, NROWS, NCOLS>

Definition at line 43 of file MatrixBlockSparseCols.h.

◆ symbolic_t

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>>
using mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::symbolic_t = INFO

Definition at line 44 of file MatrixBlockSparseCols.h.

Constructor & Destructor Documentation

◆ MatrixBlockSparseCols()

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>>
mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::MatrixBlockSparseCols ( )
inline

Definition at line 70 of file MatrixBlockSparseCols.h.

Member Function Documentation

◆ appendCol()

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>>
col_t& mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::appendCol ( const size_t  remapIndex)
inline

◆ clearAll()

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>>
void mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::clearAll ( )
inline

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

See also
getColCount

Definition at line 115 of file MatrixBlockSparseCols.h.

References mrpt::containers::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 >::m_cols.

Here is the call graph for this function:

◆ clearColEntries()

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>>
void mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::clearColEntries ( )
inline

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

See also
getColCount

Definition at line 108 of file MatrixBlockSparseCols.h.

References mrpt::containers::clear(), and mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::m_cols.

Here is the call graph for this function:

◆ cols()

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>>
size_t mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::cols ( ) const
inline

◆ copyNumericalValuesFrom()

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>>
void mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::copyNumericalValuesFrom ( const MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP > &  o)
inline

Clear the current contents of this objects and replicates the sparse structure and numerical values of o.

Definition at line 202 of file MatrixBlockSparseCols.h.

References mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::m_cols.

◆ findCurrentNumberOfRows()

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>>
size_t mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::findCurrentNumberOfRows ( ) const
inline

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

See also
cols()

Definition at line 171 of file MatrixBlockSparseCols.h.

References mrpt::containers::begin(), mrpt::keep_max(), and mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::m_cols.

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getAsDense()

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>>
void mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::getAsDense ( mrpt::math::CMatrixDouble D,
const bool  force_symmetry = false,
const bool  is_col_compressed = true 
) const
inline

Builds a dense representation of the matrix and saves to a text file.

Parameters
is_col_compressedtrue: interpret this object as compressed by cols; false: compressed by rows

Definition at line 139 of file MatrixBlockSparseCols.h.

References mrpt::containers::begin(), mrpt::math::MatrixVectorBase< Scalar, Derived >::block(), 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 >::m_cols, and mrpt::math::CMatrixDynamic< T >::setSize().

Referenced by mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::saveToTextFileAsDense().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getBinaryBlocksRepresentation()

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>>
template<class MATRIX >
void mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::getBinaryBlocksRepresentation ( MATRIX &  out) const
inline

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

Definition at line 186 of file MatrixBlockSparseCols.h.

References mrpt::containers::begin(), 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 >::m_cols, and out.

Here is the call graph for this function:

◆ getCol() [1/2]

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>>
col_t& mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::getCol ( const size_t  idx)
inline

◆ getCol() [2/2]

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>>
const col_t& mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::getCol ( const size_t  idx) const
inline

◆ getColInverseRemappedIndices()

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>>
const mrpt::containers::map_as_vector<size_t, size_t>& mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::getColInverseRemappedIndices ( ) const
inline

◆ getColRemappedIndices()

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>>
const std::vector<size_t>& mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::getColRemappedIndices ( ) const
inline

◆ saveToTextFileAsDense()

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>>
void mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::saveToTextFileAsDense ( const std::string &  filename,
const bool  force_symmetry = false,
const bool  is_col_compressed = true 
) const
inline

Builds a dense representation of the matrix and saves to a text file.

Definition at line 126 of file MatrixBlockSparseCols.h.

References mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::getAsDense(), and mrpt::math::MatrixVectorBase< Scalar, Derived >::saveToTextFile().

Here is the call graph for this function:

◆ setColCount()

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>>
void mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::setColCount ( const size_t  nCols)
inline

Change the number of columns (keep old contents)

Definition at line 103 of file MatrixBlockSparseCols.h.

References mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::m_cols.

Member Data Documentation

◆ col_inverse_remapped_indices

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>>
mrpt::containers::map_as_vector<size_t, size_t> mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::col_inverse_remapped_indices
private

◆ col_remapped_indices

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>>
std::vector<size_t> mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::col_remapped_indices
private

◆ m_cols

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>>
std::deque<col_t> mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::m_cols
private



Page generated by Doxygen 1.8.14 for MRPT 2.0.1 Git: 0fef1a6d7 Fri Apr 3 23:00:21 2020 +0200 at vie abr 3 23:20:28 CEST 2020