Eigen  5.0.1-dev+master
 
Loading...
Searching...
No Matches
CholmodSupport.h
1// This file is part of Eigen, a lightweight C++ template library
2// for linear algebra.
3//
4// Copyright (C) 2008-2010 Gael Guennebaud <gael.guennebaud@inria.fr>
5//
6// This Source Code Form is subject to the terms of the Mozilla
7// Public License v. 2.0. If a copy of the MPL was not distributed
8// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9// SPDX-License-Identifier: MPL-2.0
10
11#ifndef EIGEN_CHOLMODSUPPORT_H
12#define EIGEN_CHOLMODSUPPORT_H
13
14// IWYU pragma: private
15#include "./InternalHeaderCheck.h"
16
17namespace Eigen {
18
19namespace internal {
20
21template <typename Scalar>
22struct cholmod_configure_matrix;
23
24template <>
25struct cholmod_configure_matrix<double> {
26 template <typename CholmodType>
27 static void run(CholmodType& mat) {
28 mat.xtype = CHOLMOD_REAL;
29 mat.dtype = CHOLMOD_DOUBLE;
30 }
31};
32
33template <>
34struct cholmod_configure_matrix<std::complex<double> > {
35 template <typename CholmodType>
36 static void run(CholmodType& mat) {
37 mat.xtype = CHOLMOD_COMPLEX;
38 mat.dtype = CHOLMOD_DOUBLE;
39 }
40};
41
42// Other scalar types are not yet supported by Cholmod
43// template<> struct cholmod_configure_matrix<float> {
44// template<typename CholmodType>
45// static void run(CholmodType& mat) {
46// mat.xtype = CHOLMOD_REAL;
47// mat.dtype = CHOLMOD_SINGLE;
48// }
49// };
50//
51// template<> struct cholmod_configure_matrix<std::complex<float> > {
52// template<typename CholmodType>
53// static void run(CholmodType& mat) {
54// mat.xtype = CHOLMOD_COMPLEX;
55// mat.dtype = CHOLMOD_SINGLE;
56// }
57// };
58
59} // namespace internal
60
64template <typename Scalar_, int Options_, typename StorageIndex_>
65cholmod_sparse viewAsCholmod(Ref<SparseMatrix<Scalar_, Options_, StorageIndex_> > mat) {
66 cholmod_sparse res;
67 res.nzmax = mat.nonZeros();
68 res.nrow = mat.rows();
69 res.ncol = mat.cols();
70 res.p = mat.outerIndexPtr();
71 res.i = mat.innerIndexPtr();
72 res.x = mat.valuePtr();
73 res.z = 0;
74 res.sorted = 1;
75 if (mat.isCompressed()) {
76 res.packed = 1;
77 res.nz = 0;
78 } else {
79 res.packed = 0;
80 res.nz = mat.innerNonZeroPtr();
81 }
82
83 res.dtype = 0;
84 res.stype = -1;
85
86 EIGEN_IF_CONSTEXPR ((std::is_same<StorageIndex_, int>::value)) {
87 res.itype = CHOLMOD_INT;
88 } else EIGEN_IF_CONSTEXPR ((std::is_same<StorageIndex_, SuiteSparse_long>::value)) {
89 res.itype = CHOLMOD_LONG;
90 } else {
91 eigen_assert(false && "Index type not supported yet");
92 }
93
94 // setup res.xtype
95 internal::cholmod_configure_matrix<Scalar_>::run(res);
96
97 res.stype = 0;
98
99 return res;
100}
101
102template <typename Scalar_, int Options_, typename Index_>
103const cholmod_sparse viewAsCholmod(const SparseMatrix<Scalar_, Options_, Index_>& mat) {
104 cholmod_sparse res = viewAsCholmod(Ref<SparseMatrix<Scalar_, Options_, Index_> >(mat.const_cast_derived()));
105 return res;
106}
107
108template <typename Scalar_, int Options_, typename Index_>
109const cholmod_sparse viewAsCholmod(const SparseVector<Scalar_, Options_, Index_>& mat) {
110 cholmod_sparse res = viewAsCholmod(Ref<SparseMatrix<Scalar_, Options_, Index_> >(mat.const_cast_derived()));
111 return res;
112}
113
116template <typename Scalar_, int Options_, typename Index_, unsigned int UpLo>
117cholmod_sparse viewAsCholmod(const SparseSelfAdjointView<const SparseMatrix<Scalar_, Options_, Index_>, UpLo>& mat) {
118 cholmod_sparse res = viewAsCholmod(Ref<SparseMatrix<Scalar_, Options_, Index_> >(mat.matrix().const_cast_derived()));
119
120 EIGEN_IF_CONSTEXPR (UpLo == Upper) res.stype = 1;
121 EIGEN_IF_CONSTEXPR (UpLo == Lower) res.stype = -1;
122 // swap stype for rowmajor matrices (only works for real matrices)
123 EIGEN_STATIC_ASSERT((Options_ & RowMajorBit) == 0 || NumTraits<Scalar_>::IsComplex == 0,
124 THIS_METHOD_IS_ONLY_FOR_COLUMN_MAJOR_MATRICES);
125 EIGEN_IF_CONSTEXPR (Options_ & RowMajorBit) res.stype *= -1;
126
127 return res;
128}
129
132template <typename Derived>
133cholmod_dense viewAsCholmod(MatrixBase<Derived>& mat) {
134 EIGEN_STATIC_ASSERT((internal::traits<Derived>::Flags & RowMajorBit) == 0,
135 THIS_METHOD_IS_ONLY_FOR_COLUMN_MAJOR_MATRICES);
136 using Scalar = typename Derived::Scalar;
137
138 cholmod_dense res;
139 res.nrow = mat.rows();
140 res.ncol = mat.cols();
141 res.nzmax = res.nrow * res.ncol;
142 res.d = Derived::IsVectorAtCompileTime ? mat.derived().size() : mat.derived().outerStride();
143 res.x = (void*)(mat.derived().data());
144 res.z = 0;
145
146 internal::cholmod_configure_matrix<Scalar>::run(res);
147
148 return res;
149}
150
153template <typename Scalar, typename StorageIndex>
154Map<const SparseMatrix<Scalar, ColMajor, StorageIndex> > viewAsEigen(cholmod_sparse& cm) {
156 cm.nrow, cm.ncol, static_cast<StorageIndex*>(cm.p)[cm.ncol], static_cast<StorageIndex*>(cm.p),
157 static_cast<StorageIndex*>(cm.i), static_cast<Scalar*>(cm.x));
158}
159
162template <typename Scalar, typename StorageIndex>
163Map<const SparseMatrix<Scalar, ColMajor, StorageIndex> > viewAsEigen(cholmod_factor& cm) {
165 cm.n, cm.n, static_cast<StorageIndex*>(cm.p)[cm.n], static_cast<StorageIndex*>(cm.p),
166 static_cast<StorageIndex*>(cm.i), static_cast<Scalar*>(cm.x));
167}
168
169namespace internal {
170
171// template specializations for int and long that call the correct cholmod method
172
173#define EIGEN_CHOLMOD_SPECIALIZE0(ret, name) \
174 template <typename StorageIndex_> \
175 inline ret cm_##name(cholmod_common& Common) { \
176 return cholmod_##name(&Common); \
177 } \
178 template <> \
179 inline ret cm_##name<SuiteSparse_long>(cholmod_common & Common) { \
180 return cholmod_l_##name(&Common); \
181 }
182
183#define EIGEN_CHOLMOD_SPECIALIZE1(ret, name, t1, a1) \
184 template <typename StorageIndex_> \
185 inline ret cm_##name(t1& a1, cholmod_common& Common) { \
186 return cholmod_##name(&a1, &Common); \
187 } \
188 template <> \
189 inline ret cm_##name<SuiteSparse_long>(t1 & a1, cholmod_common & Common) { \
190 return cholmod_l_##name(&a1, &Common); \
191 }
192
193EIGEN_CHOLMOD_SPECIALIZE0(int, start)
194EIGEN_CHOLMOD_SPECIALIZE0(int, finish)
195
196EIGEN_CHOLMOD_SPECIALIZE1(int, free_factor, cholmod_factor*, L)
197EIGEN_CHOLMOD_SPECIALIZE1(int, free_dense, cholmod_dense*, X)
198EIGEN_CHOLMOD_SPECIALIZE1(int, free_sparse, cholmod_sparse*, A)
199
200EIGEN_CHOLMOD_SPECIALIZE1(cholmod_factor*, analyze, cholmod_sparse, A)
201EIGEN_CHOLMOD_SPECIALIZE1(cholmod_sparse*, factor_to_sparse, cholmod_factor, L)
202
203template <typename StorageIndex_>
204inline cholmod_dense* cm_solve(int sys, cholmod_factor& L, cholmod_dense& B, cholmod_common& Common) {
205 return cholmod_solve(sys, &L, &B, &Common);
206}
207template <>
208inline cholmod_dense* cm_solve<SuiteSparse_long>(int sys, cholmod_factor& L, cholmod_dense& B, cholmod_common& Common) {
209 return cholmod_l_solve(sys, &L, &B, &Common);
210}
211
212template <typename StorageIndex_>
213inline cholmod_sparse* cm_spsolve(int sys, cholmod_factor& L, cholmod_sparse& B, cholmod_common& Common) {
214 return cholmod_spsolve(sys, &L, &B, &Common);
215}
216template <>
217inline cholmod_sparse* cm_spsolve<SuiteSparse_long>(int sys, cholmod_factor& L, cholmod_sparse& B,
218 cholmod_common& Common) {
219 return cholmod_l_spsolve(sys, &L, &B, &Common);
220}
221
222template <typename StorageIndex_>
223inline int cm_factorize_p(cholmod_sparse* A, double beta[2], StorageIndex_* fset, std::size_t fsize, cholmod_factor* L,
224 cholmod_common& Common) {
225 return cholmod_factorize_p(A, beta, fset, fsize, L, &Common);
226}
227template <>
228inline int cm_factorize_p<SuiteSparse_long>(cholmod_sparse* A, double beta[2], SuiteSparse_long* fset,
229 std::size_t fsize, cholmod_factor* L, cholmod_common& Common) {
230 return cholmod_l_factorize_p(A, beta, fset, fsize, L, &Common);
231}
232
233#undef EIGEN_CHOLMOD_SPECIALIZE0
234#undef EIGEN_CHOLMOD_SPECIALIZE1
235
236} // namespace internal
237
238enum CholmodMode { CholmodAuto, CholmodSimplicialLLt, CholmodSupernodalLLt, CholmodLDLt };
239
245template <typename MatrixType_, int UpLo_, typename Derived>
246class CholmodBase : public SparseSolverBase<Derived> {
247 protected:
248 using Base = SparseSolverBase<Derived>;
249 using Base::derived;
250 using Base::m_isInitialized;
251
252 public:
253 using MatrixType = MatrixType_;
254 enum { UpLo = UpLo_ };
255 using Scalar = typename MatrixType::Scalar;
256 using RealScalar = typename MatrixType::RealScalar;
257 using CholMatrixType = MatrixType;
258 using StorageIndex = typename MatrixType::StorageIndex;
259 enum { ColsAtCompileTime = MatrixType::ColsAtCompileTime, MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime };
260
261 public:
262 CholmodBase() : m_cholmodFactor(0), m_info(Success), m_factorizationIsOk(false), m_analysisIsOk(false) {
263 EIGEN_STATIC_ASSERT((std::is_same<double, RealScalar>::value), CHOLMOD_SUPPORTS_DOUBLE_PRECISION_ONLY);
264 m_shiftOffset[0] = m_shiftOffset[1] = 0.0;
265 internal::cm_start<StorageIndex>(m_cholmod);
266 }
267
268 explicit CholmodBase(const MatrixType& matrix)
269 : m_cholmodFactor(0), m_info(Success), m_factorizationIsOk(false), m_analysisIsOk(false) {
270 EIGEN_STATIC_ASSERT((std::is_same<double, RealScalar>::value), CHOLMOD_SUPPORTS_DOUBLE_PRECISION_ONLY);
271 m_shiftOffset[0] = m_shiftOffset[1] = 0.0;
272 internal::cm_start<StorageIndex>(m_cholmod);
273 compute(matrix);
274 }
275
276 ~CholmodBase() {
277 if (m_cholmodFactor) internal::cm_free_factor<StorageIndex>(m_cholmodFactor, m_cholmod);
278 internal::cm_finish<StorageIndex>(m_cholmod);
279 }
280
281 inline StorageIndex cols() const { return internal::convert_index<StorageIndex, Index>(m_cholmodFactor->n); }
282 inline StorageIndex rows() const { return internal::convert_index<StorageIndex, Index>(m_cholmodFactor->n); }
283
290 eigen_assert(m_isInitialized && "Decomposition is not initialized.");
291 return m_info;
292 }
293
295 Derived& compute(const MatrixType& matrix) {
296 analyzePattern(matrix);
297 factorize(matrix);
298 return derived();
299 }
300
307 void analyzePattern(const MatrixType& matrix) {
308 if (m_cholmodFactor) {
309 internal::cm_free_factor<StorageIndex>(m_cholmodFactor, m_cholmod);
310 m_cholmodFactor = 0;
311 }
312 cholmod_sparse A = viewAsCholmod(matrix.template selfadjointView<UpLo>());
313 m_cholmodFactor = internal::cm_analyze<StorageIndex>(A, m_cholmod);
314
315 this->m_isInitialized = true;
316 this->m_info = Success;
317 m_analysisIsOk = true;
318 m_factorizationIsOk = false;
319 }
320
328 void factorize(const MatrixType& matrix) {
329 eigen_assert(m_analysisIsOk && "You must first call analyzePattern()");
330 cholmod_sparse A = viewAsCholmod(matrix.template selfadjointView<UpLo>());
331 internal::cm_factorize_p<StorageIndex>(&A, m_shiftOffset, 0, 0, m_cholmodFactor, m_cholmod);
332
333 // If the factorization failed, either the input matrix was zero (so m_cholmodFactor == nullptr), or minor is the
334 // column at which it failed. On success minor == n.
335 this->m_info =
336 (m_cholmodFactor != nullptr && m_cholmodFactor->minor == m_cholmodFactor->n ? Success : NumericalIssue);
337 m_factorizationIsOk = true;
338 }
339
342 cholmod_common& cholmod() { return m_cholmod; }
343
344#ifndef EIGEN_PARSED_BY_DOXYGEN
346 template <typename Rhs, typename Dest>
347 void _solve_impl(const MatrixBase<Rhs>& b, MatrixBase<Dest>& dest) const {
348 eigen_assert(m_factorizationIsOk &&
349 "The decomposition is not in a valid state for solving, you must first call either compute() or "
350 "symbolic()/numeric()");
351 const Index size = m_cholmodFactor->n;
352 EIGEN_UNUSED_VARIABLE(size);
353 eigen_assert(size == b.rows());
354
355 // Cholmod needs column-major storage without inner-stride, which corresponds to the default behavior of Ref.
357
358 cholmod_dense b_cd = viewAsCholmod(b_ref);
359 cholmod_dense* x_cd = internal::cm_solve<StorageIndex>(CHOLMOD_A, *m_cholmodFactor, b_cd, m_cholmod);
360 if (!x_cd) {
361 this->m_info = NumericalIssue;
362 return;
363 }
364 // TODO: optimize this copy by swapping when possible (be careful with alignment, etc.)
365 // NOTE Actually, the copy can be avoided by calling cholmod_solve2 instead of cholmod_solve
366 dest = Matrix<Scalar, Dest::RowsAtCompileTime, Dest::ColsAtCompileTime>::Map(reinterpret_cast<Scalar*>(x_cd->x),
367 b.rows(), b.cols());
368 internal::cm_free_dense<StorageIndex>(x_cd, m_cholmod);
369 }
370
372 template <typename RhsDerived, typename DestDerived>
373 void _solve_impl(const SparseMatrixBase<RhsDerived>& b, SparseMatrixBase<DestDerived>& dest) const {
374 eigen_assert(m_factorizationIsOk &&
375 "The decomposition is not in a valid state for solving, you must first call either compute() or "
376 "symbolic()/numeric()");
377 const Index size = m_cholmodFactor->n;
378 EIGEN_UNUSED_VARIABLE(size);
379 eigen_assert(size == b.rows());
380
381 // note: cs stands for Cholmod Sparse
382 Ref<SparseMatrix<typename RhsDerived::Scalar, ColMajor, typename RhsDerived::StorageIndex> > b_ref(
383 b.const_cast_derived());
384 cholmod_sparse b_cs = viewAsCholmod(b_ref);
385 cholmod_sparse* x_cs = internal::cm_spsolve<StorageIndex>(CHOLMOD_A, *m_cholmodFactor, b_cs, m_cholmod);
386 if (!x_cs) {
387 this->m_info = NumericalIssue;
388 return;
389 }
390 // TODO: optimize this copy by swapping when possible (be careful with alignment, etc.)
391 // NOTE cholmod_spsolve in fact just calls the dense solver for blocks of 4 columns at a time (similar to Eigen's
392 // sparse solver)
393 dest.derived() = viewAsEigen<typename DestDerived::Scalar, typename DestDerived::StorageIndex>(*x_cs);
394 internal::cm_free_sparse<StorageIndex>(x_cs, m_cholmod);
395 }
396#endif // EIGEN_PARSED_BY_DOXYGEN
397
407 Derived& setShift(const RealScalar& offset) {
408 m_shiftOffset[0] = double(offset);
409 return derived();
410 }
411
413 Scalar determinant() const { return numext::exp(logDeterminant()); }
414
416 Scalar logDeterminant() const {
417 eigen_assert(m_factorizationIsOk &&
418 "The decomposition is not in a valid state for solving, you must first call either compute() or "
419 "symbolic()/numeric()");
420
421 RealScalar logDet = 0;
422 Scalar* x = static_cast<Scalar*>(m_cholmodFactor->x);
423 if (m_cholmodFactor->is_super) {
424 // Supernodal factorization stored as a packed list of dense column-major blocks,
425 // as described by the following structure:
426
427 // super[k] == index of the first column of the k-th super node
428 StorageIndex* super = static_cast<StorageIndex*>(m_cholmodFactor->super);
429 // pi[k] == offset to the description of row indices
430 StorageIndex* pi = static_cast<StorageIndex*>(m_cholmodFactor->pi);
431 // px[k] == offset to the respective dense block
432 StorageIndex* px = static_cast<StorageIndex*>(m_cholmodFactor->px);
433
434 Index nb_super_nodes = m_cholmodFactor->nsuper;
435 for (Index k = 0; k < nb_super_nodes; ++k) {
436 StorageIndex ncols = super[k + 1] - super[k];
437 StorageIndex nrows = pi[k + 1] - pi[k];
438
439 Map<const Array<Scalar, 1, Dynamic>, 0, InnerStride<> > sk(x + px[k], ncols, InnerStride<>(nrows + 1));
440 logDet += sk.real().log().sum();
441 }
442 } else {
443 // Simplicial factorization stored as standard CSC matrix.
444 StorageIndex* p = static_cast<StorageIndex*>(m_cholmodFactor->p);
445 Index size = m_cholmodFactor->n;
446 for (Index k = 0; k < size; ++k) logDet += numext::log(numext::real(x[p[k]]));
447 }
448 if (m_cholmodFactor->is_ll) logDet *= 2.0;
449 return logDet;
450 }
451
452 template <typename Stream>
453 void dumpMemory(Stream& /*s*/) {}
454
455 protected:
456 mutable cholmod_common m_cholmod;
457 cholmod_factor* m_cholmodFactor;
458 double m_shiftOffset[2];
459 mutable ComputationInfo m_info;
460 int m_factorizationIsOk;
461 int m_analysisIsOk;
462};
463
487template <typename MatrixType_, int UpLo_ = Lower>
488class CholmodSimplicialLLT : public CholmodBase<MatrixType_, UpLo_, CholmodSimplicialLLT<MatrixType_, UpLo_> > {
489 using Base = CholmodBase<MatrixType_, UpLo_, CholmodSimplicialLLT>;
490 using Base::m_cholmod;
491
492 public:
493 using MatrixType = MatrixType_;
494 using Scalar = typename MatrixType::Scalar;
495 using RealScalar = typename MatrixType::RealScalar;
496 using StorageIndex = typename MatrixType::StorageIndex;
499
500 CholmodSimplicialLLT() : Base() { init(); }
501
502 CholmodSimplicialLLT(const MatrixType& matrix) : Base() {
503 init();
504 this->compute(matrix);
505 }
506
508 inline MatrixL matrixL() const { return viewAsEigen<Scalar, StorageIndex>(*Base::m_cholmodFactor); }
509
511 inline MatrixU matrixU() const { return matrixL().adjoint(); }
512
513 protected:
514 void init() {
515 m_cholmod.final_asis = 0;
516 m_cholmod.supernodal = CHOLMOD_SIMPLICIAL;
517 m_cholmod.final_ll = 1;
518 }
519};
520
544template <typename MatrixType_, int UpLo_ = Lower>
545class CholmodSimplicialLDLT : public CholmodBase<MatrixType_, UpLo_, CholmodSimplicialLDLT<MatrixType_, UpLo_> > {
546 using Base = CholmodBase<MatrixType_, UpLo_, CholmodSimplicialLDLT>;
547 using Base::m_cholmod;
548
549 public:
550 using MatrixType = MatrixType_;
551 using Scalar = typename MatrixType::Scalar;
552 using RealScalar = typename MatrixType::RealScalar;
553 using StorageIndex = typename MatrixType::StorageIndex;
554 using VectorType = Matrix<Scalar, Dynamic, 1>;
557
558 CholmodSimplicialLDLT() : Base() { init(); }
559
560 CholmodSimplicialLDLT(const MatrixType& matrix) : Base() {
561 init();
562 this->compute(matrix);
563 }
564
566 inline VectorType vectorD() const {
567 auto cholmodL = viewAsEigen<Scalar, StorageIndex>(*Base::m_cholmodFactor);
568
569 VectorType D{cholmodL.rows()};
570
571 for (Index k = 0; k < cholmodL.outerSize(); ++k) {
572 typename decltype(cholmodL)::InnerIterator it{cholmodL, k};
573 D(k) = it.value();
574 }
575
576 return D;
577 }
578
580 inline MatrixL matrixL() const { return viewAsEigen<Scalar, StorageIndex>(*Base::m_cholmodFactor); }
581
583 inline MatrixU matrixU() const { return matrixL().adjoint(); }
584
585 protected:
586 void init() {
587 m_cholmod.final_asis = 1;
588 m_cholmod.supernodal = CHOLMOD_SIMPLICIAL;
589 }
590};
591
615template <typename MatrixType_, int UpLo_ = Lower>
616class CholmodSupernodalLLT : public CholmodBase<MatrixType_, UpLo_, CholmodSupernodalLLT<MatrixType_, UpLo_> > {
617 using Base = CholmodBase<MatrixType_, UpLo_, CholmodSupernodalLLT>;
618 using Base::m_cholmod;
619
620 public:
621 using MatrixType = MatrixType_;
622 using Scalar = typename MatrixType::Scalar;
623 using RealScalar = typename MatrixType::RealScalar;
624 using StorageIndex = typename MatrixType::StorageIndex;
625
626 CholmodSupernodalLLT() : Base() { init(); }
627
628 CholmodSupernodalLLT(const MatrixType& matrix) : Base() {
629 init();
630 this->compute(matrix);
631 }
632
634 inline MatrixType matrixL() const {
635 // Convert Cholmod factor's supernodal storage format to Eigen's CSC storage format
636 cholmod_sparse* cholmodL = internal::cm_factor_to_sparse(*Base::m_cholmodFactor, m_cholmod);
637 MatrixType L = viewAsEigen<Scalar, StorageIndex>(*cholmodL);
638 internal::cm_free_sparse<StorageIndex>(cholmodL, m_cholmod);
639
640 return L;
641 }
642
644 inline MatrixType matrixU() const { return matrixL().adjoint(); }
645
646 protected:
647 void init() {
648 m_cholmod.final_asis = 1;
649 m_cholmod.supernodal = CHOLMOD_SUPERNODAL;
650 }
651};
652
678template <typename MatrixType_, int UpLo_ = Lower>
679class CholmodDecomposition : public CholmodBase<MatrixType_, UpLo_, CholmodDecomposition<MatrixType_, UpLo_> > {
680 using Base = CholmodBase<MatrixType_, UpLo_, CholmodDecomposition>;
681 using Base::m_cholmod;
682
683 public:
684 using MatrixType = MatrixType_;
685
686 CholmodDecomposition() : Base() { init(); }
687
688 CholmodDecomposition(const MatrixType& matrix) : Base() {
689 init();
690 this->compute(matrix);
691 }
692
693 void setMode(CholmodMode mode) {
694 switch (mode) {
695 case CholmodAuto:
696 m_cholmod.final_asis = 1;
697 m_cholmod.supernodal = CHOLMOD_AUTO;
698 break;
699 case CholmodSimplicialLLt:
700 m_cholmod.final_asis = 0;
701 m_cholmod.supernodal = CHOLMOD_SIMPLICIAL;
702 m_cholmod.final_ll = 1;
703 break;
704 case CholmodSupernodalLLt:
705 m_cholmod.final_asis = 1;
706 m_cholmod.supernodal = CHOLMOD_SUPERNODAL;
707 break;
708 case CholmodLDLt:
709 m_cholmod.final_asis = 1;
710 m_cholmod.supernodal = CHOLMOD_SIMPLICIAL;
711 break;
712 default:
713 break;
714 }
715 }
716
717 protected:
718 void init() {
719 m_cholmod.final_asis = 1;
720 m_cholmod.supernodal = CHOLMOD_AUTO;
721 }
722};
723
724} // end namespace Eigen
725
726#endif // EIGEN_CHOLMODSUPPORT_H
void factorize(const MatrixType &matrix)
Definition CholmodSupport.h:328
ComputationInfo info() const
Reports whether previous computation was successful.
Definition CholmodSupport.h:289
Scalar determinant() const
Definition CholmodSupport.h:413
Derived & setShift(const RealScalar &offset)
Definition CholmodSupport.h:407
Derived & compute(const MatrixType &matrix)
Definition CholmodSupport.h:295
Scalar logDeterminant() const
Definition CholmodSupport.h:416
cholmod_common & cholmod()
Definition CholmodSupport.h:342
void analyzePattern(const MatrixType &matrix)
Definition CholmodSupport.h:307
MatrixU matrixU() const
Definition CholmodSupport.h:583
VectorType vectorD() const
Definition CholmodSupport.h:566
MatrixL matrixL() const
Definition CholmodSupport.h:580
MatrixL matrixL() const
Definition CholmodSupport.h:508
MatrixU matrixU() const
Definition CholmodSupport.h:511
MatrixType matrixU() const
Definition CholmodSupport.h:644
MatrixType matrixL() const
Definition CholmodSupport.h:634
An InnerIterator allows to loop over the element of any matrix expression.
Definition CoreIterators.h:38
Scalar value() const
Definition CoreIterators.h:49
Convenience specialization of Stride to specify only an inner stride See class Map for some examples.
Definition Stride.h:93
A matrix or vector expression mapping an existing array of data.
Definition Map.h:97
Base class for all dense matrices, vectors, and expressions.
Definition MatrixBase.h:53
The matrix class, also used for vectors and row-vectors.
Definition Matrix.h:188
A matrix or vector expression mapping an existing expression.
Definition Ref.h:261
A versatile sparse matrix representation.
Definition SparseMatrix.h:121
Pseudo expression to manipulate a triangular sparse matrix as a selfadjoint matrix.
Definition SparseSelfAdjointView.h:53
a sparse vector class
Definition SparseVector.h:63
Expression of a triangular part in a matrix.
Definition TriangularMatrix.h:426
ComputationInfo
Definition Constants.h:455
@ Lower
Definition Constants.h:212
@ Upper
Definition Constants.h:214
@ NumericalIssue
Definition Constants.h:459
@ Success
Definition Constants.h:457
constexpr unsigned int RowMajorBit
Definition Constants.h:71