g2o
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. More...
 
typedef std::vector< MatrixType, Eigen::aligned_allocator< MatrixType > > DiagonalVector
 

Public Member Functions

int cols () const
 columns of the matrix More...
 
int rows () const
 rows of the matrix More...
 
 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? More...
 
int baseOfBlock (int r) const
 where does the row /col at block-row / block-column r starts? More...
 
const DiagonalVectordiagonal () const
 the block matrices per block-column More...
 
DiagonalVectordiagonal ()
 
const std::vector< int > & blockIndices () const
 indices of the row blocks More...
 
void multiply (double *&dest, const double *src) const
 

Protected Attributes

const std::vector< int > & _blockIndices
 vector of the indices of the blocks along the diagonal More...
 
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 47 of file sparse_block_matrix_diagonal.h.

Member Typedef Documentation

template<class MatrixType>
typedef std::vector<MatrixType, Eigen::aligned_allocator<MatrixType> > g2o::SparseBlockMatrixDiagonal< MatrixType >::DiagonalVector

Definition at line 58 of file sparse_block_matrix_diagonal.h.

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 51 of file sparse_block_matrix_diagonal.h.

Constructor & Destructor Documentation

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

Definition at line 60 of file sparse_block_matrix_diagonal.h.

60  :
62  {}
const std::vector< int > & blockIndices() const
indices of the row blocks
const std::vector< int > & _blockIndices
vector of the indices of the blocks along the diagonal

Member Function Documentation

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 68 of file sparse_block_matrix_diagonal.h.

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

68 { return r ? _blockIndices[r-1] : 0 ; }
const std::vector< int > & _blockIndices
vector of the indices of the blocks along the diagonal
template<class MatrixType>
const std::vector<int>& g2o::SparseBlockMatrixDiagonal< MatrixType >::blockIndices ( ) const
inline

indices of the row blocks

Definition at line 75 of file sparse_block_matrix_diagonal.h.

75 { return _blockIndices;}
const std::vector< int > & _blockIndices
vector of the indices of the blocks along the diagonal
template<class MatrixType>
int g2o::SparseBlockMatrixDiagonal< MatrixType >::cols ( ) const
inline

columns of the matrix

Definition at line 54 of file sparse_block_matrix_diagonal.h.

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

54 {return _blockIndices.size() ? _blockIndices.back() : 0;}
const std::vector< int > & _blockIndices
vector of the indices of the blocks along the diagonal
template<class MatrixType>
const DiagonalVector& g2o::SparseBlockMatrixDiagonal< MatrixType >::diagonal ( ) const
inline

the block matrices per block-column

Definition at line 71 of file sparse_block_matrix_diagonal.h.

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

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

Definition at line 72 of file sparse_block_matrix_diagonal.h.

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 65 of file sparse_block_matrix_diagonal.h.

65 { return r ? _blockIndices[r] - _blockIndices[r-1] : _blockIndices[0] ; }
const std::vector< int > & _blockIndices
vector of the indices of the blocks along the diagonal
template<class MatrixType>
void g2o::SparseBlockMatrixDiagonal< MatrixType >::multiply ( double *&  dest,
const double *  src 
) const
inline

Definition at line 77 of file sparse_block_matrix_diagonal.h.

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

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

rows of the matrix

Definition at line 56 of file sparse_block_matrix_diagonal.h.

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

56 {return _blockIndices.size() ? _blockIndices.back() : 0;}
const std::vector< int > & _blockIndices
vector of the indices of the blocks along the diagonal

Member Data Documentation

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

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