27#ifndef G2O_LINEAR_SOLVER_H
28#define G2O_LINEAR_SOLVER_H
46template <
typename MatrixType>
84 const std::vector<std::pair<int, int> >& blockIndices,
99 blocks =
new double*[A.
rows()];
100 double** block = blocks;
103 *block =
new double[dim];
121 template <
typename BlockDerived,
typename ScalarDerived>
124 const Eigen::MatrixBase<BlockDerived>& p,
125 const Eigen::MatrixBase<ScalarDerived>& scalar ) {
127 Eigen::MatrixBase<ScalarDerived>& scalarPermutation =
128 const_cast<Eigen::MatrixBase<ScalarDerived>&
>(scalar);
129 if (scalarPermutation.size() == 0) scalarPermutation.derived().resize(n);
130 if (scalarPermutation.size() < n) scalarPermutation.derived().resize(2 * n);
131 size_t scalarIdx = 0;
135 for (
int j = 0; j < nCols; ++j) {
136 scalarPermutation(scalarIdx++) = base++;
139 assert((
int)scalarIdx == n);
149template <
typename MatrixType>
167 const std::vector<std::pair<int, int> >& blockIndices,
Solver with faster iterating structure for the linear matrix.
void initMatrixStructure(const SparseBlockMatrix< MatrixType > &A)
SparseBlockMatrixCCS< MatrixType > * _ccsMatrix
virtual bool solvePattern(SparseBlockMatrix< MatrixX > &spinv, const std::vector< std::pair< int, int > > &blockIndices, const SparseBlockMatrix< MatrixType > &A)
virtual bool solveBlocks(double **&blocks, const SparseBlockMatrix< MatrixType > &A)
void setBlockOrdering(bool blockOrdering)
virtual bool solveBlocks_impl(const SparseBlockMatrix< MatrixType > &A, std::function< void(MarginalCovarianceCholesky &)> compute)=0
bool blockOrdering() const
do the AMD ordering on the blocks or on the scalar matrix
static void allocateBlocks(const SparseBlockMatrix< MatrixType > &A, double **&blocks)
allocate block memory structure
virtual bool solveBlocks(double **&blocks, const SparseBlockMatrix< MatrixType > &A)
static void deallocateBlocks(const SparseBlockMatrix< MatrixType > &A, double **&blocks)
de-allocate the block structure
void setWriteDebug(bool b)
bool writeDebug() const
write a debug dump of the system matrix if it is not PSD in solve
virtual bool solve(const SparseBlockMatrix< MatrixType > &A, double *x, double *b)=0
static void blockToScalarPermutation(const SparseBlockMatrix< MatrixType > &A, const Eigen::MatrixBase< BlockDerived > &p, const Eigen::MatrixBase< ScalarDerived > &scalar)
virtual bool solvePattern(SparseBlockMatrix< MatrixX > &spinv, const std::vector< std::pair< int, int > > &blockIndices, const SparseBlockMatrix< MatrixType > &A)
computing the marginal covariance given a cholesky factor (lower triangle of the factor)
Sparse matrix which uses blocks.
Sparse matrix which uses blocks.
int colBaseOfBlock(int c) const
where does the col at block-col r starts?
int rowsOfBlock(int r) const
how many rows does the block at block-row r has?
int fillSparseBlockMatrixCCS(SparseBlockMatrixCCS< MatrixType > &blockCCS) const
const std::vector< int > & colBlockIndices() const
indices of the column blocks
int rows() const
rows of the matrix
int cols() const
columns of the matrix
const std::vector< int > & rowBlockIndices() const
indices of the row blocks
int colsOfBlock(int c) const
how many cols does the block at block-col c has?