g2o
Loading...
Searching...
No Matches
Classes | Public Member Functions | Private Attributes | List of all members
g2o::cholmod::Cholmod Class Reference

#include <cholmod_wrapper.h>

Classes

struct  FactorView
 View onto the cholesky factor. More...
 
class  Impl
 
struct  SparseView
 View onto the sparse matrix structure of Cholmod using CCS storage. More...
 

Public Member Functions

 Cholmod ()
 
 ~Cholmod ()
 
bool factorize ()
 
bool hasFactor () const
 
void freeFactor ()
 
bool simplifyFactor ()
 
bool amd (SparseView &sparseView, int *result)
 compute AMD ordering on the given SparseView, store into result
 
int choleskyNz () const
 
void solve (double *x, double *b) const
 
bool analyze ()
 
bool analyze_p (int *permutation)
 
SparseView sparseView ()
 
FactorView factor ()
 

Private Attributes

std::unique_ptr< ImplpImpl
 

Detailed Description

Definition at line 36 of file cholmod_wrapper.h.

Constructor & Destructor Documentation

◆ Cholmod()

g2o::cholmod::Cholmod::Cholmod ( )

Definition at line 70 of file cholmod_wrapper.cpp.

70: pImpl(std::make_unique<Impl>()) {}
std::unique_ptr< Impl > pImpl

◆ ~Cholmod()

g2o::cholmod::Cholmod::~Cholmod ( )
default

Member Function Documentation

◆ amd()

bool g2o::cholmod::Cholmod::amd ( SparseView sparseView,
int *  result 
)

compute AMD ordering on the given SparseView, store into result

Definition at line 78 of file cholmod_wrapper.cpp.

78 {
79 cholmod_sparse auxCholmodSparse;
80 auxCholmodSparse.nzmax = sparseView.nzmax;
81 auxCholmodSparse.nrow = sparseView.nrow;
82 auxCholmodSparse.ncol = sparseView.ncol;
83 auxCholmodSparse.p = sparseView.p;
84 auxCholmodSparse.i = sparseView.i;
85 auxCholmodSparse.nz = 0;
86 auxCholmodSparse.x = 0;
87 auxCholmodSparse.z = 0;
88 auxCholmodSparse.stype = 1;
89 auxCholmodSparse.xtype = CHOLMOD_PATTERN;
90 auxCholmodSparse.itype = CHOLMOD_INT;
91 auxCholmodSparse.dtype = CHOLMOD_DOUBLE;
92 auxCholmodSparse.sorted = 1;
93 auxCholmodSparse.packed = 1;
94
95 int amdStatus =
96 cholmod_amd(&auxCholmodSparse, NULL, 0, result, &pImpl->cholmodCommon);
97 return amdStatus != 0;
98}

References g2o::cholmod::Cholmod::SparseView::i, g2o::cholmod::Cholmod::SparseView::ncol, g2o::cholmod::Cholmod::SparseView::nrow, g2o::cholmod::Cholmod::SparseView::nzmax, g2o::cholmod::Cholmod::SparseView::p, pImpl, and sparseView().

Referenced by g2o::LinearSolverCholmod< MatrixType >::computeSymbolicDecomposition().

◆ analyze()

bool g2o::cholmod::Cholmod::analyze ( )

Definition at line 131 of file cholmod_wrapper.cpp.

131 {
132 // setup ordering strategy
133 pImpl->cholmodCommon.nmethods = 1;
134 pImpl->cholmodCommon.method[0].ordering = CHOLMOD_AMD; // CHOLMOD_COLAMD
135 pImpl->cholmodFactor =
136 cholmod_analyze(&pImpl->cholmodSparse,
137 &pImpl->cholmodCommon); // symbolic factorization
138 return true;
139}

References pImpl.

Referenced by g2o::LinearSolverCholmod< MatrixType >::computeSymbolicDecomposition().

◆ analyze_p()

bool g2o::cholmod::Cholmod::analyze_p ( int *  permutation)

Definition at line 141 of file cholmod_wrapper.cpp.

141 {
142 pImpl->cholmodCommon.nmethods = 1;
143 pImpl->cholmodCommon.method[0].ordering = CHOLMOD_GIVEN;
144 pImpl->cholmodFactor = cholmod_analyze_p(&pImpl->cholmodSparse, permutation,
145 NULL, 0, &pImpl->cholmodCommon);
146 return true;
147}

References pImpl.

Referenced by g2o::LinearSolverCholmod< MatrixType >::computeSymbolicDecomposition().

◆ choleskyNz()

int g2o::cholmod::Cholmod::choleskyNz ( ) const

Definition at line 149 of file cholmod_wrapper.cpp.

149 {
150 return static_cast<int>(pImpl->cholmodCommon.method[0].lnz);
151}

References pImpl.

Referenced by g2o::LinearSolverCholmod< MatrixType >::solve(), and g2o::LinearSolverCholmod< MatrixType >::solveBlocks_impl().

◆ factor()

Cholmod::FactorView g2o::cholmod::Cholmod::factor ( )

Definition at line 108 of file cholmod_wrapper.cpp.

108 {
109 cholmod_factor& factor = *pImpl->cholmodFactor;
110 return Cholmod::FactorView(factor.n, *reinterpret_cast<int**>(&factor.p),
111 *reinterpret_cast<int**>(&factor.i),
112 *reinterpret_cast<double**>(&factor.x),
113 *reinterpret_cast<int**>(&factor.Perm));
114}

References factor(), g2o::cholmod::Cholmod::FactorView::i, g2o::cholmod::Cholmod::FactorView::n, g2o::cholmod::Cholmod::FactorView::p, pImpl, and g2o::cholmod::Cholmod::FactorView::x.

Referenced by factor(), and g2o::LinearSolverCholmod< MatrixType >::solveBlocks_impl().

◆ factorize()

bool g2o::cholmod::Cholmod::factorize ( )

Definition at line 153 of file cholmod_wrapper.cpp.

153 {
154 cholmod_factorize(&pImpl->cholmodSparse, pImpl->cholmodFactor,
155 &pImpl->cholmodCommon);
156 return pImpl->cholmodCommon.status == CHOLMOD_OK;
157}

References pImpl.

Referenced by g2o::LinearSolverCholmod< MatrixType >::computeCholmodFactor().

◆ freeFactor()

void g2o::cholmod::Cholmod::freeFactor ( )

Definition at line 74 of file cholmod_wrapper.cpp.

74{ pImpl->freeFactor(); }

References pImpl.

Referenced by g2o::LinearSolverCholmod< MatrixType >::freeCholdmodFactor().

◆ hasFactor()

bool g2o::cholmod::Cholmod::hasFactor ( ) const

Definition at line 76 of file cholmod_wrapper.cpp.

76{ return pImpl->cholmodFactor != nullptr; }

References pImpl.

Referenced by g2o::LinearSolverCholmod< MatrixType >::computeCholmodFactor().

◆ simplifyFactor()

bool g2o::cholmod::Cholmod::simplifyFactor ( )

Definition at line 159 of file cholmod_wrapper.cpp.

159 {
160 // convert the factorization to LL, simplical, packed, monotonic
161 int change_status = cholmod_change_factor(
162 CHOLMOD_REAL, 1, 0, 1, 1, pImpl->cholmodFactor, &pImpl->cholmodCommon);
163 assert(pImpl->cholmodFactor->is_ll && !pImpl->cholmodFactor->is_super &&
164 pImpl->cholmodFactor->is_monotonic &&
165 "Cholesky factor has wrong format");
166 return change_status != 0;
167}

References pImpl.

Referenced by g2o::LinearSolverCholmod< MatrixType >::solveBlocks_impl().

◆ solve()

void g2o::cholmod::Cholmod::solve ( double *  x,
double *  b 
) const

Definition at line 116 of file cholmod_wrapper.cpp.

116 {
117 // setting up b for calling cholmod
118 cholmod_dense bcholmod;
119 bcholmod.nrow = bcholmod.d = pImpl->cholmodSparse.nrow;
120 bcholmod.ncol = 1;
121 bcholmod.x = b;
122 bcholmod.xtype = CHOLMOD_REAL;
123 bcholmod.dtype = CHOLMOD_DOUBLE;
124 cholmod_dense* xcholmod = cholmod_solve(CHOLMOD_A, pImpl->cholmodFactor,
125 &bcholmod, &pImpl->cholmodCommon);
126 std::memcpy(x, xcholmod->x,
127 sizeof(double) * bcholmod.nrow); // copy back to our array
128 cholmod_free_dense(&xcholmod, &pImpl->cholmodCommon);
129}

References pImpl.

Referenced by g2o::LinearSolverCholmod< MatrixType >::solve().

◆ sparseView()

Cholmod::SparseView g2o::cholmod::Cholmod::sparseView ( )

Definition at line 100 of file cholmod_wrapper.cpp.

100 {
101 CholmodExt& sparse = pImpl->cholmodSparse;
102 return Cholmod::SparseView(
103 sparse.nrow, sparse.ncol, sparse.nzmax,
104 *reinterpret_cast<int**>(&sparse.p), *reinterpret_cast<int**>(&sparse.i),
105 *reinterpret_cast<double**>(&sparse.x), sparse.columnsAllocated);
106}

References g2o::cholmod::CholmodExt::columnsAllocated, and pImpl.

Referenced by amd(), g2o::LinearSolverCholmod< MatrixType >::fillCholmodExt(), g2o::LinearSolverCholmod< MatrixType >::saveMatrix(), and g2o::LinearSolverCholmod< MatrixType >::solveBlocks_impl().

Member Data Documentation

◆ pImpl

std::unique_ptr<Impl> g2o::cholmod::Cholmod::pImpl
private

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