27 #ifndef G2O_SPARSE_BLOCK_MATRIX_ 28 #define G2O_SPARSE_BLOCK_MATRIX_ 41 #include "../../config.h" 44 using namespace Eigen;
61 template <
class MatrixType = MatrixXd >
69 inline int cols()
const {
return _colBlockIndices.size() ? _colBlockIndices.back() : 0;}
71 inline int rows()
const {
return _rowBlockIndices.size() ? _rowBlockIndices.back() : 0;}
86 SparseBlockMatrix(
const int * rbi,
const int* cbi,
int rb,
int cb,
bool hasStorage=
true);
94 void clear(
bool dealloc=
false) ;
97 SparseMatrixBlock* block(
int r,
int c,
bool alloc=
false);
99 const SparseMatrixBlock* block(
int r,
int c)
const;
102 inline int rowsOfBlock(
int r)
const {
return r ? _rowBlockIndices[r] - _rowBlockIndices[r-1] : _rowBlockIndices[0] ; }
105 inline int colsOfBlock(
int c)
const {
return c ? _colBlockIndices[c] - _colBlockIndices[c-1] : _colBlockIndices[0]; }
108 inline int rowBaseOfBlock(
int r)
const {
return r ? _rowBlockIndices[r-1] : 0 ; }
111 inline int colBaseOfBlock(
int c)
const {
return c ? _colBlockIndices[c-1] : 0 ; }
114 size_t nonZeros()
const;
116 size_t nonZeroBlocks()
const;
129 SparseBlockMatrix* slice(
int rmin,
int rmax,
int cmin,
int cmax,
bool alloc=
true)
const;
132 template <
class MatrixTransposedType>
139 template <
class MatrixResultType,
class MatrixFactorType>
143 void multiply(
double*& dest,
const double* src)
const;
149 void multiplySymmetricUpperTriangle(
double*& dest,
const double* src)
const;
152 void rightMultiply(
double*& dest,
const double* src)
const;
155 void scale(
double a);
166 int fillCCS(
int* Cp,
int* Ci,
double* Cx,
bool upperTriangle =
false)
const;
172 int fillCCS(
double* Cx,
bool upperTriangle =
false)
const;
178 const std::vector<IntBlockMap>&
blockCols()
const {
return _blockCols;}
179 std::vector<IntBlockMap>&
blockCols() {
return _blockCols;}
193 bool writeOctave(
const char*
filename,
bool upperTriangle =
true)
const;
216 std::vector <IntBlockMap> _blockCols;
222 template <
class MatrixType >
223 std::ostream& operator << (std::ostream&, const SparseBlockMatrix<MatrixType>& m);
const std::vector< int > & rowBlockIndices() const
indices of the row blocks
std::vector< int > _rowBlockIndices
vector of the indices of the blocks along the rows.
std::vector< int > _colBlockIndices
int rowsOfBlock(int r) const
how many rows does the block at block-row r has?
int cols() const
columns of the matrix
int rows() const
rows of the matrix
representing the structure of a matrix in column compressed structure (only the upper triangular part...
int colsOfBlock(int c) const
how many cols does the block at block-col c has?
bool add(const actionlib::TwoIntsGoal &req, actionlib::TwoIntsResult &res)
MatrixType SparseMatrixBlock
this is the type of the elementary block, it is an Eigen::Matrix.
const std::vector< int > & colBlockIndices() const
indices of the column blocks
std::vector< IntBlockMap > & blockCols()
std::vector< int > & colBlockIndices()
Sparse matrix which uses blocks.
std::vector< int > & rowBlockIndices()
std::map< int, SparseMatrixBlock * > IntBlockMap
int colBaseOfBlock(int c) const
where does the col at block-col r starts?
const std::vector< IntBlockMap > & blockCols() const
the block matrices per block-column
Sparse matrix which uses blocks based on hash structures.
SparseBlockMatrix< MatrixXd > SparseBlockMatrixXd
int rowBaseOfBlock(int r) const
where does the row at block-row r starts?
Sparse matrix which uses blocks.