10 #ifndef EIGEN_CHOLMODSUPPORT_H
11 #define EIGEN_CHOLMODSUPPORT_H
20 template <
typename Scalar>
25 template <
typename CholmodType>
27 mat.xtype = CHOLMOD_REAL;
28 mat.dtype = CHOLMOD_DOUBLE;
34 template <
typename CholmodType>
36 mat.xtype = CHOLMOD_COMPLEX;
37 mat.dtype = CHOLMOD_DOUBLE;
63 template <
typename Scalar_,
int Options_,
typename StorageIndex_>
86 res.itype = CHOLMOD_INT;
88 res.itype = CHOLMOD_LONG;
101 template <
typename Scalar_,
int Options_,
typename Index_>
107 template <
typename Scalar_,
int Options_,
typename Index_>
115 template <
typename Scalar_,
int Options_,
typename Index_,
unsigned int UpLo>
123 THIS_METHOD_IS_ONLY_FOR_COLUMN_MAJOR_MATRICES);
131 template <
typename Derived>
134 THIS_METHOD_IS_ONLY_FOR_COLUMN_MAJOR_MATRICES);
152 template <
typename Scalar,
typename StorageIndex>
155 cm.nrow, cm.ncol,
static_cast<StorageIndex*
>(cm.p)[cm.ncol],
static_cast<StorageIndex*
>(cm.p),
156 static_cast<StorageIndex*
>(cm.i),
static_cast<Scalar*
>(cm.x));
161 template <
typename Scalar,
typename StorageIndex>
164 cm.n, cm.n,
static_cast<StorageIndex*
>(cm.p)[cm.n],
static_cast<StorageIndex*
>(cm.p),
165 static_cast<StorageIndex*
>(cm.i),
static_cast<Scalar*
>(cm.x));
172 #define EIGEN_CHOLMOD_SPECIALIZE0(ret, name) \
173 template <typename StorageIndex_> \
174 inline ret cm_##name(cholmod_common& Common) { \
175 return cholmod_##name(&Common); \
178 inline ret cm_##name<SuiteSparse_long>(cholmod_common & Common) { \
179 return cholmod_l_##name(&Common); \
182 #define EIGEN_CHOLMOD_SPECIALIZE1(ret, name, t1, a1) \
183 template <typename StorageIndex_> \
184 inline ret cm_##name(t1& a1, cholmod_common& Common) { \
185 return cholmod_##name(&a1, &Common); \
188 inline ret cm_##name<SuiteSparse_long>(t1 & a1, cholmod_common & Common) { \
189 return cholmod_l_##name(&a1, &Common); \
202 template <
typename StorageIndex_>
203 inline cholmod_dense*
cm_solve(
int sys, cholmod_factor&
L, cholmod_dense&
B, cholmod_common& Common) {
204 return cholmod_solve(sys, &
L, &
B, &Common);
208 return cholmod_l_solve(sys, &
L, &
B, &Common);
211 template <
typename StorageIndex_>
212 inline cholmod_sparse*
cm_spsolve(
int sys, cholmod_factor&
L, cholmod_sparse&
B, cholmod_common& Common) {
213 return cholmod_spsolve(sys, &
L, &
B, &Common);
217 cholmod_common& Common) {
218 return cholmod_l_spsolve(sys, &
L, &
B, &Common);
221 template <
typename StorageIndex_>
222 inline int cm_factorize_p(cholmod_sparse*
A,
double beta[2], StorageIndex_* fset, std::size_t fsize, cholmod_factor*
L,
223 cholmod_common& Common) {
224 return cholmod_factorize_p(
A,
beta, fset, fsize,
L, &Common);
228 std::size_t fsize, cholmod_factor*
L, cholmod_common& Common) {
229 return cholmod_l_factorize_p(
A,
beta, fset, fsize,
L, &Common);
232 #undef EIGEN_CHOLMOD_SPECIALIZE0
233 #undef EIGEN_CHOLMOD_SPECIALIZE1
244 template <
typename MatrixType_,
int UpLo_,
typename Derived>
264 internal::cm_start<StorageIndex>(
m_cholmod);
271 internal::cm_start<StorageIndex>(
m_cholmod);
277 internal::cm_finish<StorageIndex>(
m_cholmod);
343 #ifndef EIGEN_PARSED_BY_DOXYGEN
345 template <
typename Rhs,
typename Dest>
348 "The decomposition is not in a valid state for solving, you must first call either compute() or "
349 "symbolic()/numeric()");
367 internal::cm_free_dense<StorageIndex>(x_cd,
m_cholmod);
371 template <
typename RhsDerived,
typename DestDerived>
374 "The decomposition is not in a valid state for solving, you must first call either compute() or "
375 "symbolic()/numeric()");
382 b.const_cast_derived());
392 dest.
derived() = viewAsEigen<typename DestDerived::Scalar, typename DestDerived::StorageIndex>(*x_cs);
393 internal::cm_free_sparse<StorageIndex>(x_cs,
m_cholmod);
422 "The decomposition is not in a valid state for solving, you must first call either compute() or "
423 "symbolic()/numeric()");
439 for (
Index k = 0;
k < nb_super_nodes; ++
k) {
444 logDet += sk.real().log().sum();
456 template <
typename Stream>
491 template <
typename MatrixType_,
int UpLo_ = Lower>
522 m_cholmod.supernodal = CHOLMOD_SIMPLICIAL;
550 template <
typename MatrixType_,
int UpLo_ = Lower>
579 for (
Index k = 0;
k < cholmodL.outerSize(); ++
k) {
596 m_cholmod.supernodal = CHOLMOD_SIMPLICIAL;
623 template <
typename MatrixType_,
int UpLo_ = Lower>
647 MatrixType L = viewAsEigen<Scalar, StorageIndex>(*cholmodL);
648 internal::cm_free_sparse<StorageIndex>(cholmodL,
m_cholmod);
659 m_cholmod.supernodal = CHOLMOD_SUPERNODAL;
688 template <
typename MatrixType_,
int UpLo_ = Lower>
713 m_cholmod.supernodal = CHOLMOD_SIMPLICIAL;
718 m_cholmod.supernodal = CHOLMOD_SUPERNODAL;
722 m_cholmod.supernodal = CHOLMOD_SIMPLICIAL;
#define EIGEN_CHOLMOD_SPECIALIZE1(ret, name, t1, a1)
Definition: CholmodSupport.h:182
#define EIGEN_CHOLMOD_SPECIALIZE0(ret, name)
Definition: CholmodSupport.h:172
dominoes D
Definition: Domino.cpp:55
MatrixXd L
Definition: LLT_example.cpp:6
#define EIGEN_UNUSED_VARIABLE(var)
Definition: Macros.h:966
#define eigen_assert(x)
Definition: Macros.h:910
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
Definition: PartialRedux_count.cpp:3
#define EIGEN_STATIC_ASSERT(X, MSG)
Definition: StaticAssert.h:26
float * p
Definition: Tutorial_Map_using.cpp:9
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
Scalar * b
Definition: benchVecAdd.cpp:17
SCALAR Scalar
Definition: bench_gemm.cpp:45
Matrix< SCALARA, Dynamic, Dynamic, opt_A > A
Definition: bench_gemm.cpp:47
NumTraits< Scalar >::Real RealScalar
Definition: bench_gemm.cpp:46
The base class for the direct Cholesky factorization of Cholmod.
Definition: CholmodSupport.h:245
CholmodBase()
Definition: CholmodSupport.h:261
int m_factorizationIsOk
Definition: CholmodSupport.h:464
MatrixType CholMatrixType
Definition: CholmodSupport.h:256
void factorize(const MatrixType &matrix)
Definition: CholmodSupport.h:327
@ UpLo
Definition: CholmodSupport.h:253
ComputationInfo info() const
Reports whether previous computation was successful.
Definition: CholmodSupport.h:288
~CholmodBase()
Definition: CholmodSupport.h:275
cholmod_common & cholmod()
Definition: CholmodSupport.h:341
Scalar determinant() const
Definition: CholmodSupport.h:412
SparseSolverBase< Derived > Base
Definition: CholmodSupport.h:247
CholmodBase(const MatrixType &matrix)
Definition: CholmodSupport.h:267
MatrixType::Scalar Scalar
Definition: CholmodSupport.h:254
MatrixType::RealScalar RealScalar
Definition: CholmodSupport.h:255
@ ColsAtCompileTime
Definition: CholmodSupport.h:258
@ MaxColsAtCompileTime
Definition: CholmodSupport.h:258
StorageIndex cols() const
Definition: CholmodSupport.h:280
Derived & compute(const MatrixType &matrix)
Definition: CholmodSupport.h:294
ComputationInfo m_info
Definition: CholmodSupport.h:463
Scalar logDeterminant() const
Definition: CholmodSupport.h:418
void _solve_impl(const SparseMatrixBase< RhsDerived > &b, SparseMatrixBase< DestDerived > &dest) const
Definition: CholmodSupport.h:372
StorageIndex rows() const
Definition: CholmodSupport.h:281
void dumpMemory(Stream &)
Definition: CholmodSupport.h:457
cholmod_factor * m_cholmodFactor
Definition: CholmodSupport.h:461
bool m_isInitialized
Definition: SparseSolverBase.h:110
Derived & setShift(const RealScalar &offset)
Definition: CholmodSupport.h:406
double m_shiftOffset[2]
Definition: CholmodSupport.h:462
cholmod_common m_cholmod
Definition: CholmodSupport.h:460
MatrixType::StorageIndex StorageIndex
Definition: CholmodSupport.h:257
void _solve_impl(const MatrixBase< Rhs > &b, MatrixBase< Dest > &dest) const
Definition: CholmodSupport.h:346
Derived & derived()
Definition: SparseSolverBase.h:76
int m_analysisIsOk
Definition: CholmodSupport.h:465
MatrixType_ MatrixType
Definition: CholmodSupport.h:252
void analyzePattern(const MatrixType &matrix)
Definition: CholmodSupport.h:306
A general Cholesky factorization and solver based on Cholmod.
Definition: CholmodSupport.h:689
void init()
Definition: CholmodSupport.h:730
MatrixType_ MatrixType
Definition: CholmodSupport.h:694
~CholmodDecomposition()
Definition: CholmodSupport.h:703
CholmodDecomposition(const MatrixType &matrix)
Definition: CholmodSupport.h:698
cholmod_common m_cholmod
Definition: CholmodSupport.h:460
CholmodBase< MatrixType_, UpLo_, CholmodDecomposition > Base
Definition: CholmodSupport.h:690
CholmodDecomposition()
Definition: CholmodSupport.h:696
void setMode(CholmodMode mode)
Definition: CholmodSupport.h:705
A simplicial direct Cholesky (LDLT) factorization and solver based on Cholmod.
Definition: CholmodSupport.h:551
MatrixU matrixU() const
Definition: CholmodSupport.h:591
TriangularView< const MatrixType, Eigen::UnitLower > MatrixL
Definition: CholmodSupport.h:561
CholmodBase< MatrixType_, UpLo_, CholmodSimplicialLDLT > Base
Definition: CholmodSupport.h:552
MatrixType::Scalar Scalar
Definition: CholmodSupport.h:557
Matrix< Scalar, Dynamic, 1 > VectorType
Definition: CholmodSupport.h:560
MatrixType::RealScalar RealScalar
Definition: CholmodSupport.h:558
void init()
Definition: CholmodSupport.h:594
VectorType vectorD() const
Definition: CholmodSupport.h:574
~CholmodSimplicialLDLT()
Definition: CholmodSupport.h:571
CholmodSimplicialLDLT()
Definition: CholmodSupport.h:564
MatrixType_ MatrixType
Definition: CholmodSupport.h:556
MatrixType::StorageIndex StorageIndex
Definition: CholmodSupport.h:559
CholmodSimplicialLDLT(const MatrixType &matrix)
Definition: CholmodSupport.h:566
cholmod_common m_cholmod
Definition: CholmodSupport.h:460
MatrixL matrixL() const
Definition: CholmodSupport.h:588
TriangularView< const typename MatrixType::AdjointReturnType, Eigen::UnitUpper > MatrixU
Definition: CholmodSupport.h:562
A simplicial direct Cholesky (LLT) factorization and solver based on Cholmod.
Definition: CholmodSupport.h:492
CholmodSimplicialLLT(const MatrixType &matrix)
Definition: CholmodSupport.h:506
CholmodSimplicialLLT()
Definition: CholmodSupport.h:504
TriangularView< const typename MatrixType::AdjointReturnType, Eigen::Upper > MatrixU
Definition: CholmodSupport.h:502
void init()
Definition: CholmodSupport.h:520
MatrixL matrixL() const
Definition: CholmodSupport.h:514
MatrixType::RealScalar RealScalar
Definition: CholmodSupport.h:499
MatrixType_ MatrixType
Definition: CholmodSupport.h:497
MatrixType::StorageIndex StorageIndex
Definition: CholmodSupport.h:500
MatrixU matrixU() const
Definition: CholmodSupport.h:517
~CholmodSimplicialLLT()
Definition: CholmodSupport.h:511
MatrixType::Scalar Scalar
Definition: CholmodSupport.h:498
cholmod_common m_cholmod
Definition: CholmodSupport.h:460
CholmodBase< MatrixType_, UpLo_, CholmodSimplicialLLT > Base
Definition: CholmodSupport.h:493
TriangularView< const MatrixType, Eigen::Lower > MatrixL
Definition: CholmodSupport.h:501
A supernodal Cholesky (LLT) factorization and solver based on Cholmod.
Definition: CholmodSupport.h:624
~CholmodSupernodalLLT()
Definition: CholmodSupport.h:641
MatrixType_ MatrixType
Definition: CholmodSupport.h:629
CholmodBase< MatrixType_, UpLo_, CholmodSupernodalLLT > Base
Definition: CholmodSupport.h:625
MatrixType::Scalar Scalar
Definition: CholmodSupport.h:630
MatrixType matrixU() const
Definition: CholmodSupport.h:654
MatrixType::RealScalar RealScalar
Definition: CholmodSupport.h:631
MatrixType matrixL() const
Definition: CholmodSupport.h:644
cholmod_common m_cholmod
Definition: CholmodSupport.h:460
void init()
Definition: CholmodSupport.h:657
MatrixType::StorageIndex StorageIndex
Definition: CholmodSupport.h:632
CholmodSupernodalLLT()
Definition: CholmodSupport.h:634
CholmodSupernodalLLT(const MatrixType &matrix)
Definition: CholmodSupport.h:636
An InnerIterator allows to loop over the element of any matrix expression.
Definition: CoreIterators.h:37
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:96
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:52
The matrix class, also used for vectors and row-vectors.
Definition: Eigen/Eigen/src/Core/Matrix.h:186
static ConstMapType Map(const Scalar *data)
Definition: PlainObjectBase.h:595
A matrix or vector expression mapping an existing expression.
Definition: Ref.h:264
Base class of any sparse matrices or sparse expressions.
Definition: SparseMatrixBase.h:30
Derived & const_cast_derived() const
Definition: SparseMatrixBase.h:146
const Derived & derived() const
Definition: SparseMatrixBase.h:144
Index nonZeros() const
Definition: SparseCompressedBase.h:64
Index cols() const
Definition: SparseMatrix.h:161
const StorageIndex * innerNonZeroPtr() const
Definition: SparseMatrix.h:198
const Scalar * valuePtr() const
Definition: SparseMatrix.h:171
bool isCompressed() const
Definition: SparseCompressedBase.h:114
Index rows() const
Definition: SparseMatrix.h:159
const StorageIndex * outerIndexPtr() const
Definition: SparseMatrix.h:189
const StorageIndex * innerIndexPtr() const
Definition: SparseMatrix.h:180
Pseudo expression to manipulate a triangular sparse matrix as a selfadjoint matrix.
Definition: SparseSelfAdjointView.h:52
A base class for sparse solvers.
Definition: SparseSolverBase.h:67
bool m_isInitialized
Definition: SparseSolverBase.h:110
Derived & derived()
Definition: SparseSolverBase.h:76
a sparse vector class
Definition: SparseVector.h:62
Expression of a triangular part in a matrix.
Definition: TriangularMatrix.h:167
EIGEN_DEVICE_FUNC const AdjointReturnType adjoint() const
Definition: TriangularMatrix.h:224
Definition: matrices.h:74
Concept for reading and writing characters.
Eigen::Map< Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor >, 0, Eigen::OuterStride<> > matrix(T *data, int rows, int cols, int stride)
Definition: common.h:85
float real
Definition: datatypes.h:10
ComputationInfo
Definition: Constants.h:438
@ Lower
Definition: Constants.h:211
@ Upper
Definition: Constants.h:213
@ NumericalIssue
Definition: Constants.h:442
@ Success
Definition: Constants.h:440
const unsigned int RowMajorBit
Definition: Constants.h:70
#define X
Definition: icosphere.cpp:20
RealScalar RealScalar * px
Definition: level1_cplx_impl.h:27
Scalar beta
Definition: level2_cplx_impl.h:36
char char char int int * k
Definition: level2_impl.h:374
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 exp(const bfloat16 &a)
Definition: BFloat16.h:615
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 log(const bfloat16 &a)
Definition: BFloat16.h:618
cholmod_sparse * cm_spsolve(int sys, cholmod_factor &L, cholmod_sparse &B, cholmod_common &Common)
Definition: CholmodSupport.h:212
cholmod_sparse * cm_spsolve< SuiteSparse_long >(int sys, cholmod_factor &L, cholmod_sparse &B, cholmod_common &Common)
Definition: CholmodSupport.h:216
cholmod_dense * cm_solve< SuiteSparse_long >(int sys, cholmod_factor &L, cholmod_dense &B, cholmod_common &Common)
Definition: CholmodSupport.h:207
int cm_factorize_p< SuiteSparse_long >(cholmod_sparse *A, double beta[2], SuiteSparse_long *fset, std::size_t fsize, cholmod_factor *L, cholmod_common &Common)
Definition: CholmodSupport.h:227
cholmod_dense * cm_solve(int sys, cholmod_factor &L, cholmod_dense &B, cholmod_common &Common)
Definition: CholmodSupport.h:203
int cm_factorize_p(cholmod_sparse *A, double beta[2], StorageIndex_ *fset, std::size_t fsize, cholmod_factor *L, cholmod_common &Common)
Definition: CholmodSupport.h:222
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:70
Map< const SparseMatrix< Scalar, ColMajor, StorageIndex > > viewAsEigen(cholmod_sparse &cm)
Definition: CholmodSupport.h:153
const AutoDiffScalar< DerType > & real(const AutoDiffScalar< DerType > &x)
Definition: AutoDiffScalar.h:486
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:83
cholmod_sparse viewAsCholmod(Ref< SparseMatrix< Scalar_, Options_, StorageIndex_ > > mat)
Definition: CholmodSupport.h:64
CholmodMode
Definition: CholmodSupport.h:237
@ CholmodSimplicialLLt
Definition: CholmodSupport.h:237
@ CholmodAuto
Definition: CholmodSupport.h:237
@ CholmodLDLt
Definition: CholmodSupport.h:237
@ CholmodSupernodalLLt
Definition: CholmodSupport.h:237
const Mdouble pi
Definition: ExtendedMath.h:23
Definition: Eigen_Colamd.h:49
void start(const unsigned &i)
(Re-)start i-th timer
Definition: oomph_utilities.cc:243
list x
Definition: plotDoE.py:28
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition: NumTraits.h:217
Definition: ForwardDeclarations.h:21
Definition: datatypes.h:12
void run(const string &dir_name, LinearSolver *linear_solver_pt, const unsigned nel_1d, bool mess_up_order)
Definition: two_d_poisson_compare_solvers.cc:317