27#ifndef G2O_LINEAR_SOLVER_CHOLMOD
28#define G2O_LINEAR_SOLVER_CHOLMOD
46template <
typename MatrixType>
65 if (!cholState)
return false;
81 sparseView.
i, sparseView.
x,
true);
108 size_t structureAllocated = structureDim;
109 double* structureX =
nullptr;
114 if (!amdStatus)
return;
131 assert(m > 0 && n > 0 &&
"Hessian has 0 rows/cols");
139 delete[] cholmodSparse.
p;
144 if (cholmodSparse.
nzmax < nzmax) {
146 cholmodSparse.
nzmax = cholmodSparse.
nzmax == 0 ? nzmax : 2 * nzmax;
147 delete[] cholmodSparse.
x;
148 delete[] cholmodSparse.
i;
149 cholmodSparse.
i =
new int[cholmodSparse.
nzmax];
150 cholmodSparse.
x =
new double[cholmodSparse.
nzmax];
153 cholmodSparse.
ncol = n;
154 cholmodSparse.
nrow = m;
157 this->
_ccsMatrix->fillCCS((
double*)cholmodSparse.
x,
true);
159 this->
_ccsMatrix->fillCCS((
int*)cholmodSparse.
p, (
int*)cholmodSparse.
i,
160 (
double*)cholmodSparse.
x,
true);
180 "Cholesky failure, writing debug.txt (Hessian loadable by Octave)");
195 if (!cholState)
return false;
199 if (!change_status)
return false;
205 int* p = cholmodFactor.
perm;
207 for (
size_t i = 0; i < cholmodSparse.
ncol; ++i) pinv(p[i]) = i;
212 cholmodFactor.
x, pinv.data());
Solver with faster iterating structure for the linear matrix.
void initMatrixStructure(const SparseBlockMatrix< MatrixType > &A)
SparseBlockMatrixCCS< MatrixType > * _ccsMatrix
bool blockOrdering() const
do the AMD ordering on the blocks or on the scalar matrix
basic solver for Ax = b which has to reimplemented for different linear algebra libraries
LinearSolverCholmod(LinearSolverCholmod< MatrixType > const &)=delete
bool solveBlocks_impl(const SparseBlockMatrix< MatrixType > &A, std::function< void(MarginalCovarianceCholesky &)> compute)
void computeSymbolicDecomposition(const SparseBlockMatrix< MatrixType > &A)
cholmod::Cholmod _cholmod
void fillCholmodExt(const SparseBlockMatrix< MatrixType > &A, bool onlyValues)
virtual ~LinearSolverCholmod()
VectorXI _blockPermutation
bool solve(const SparseBlockMatrix< MatrixType > &A, double *x, double *b)
virtual bool saveMatrix(const std::string &fileName)
VectorXI _scalarPermutation
bool computeCholmodFactor(const SparseBlockMatrix< MatrixType > &A, double &t)
compute the cholmodFactor for the given matrix A
void freeCholdmodFactor()
LinearSolverCholmod & operator=(LinearSolverCholmod< MatrixType > const &)=delete
MatrixStructure _matrixStructure
bool writeDebug() const
write a debug dump of the system matrix if it is not PSD in solve
static void blockToScalarPermutation(const SparseBlockMatrix< MatrixType > &A, const Eigen::MatrixBase< BlockDerived > &p, const Eigen::MatrixBase< ScalarDerived > &scalar)
computing the marginal covariance given a cholesky factor (lower triangle of the factor)
void setCholeskyFactor(int n, int *Lp, int *Li, double *Lx, int *permInv)
representing the structure of a matrix in column compressed structure (only the upper triangular part...
int * Aii
row indices of A, of size nz = Ap [n]
int n
A is m-by-n. n must be >= 0.
int nzMax() const
max number of non-zeros blocks
int * Ap
column pointers for A, of size n+1
Sparse matrix which uses blocks.
size_t nonZeros() const
number of non-zero elements
int rows() const
rows of the matrix
int cols() const
columns of the matrix
void fillBlockStructure(MatrixStructure &ms) const
exports the non zero blocks in the structure matrix ms
bool amd(SparseView &sparseView, int *result)
compute AMD ordering on the given SparseView, store into result
bool analyze_p(int *permutation)
void solve(double *x, double *b) const
bool writeCCSMatrix(const string &filename, int rows, int cols, const int *Ap, const int *Ai, const double *Ax, bool upperTriangleSymmetric)
Eigen::Matrix< int, Eigen::Dynamic, 1, Eigen::ColMajor > VectorXI
double get_monotonic_time()
statistics about the optimization
static G2OBatchStatistics * globalStats()
double timeNumericDecomposition
numeric decomposition (0 if not done)
double timeSymbolicDecomposition
symbolic decomposition (0 if not done)
size_t choleskyNNZ
number of non-zeros in the cholesky factor
View onto the cholesky factor.
View onto the sparse matrix structure of Cholmod using CCS storage.
size_t & columnsAllocated
utility functions for handling time related stuff