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

Sparse matrix which uses blocks on the diagonal. More...

#include <sparse_block_matrix_diagonal.h>

Public Types

typedef MatrixType SparseMatrixBlock
 this is the type of the elementary block, it is an Eigen::Matrix.
 
using DiagonalVector = std::vector< MatrixType >
 

Public Member Functions

int cols () const
 columns of the matrix
 
int rows () const
 rows of the matrix
 
 SparseBlockMatrixDiagonal (const std::vector< int > &blockIndices)
 
int dimOfBlock (int r) const
 how many rows/cols does the block at block-row / block-column r has?
 
int baseOfBlock (int r) const
 where does the row /col at block-row / block-column r starts?
 
const DiagonalVectordiagonal () const
 the block matrices per block-column
 
DiagonalVectordiagonal ()
 
const std::vector< int > & blockIndices () const
 indices of the row blocks
 
void multiply (double *&dest, const double *src) const
 

Protected Attributes

const std::vector< int > & _blockIndices
 
DiagonalVector _diagonal
 

Detailed Description

template<class MatrixType>
class g2o::SparseBlockMatrixDiagonal< MatrixType >

Sparse matrix which uses blocks on the diagonal.

This class is used as a const view on a SparseBlockMatrix which allows a faster iteration over the elements of the matrix.

Definition at line 46 of file sparse_block_matrix_diagonal.h.

Member Typedef Documentation

◆ DiagonalVector

template<class MatrixType >
using g2o::SparseBlockMatrixDiagonal< MatrixType >::DiagonalVector = std::vector<MatrixType>

Definition at line 56 of file sparse_block_matrix_diagonal.h.

◆ SparseMatrixBlock

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

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

Definition at line 49 of file sparse_block_matrix_diagonal.h.

Constructor & Destructor Documentation

◆ SparseBlockMatrixDiagonal()

template<class MatrixType >
g2o::SparseBlockMatrixDiagonal< MatrixType >::SparseBlockMatrixDiagonal ( const std::vector< int > &  blockIndices)
inline

Definition at line 58 of file sparse_block_matrix_diagonal.h.

const std::vector< int > & blockIndices() const
indices of the row blocks

Member Function Documentation

◆ baseOfBlock()

template<class MatrixType >
int g2o::SparseBlockMatrixDiagonal< MatrixType >::baseOfBlock ( int  r) const
inline

where does the row /col at block-row / block-column r starts?

Definition at line 67 of file sparse_block_matrix_diagonal.h.

67{ return r ? _blockIndices[r - 1] : 0; }

References g2o::SparseBlockMatrixDiagonal< MatrixType >::_blockIndices.

Referenced by g2o::SparseBlockMatrixDiagonal< MatrixType >::multiply().

◆ blockIndices()

template<class MatrixType >
const std::vector< int > & g2o::SparseBlockMatrixDiagonal< MatrixType >::blockIndices ( ) const
inline

indices of the row blocks

Definition at line 74 of file sparse_block_matrix_diagonal.h.

74{ return _blockIndices; }

References g2o::SparseBlockMatrixDiagonal< MatrixType >::_blockIndices.

◆ cols()

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

columns of the matrix

Definition at line 52 of file sparse_block_matrix_diagonal.h.

52{ return _blockIndices.size() ? _blockIndices.back() : 0; }

References g2o::SparseBlockMatrixDiagonal< MatrixType >::_blockIndices.

Referenced by g2o::SparseBlockMatrixDiagonal< MatrixType >::multiply().

◆ diagonal() [1/2]

template<class MatrixType >
DiagonalVector & g2o::SparseBlockMatrixDiagonal< MatrixType >::diagonal ( )
inline

◆ diagonal() [2/2]

template<class MatrixType >
const DiagonalVector & g2o::SparseBlockMatrixDiagonal< MatrixType >::diagonal ( ) const
inline

the block matrices per block-column

Definition at line 70 of file sparse_block_matrix_diagonal.h.

70{ return _diagonal; }

References g2o::SparseBlockMatrixDiagonal< MatrixType >::_diagonal.

◆ dimOfBlock()

template<class MatrixType >
int g2o::SparseBlockMatrixDiagonal< MatrixType >::dimOfBlock ( int  r) const
inline

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

Definition at line 62 of file sparse_block_matrix_diagonal.h.

62 {
63 return r ? _blockIndices[r] - _blockIndices[r - 1] : _blockIndices[0];
64 }

References g2o::SparseBlockMatrixDiagonal< MatrixType >::_blockIndices.

◆ multiply()

template<class MatrixType >
void g2o::SparseBlockMatrixDiagonal< MatrixType >::multiply ( double *&  dest,
const double *  src 
) const
inline

Definition at line 76 of file sparse_block_matrix_diagonal.h.

76 {
77 int destSize = cols();
78 if (!dest) {
79 dest = new double[destSize];
80 memset(dest, 0, destSize * sizeof(double));
81 }
82
83 // map the memory by Eigen
84 Eigen::Map<VectorX> destVec(dest, destSize);
85 Eigen::Map<const VectorX> srcVec(src, rows());
86
87#ifdef G2O_OPENMP
88#pragma omp parallel for default(shared) schedule(dynamic, 10)
89#endif
90 for (int i = 0; i < static_cast<int>(_diagonal.size()); ++i) {
91 int destOffset = baseOfBlock(i);
92 int srcOffset = destOffset;
93 const SparseMatrixBlock& A = _diagonal[i];
94 // destVec += *A.transpose() * srcVec (according to the sub-vector parts)
95 internal::template axpy<SparseMatrixBlock>(A, srcVec, srcOffset, destVec,
96 destOffset);
97 }
98 }
int baseOfBlock(int r) const
where does the row /col at block-row / block-column r starts?
int cols() const
columns of the matrix
MatrixType SparseMatrixBlock
this is the type of the elementary block, it is an Eigen::Matrix.

References g2o::SparseBlockMatrixDiagonal< MatrixType >::_diagonal, g2o::SparseBlockMatrixDiagonal< MatrixType >::baseOfBlock(), g2o::SparseBlockMatrixDiagonal< MatrixType >::cols(), and g2o::SparseBlockMatrixDiagonal< MatrixType >::rows().

◆ rows()

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

Member Data Documentation

◆ _blockIndices

template<class MatrixType >
const std::vector<int>& g2o::SparseBlockMatrixDiagonal< MatrixType >::_blockIndices
protected

◆ _diagonal

template<class MatrixType >
DiagonalVector g2o::SparseBlockMatrixDiagonal< MatrixType >::_diagonal
protected

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