g2o
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Attributes | List of all members
g2o::SparseBlockMatrixHashMap< MatrixType > Class Template Reference

Sparse matrix which uses blocks based on hash structures. More...

#include <sparse_block_matrix_ccs.h>

Public Types

typedef MatrixType SparseMatrixBlock
 this is the type of the elementary block, it is an Eigen::Matrix.
 
typedef std::unordered_map< int, MatrixType * > SparseColumn
 

Public Member Functions

int cols () const
 columns of the matrix
 
int rows () const
 rows of the matrix
 
 SparseBlockMatrixHashMap (const std::vector< int > &rowIndices, const std::vector< int > &colIndices)
 
int rowsOfBlock (int r) const
 how many rows does the block at block-row r has?
 
int colsOfBlock (int c) const
 how many cols does the block at block-col c has?
 
int rowBaseOfBlock (int r) const
 where does the row at block-row r start?
 
int colBaseOfBlock (int c) const
 where does the col at block-col r start?
 
const std::vector< SparseColumn > & blockCols () const
 the block matrices per block-column
 
std::vector< SparseColumn > & blockCols ()
 
const std::vector< int > & rowBlockIndices () const
 indices of the row blocks
 
const std::vector< int > & colBlockIndices () const
 indices of the column blocks
 
MatrixType * addBlock (int r, int c, bool zeroBlock=false)
 

Protected Attributes

const std::vector< int > & _rowBlockIndices
 
const std::vector< int > & _colBlockIndices
 vector of the indices of the blocks along the cols
 
std::vector< SparseColumn_blockCols
 the matrices stored in CCS order
 

Detailed Description

template<class MatrixType>
class g2o::SparseBlockMatrixHashMap< MatrixType >

Sparse matrix which uses blocks based on hash structures.

This class is used to construct the pattern of a sparse block matrix

Definition at line 217 of file sparse_block_matrix_ccs.h.

Member Typedef Documentation

◆ SparseColumn

template<class MatrixType >
typedef std::unordered_map<int, MatrixType*> g2o::SparseBlockMatrixHashMap< MatrixType >::SparseColumn

Definition at line 231 of file sparse_block_matrix_ccs.h.

◆ SparseMatrixBlock

template<class MatrixType >
typedef MatrixType g2o::SparseBlockMatrixHashMap< MatrixType >::SparseMatrixBlock

this is the type of the elementary block, it is an Eigen::Matrix.

Definition at line 220 of file sparse_block_matrix_ccs.h.

Constructor & Destructor Documentation

◆ SparseBlockMatrixHashMap()

template<class MatrixType >
g2o::SparseBlockMatrixHashMap< MatrixType >::SparseBlockMatrixHashMap ( const std::vector< int > &  rowIndices,
const std::vector< int > &  colIndices 
)
inline

Definition at line 233 of file sparse_block_matrix_ccs.h.

235 : _rowBlockIndices(rowIndices), _colBlockIndices(colIndices) {}
const std::vector< int > & _colBlockIndices
vector of the indices of the blocks along the cols
const std::vector< int > & _rowBlockIndices

Member Function Documentation

◆ addBlock()

template<class MatrixType >
MatrixType * g2o::SparseBlockMatrixHashMap< MatrixType >::addBlock ( int  r,
int  c,
bool  zeroBlock = false 
)
inline

add a block to the pattern, return a pointer to the added block

Definition at line 268 of file sparse_block_matrix_ccs.h.

268 {
269 assert(c < (int)_blockCols.size() &&
270 "accessing column which is not available");
271 SparseColumn& sparseColumn = _blockCols[c];
272 typename SparseColumn::iterator foundIt = sparseColumn.find(r);
273 if (foundIt == sparseColumn.end()) {
274 int rb = rowsOfBlock(r);
275 int cb = colsOfBlock(c);
276 MatrixType* m = new MatrixType(rb, cb);
277 if (zeroBlock) m->setZero();
278 sparseColumn[r] = m;
279 return m;
280 }
281 return foundIt->second;
282 }
std::unordered_map< int, MatrixType * > SparseColumn
int colsOfBlock(int c) const
how many cols does the block at block-col c has?
std::vector< SparseColumn > _blockCols
the matrices stored in CCS order
int rowsOfBlock(int r) const
how many rows does the block at block-row r has?

References g2o::SparseBlockMatrixHashMap< MatrixType >::_blockCols, g2o::SparseBlockMatrixHashMap< MatrixType >::colsOfBlock(), and g2o::SparseBlockMatrixHashMap< MatrixType >::rowsOfBlock().

Referenced by g2o::BlockSolver< Traits >::buildStructure().

◆ blockCols() [1/2]

template<class MatrixType >
std::vector< SparseColumn > & g2o::SparseBlockMatrixHashMap< MatrixType >::blockCols ( )
inline

◆ blockCols() [2/2]

template<class MatrixType >
const std::vector< SparseColumn > & g2o::SparseBlockMatrixHashMap< MatrixType >::blockCols ( ) const
inline

◆ colBaseOfBlock()

template<class MatrixType >
int g2o::SparseBlockMatrixHashMap< MatrixType >::colBaseOfBlock ( int  c) const
inline

where does the col at block-col r start?

Definition at line 253 of file sparse_block_matrix_ccs.h.

253{ return c ? _colBlockIndices[c - 1] : 0; }

References g2o::SparseBlockMatrixHashMap< MatrixType >::_colBlockIndices.

◆ colBlockIndices()

template<class MatrixType >
const std::vector< int > & g2o::SparseBlockMatrixHashMap< MatrixType >::colBlockIndices ( ) const
inline

indices of the column blocks

Definition at line 263 of file sparse_block_matrix_ccs.h.

263{ return _colBlockIndices; }

References g2o::SparseBlockMatrixHashMap< MatrixType >::_colBlockIndices.

◆ cols()

template<class MatrixType >
int g2o::SparseBlockMatrixHashMap< MatrixType >::cols ( ) const
inline

columns of the matrix

Definition at line 223 of file sparse_block_matrix_ccs.h.

223 {
224 return _colBlockIndices.size() ? _colBlockIndices.back() : 0;
225 }

References g2o::SparseBlockMatrixHashMap< MatrixType >::_colBlockIndices.

◆ colsOfBlock()

template<class MatrixType >
int g2o::SparseBlockMatrixHashMap< MatrixType >::colsOfBlock ( int  c) const
inline

how many cols does the block at block-col c has?

Definition at line 244 of file sparse_block_matrix_ccs.h.

244 {
245 return c ? _colBlockIndices[c] - _colBlockIndices[c - 1]
246 : _colBlockIndices[0];
247 }

References g2o::SparseBlockMatrixHashMap< MatrixType >::_colBlockIndices.

Referenced by g2o::SparseBlockMatrixHashMap< MatrixType >::addBlock().

◆ rowBaseOfBlock()

template<class MatrixType >
int g2o::SparseBlockMatrixHashMap< MatrixType >::rowBaseOfBlock ( int  r) const
inline

where does the row at block-row r start?

Definition at line 250 of file sparse_block_matrix_ccs.h.

250{ return r ? _rowBlockIndices[r - 1] : 0; }

References g2o::SparseBlockMatrixHashMap< MatrixType >::_rowBlockIndices.

◆ rowBlockIndices()

template<class MatrixType >
const std::vector< int > & g2o::SparseBlockMatrixHashMap< MatrixType >::rowBlockIndices ( ) const
inline

indices of the row blocks

Definition at line 260 of file sparse_block_matrix_ccs.h.

260{ return _rowBlockIndices; }

References g2o::SparseBlockMatrixHashMap< MatrixType >::_rowBlockIndices.

◆ rows()

template<class MatrixType >
int g2o::SparseBlockMatrixHashMap< MatrixType >::rows ( ) const
inline

rows of the matrix

Definition at line 227 of file sparse_block_matrix_ccs.h.

227 {
228 return _rowBlockIndices.size() ? _rowBlockIndices.back() : 0;
229 }

References g2o::SparseBlockMatrixHashMap< MatrixType >::_rowBlockIndices.

◆ rowsOfBlock()

template<class MatrixType >
int g2o::SparseBlockMatrixHashMap< MatrixType >::rowsOfBlock ( int  r) const
inline

how many rows does the block at block-row r has?

Definition at line 238 of file sparse_block_matrix_ccs.h.

238 {
239 return r ? _rowBlockIndices[r] - _rowBlockIndices[r - 1]
240 : _rowBlockIndices[0];
241 }

References g2o::SparseBlockMatrixHashMap< MatrixType >::_rowBlockIndices.

Referenced by g2o::SparseBlockMatrixHashMap< MatrixType >::addBlock().

Member Data Documentation

◆ _blockCols

template<class MatrixType >
std::vector<SparseColumn> g2o::SparseBlockMatrixHashMap< MatrixType >::_blockCols
protected

◆ _colBlockIndices

template<class MatrixType >
const std::vector<int>& g2o::SparseBlockMatrixHashMap< MatrixType >::_colBlockIndices
protected

◆ _rowBlockIndices

template<class MatrixType >
const std::vector<int>& g2o::SparseBlockMatrixHashMap< MatrixType >::_rowBlockIndices
protected

The documentation for this class was generated from the following file: