32#ifndef EIGEN_PARDISOSUPPORT_H
33#define EIGEN_PARDISOSUPPORT_H
37template<
typename _MatrixType>
class PardisoLU;
38template<
typename _MatrixType,
int Options=Upper>
class PardisoLLT;
39template<
typename _MatrixType,
int Options=Upper>
class PardisoLDLT;
43 template<
typename IndexType>
47 IndexType *ia, IndexType *
ja, IndexType *perm, IndexType
nrhs, IndexType *iparm, IndexType
msglvl,
void *b,
void *x)
50 ::pardiso(
pt, &
maxfct, &
mnum, &type, &
phase, &n, a, ia,
ja, perm, &
nrhs, iparm, &
msglvl, b, x, &error);
62 ::pardiso_64(
pt, &
maxfct, &
mnum, &type, &
phase, &n, a, ia,
ja, perm, &
nrhs, iparm, &
msglvl, b, x, &error);
69 template<
typename _MatrixType>
72 typedef _MatrixType MatrixType;
73 typedef typename _MatrixType::Scalar Scalar;
74 typedef typename _MatrixType::RealScalar RealScalar;
75 typedef typename _MatrixType::StorageIndex StorageIndex;
78 template<
typename _MatrixType,
int Options>
81 typedef _MatrixType MatrixType;
82 typedef typename _MatrixType::Scalar Scalar;
83 typedef typename _MatrixType::RealScalar RealScalar;
84 typedef typename _MatrixType::StorageIndex StorageIndex;
87 template<
typename _MatrixType,
int Options>
90 typedef _MatrixType MatrixType;
91 typedef typename _MatrixType::Scalar Scalar;
92 typedef typename _MatrixType::RealScalar RealScalar;
93 typedef typename _MatrixType::StorageIndex StorageIndex;
98template<
class Derived>
104 using Base::m_isInitialized;
108 using Base::_solve_impl;
110 typedef typename Traits::MatrixType MatrixType;
111 typedef typename Traits::Scalar Scalar;
112 typedef typename Traits::RealScalar RealScalar;
113 typedef typename Traits::StorageIndex StorageIndex;
121 ColsAtCompileTime = Dynamic,
122 MaxColsAtCompileTime = Dynamic
127 eigen_assert((
sizeof(StorageIndex) >=
sizeof(
_INTEGER_t) &&
sizeof(StorageIndex) <= 8) &&
"Non-supported index type");
130 m_isInitialized =
false;
138 inline Index cols()
const {
return m_size; }
139 inline Index rows()
const {
return m_size; }
148 eigen_assert(m_isInitialized &&
"Decomposition is not initialized.");
176 Derived& compute(
const MatrixType& matrix);
178 template<
typename Rhs,
typename Dest>
182 void pardisoRelease()
186 internal::pardiso_run_selector<StorageIndex>::run(m_pt, 1, 1, m_type, -1, m_size,0, 0, 0, m_perm.
data(), 0,
188 m_isInitialized =
false;
192 void pardisoInit(
int type)
195 bool symmetric = std::abs(m_type) < 10;
206 m_iparm[10] = symmetric ? 0 : 1;
208 m_iparm[12] = symmetric ? 0 : 1;
220 m_iparm[27] = (
sizeof(RealScalar) == 4) ? 1 : 0;
224 memset(m_pt, 0,
sizeof(m_pt));
230 void manageErrorCode(Index error)
const
246 mutable SparseMatrixType m_matrix;
248 bool m_analysisIsOk, m_factorizationIsOk;
249 Index m_type, m_msglvl;
250 mutable void *m_pt[64];
251 mutable ParameterType m_iparm;
252 mutable IntColVectorType m_perm;
257template<
class Derived>
258Derived& PardisoImpl<Derived>::compute(
const MatrixType& a)
261 eigen_assert(a.rows() == a.cols());
264 m_perm.setZero(m_size);
265 derived().getMatrix(a);
268 error = internal::pardiso_run_selector<StorageIndex>::run(m_pt, 1, 1, m_type, 12, m_size,
269 m_matrix.valuePtr(), m_matrix.outerIndexPtr(), m_matrix.innerIndexPtr(),
270 m_perm.data(), 0, m_iparm.data(), m_msglvl, NULL, NULL);
272 manageErrorCode(error);
273 m_analysisIsOk =
true;
274 m_factorizationIsOk =
true;
275 m_isInitialized =
true;
279template<
class Derived>
283 eigen_assert(m_size == a.cols());
286 m_perm.setZero(m_size);
287 derived().getMatrix(a);
291 m_matrix.valuePtr(), m_matrix.outerIndexPtr(), m_matrix.innerIndexPtr(),
292 m_perm.data(), 0, m_iparm.data(), m_msglvl,
NULL,
NULL);
294 manageErrorCode(error);
295 m_analysisIsOk =
true;
296 m_factorizationIsOk =
false;
297 m_isInitialized =
true;
301template<
class Derived>
304 eigen_assert(m_analysisIsOk &&
"You must first call analyzePattern()");
305 eigen_assert(m_size == a.rows() && m_size == a.cols());
307 derived().getMatrix(a);
311 m_matrix.valuePtr(), m_matrix.outerIndexPtr(), m_matrix.innerIndexPtr(),
312 m_perm.data(), 0, m_iparm.data(), m_msglvl,
NULL,
NULL);
314 manageErrorCode(error);
315 m_factorizationIsOk =
true;
319template<
class Derived>
320template<
typename BDerived,
typename XDerived>
330 Index nrhs = Index(b.cols());
331 eigen_assert(m_size==b.rows());
334 eigen_assert(((nrhs == 1) || b.outerStride() == b.rows()));
346 Scalar* rhs_ptr =
const_cast<Scalar*
>(b.derived().data());
350 if(rhs_ptr == x.derived().data())
353 rhs_ptr = tmp.data();
357 error = internal::pardiso_run_selector<StorageIndex>::run(m_pt, 1, 1, m_type, 33, m_size,
358 m_matrix.valuePtr(), m_matrix.outerIndexPtr(), m_matrix.innerIndexPtr(),
359 m_perm.data(), nrhs, m_iparm.data(), m_msglvl,
360 rhs_ptr, x.derived().data());
362 manageErrorCode(error);
380template<
typename MatrixType>
385 typedef typename Base::Scalar Scalar;
386 typedef typename Base::RealScalar RealScalar;
387 using Base::pardisoInit;
388 using Base::m_matrix;
399 pardisoInit(Base::ScalarIsComplex ? 13 : 11);
402 explicit PardisoLU(
const MatrixType& matrix)
405 pardisoInit(Base::ScalarIsComplex ? 13 : 11);
409 void getMatrix(
const MatrixType& matrix)
432template<
typename MatrixType,
int _UpLo>
437 typedef typename Base::Scalar Scalar;
438 typedef typename Base::RealScalar RealScalar;
439 using Base::pardisoInit;
440 using Base::m_matrix;
445 typedef typename Base::StorageIndex StorageIndex;
446 enum { UpLo =
_UpLo };
452 pardisoInit(Base::ScalarIsComplex ? 4 : 2);
458 pardisoInit(Base::ScalarIsComplex ? 4 : 2);
464 void getMatrix(
const MatrixType& matrix)
468 m_matrix.
resize(matrix.rows(), matrix.cols());
492template<
typename MatrixType,
int Options>
497 typedef typename Base::Scalar Scalar;
498 typedef typename Base::RealScalar RealScalar;
499 using Base::pardisoInit;
500 using Base::m_matrix;
505 typedef typename Base::StorageIndex StorageIndex;
512 pardisoInit(Base::ScalarIsComplex ? (
bool(Options&
Symmetric) ? 6 : -4 ) : -2);
518 pardisoInit(Base::ScalarIsComplex ? (
bool(Options&
Symmetric) ? 6 : -4 ) : -2);
522 void getMatrix(
const MatrixType& matrix)
526 m_matrix.
resize(matrix.rows(), matrix.cols());
@ Flags
This stores expression Flags flags which may or may not be inherited by new expressions constructed f...
Definition DenseBase.h:164
Definition PardisoSupport.h:100
Derived & factorize(const MatrixType &matrix)
Performs a numeric decomposition of matrix.
Definition PardisoSupport.h:302
ParameterType & pardisoParameterArray()
Definition PardisoSupport.h:155
ComputationInfo info() const
Reports whether previous computation was successful.
Definition PardisoSupport.h:146
Derived & analyzePattern(const MatrixType &matrix)
Performs a symbolic decomposition on the sparcity of matrix.
Definition PardisoSupport.h:280
A sparse direct Cholesky (LDLT) factorization and solver based on the PARDISO library.
Definition PardisoSupport.h:494
A sparse direct Cholesky (LLT) factorization and solver based on the PARDISO library.
Definition PardisoSupport.h:434
A sparse direct LU factorization and solver based on the PARDISO library.
Definition PardisoSupport.h:382
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar * data() const
Definition PlainObjectBase.h:228
EIGEN_DEVICE_FUNC Derived & setZero(Index size)
Resizes to the given size, and sets all coefficients in this expression to zero.
Definition CwiseNullaryOp.h:520
Pseudo expression representing a solving operation.
Definition Solve.h:63
void resize(Index rows, Index cols)
Resizes the matrix to a rows x cols matrix and initializes it to zero.
Definition SparseMatrix.h:611
void makeCompressed()
Turns the matrix into the compressed format.
Definition SparseMatrix.h:459
A base class for sparse solvers.
Definition SparseSolverBase.h:54
const Solve< Derived, Rhs > solve(const MatrixBase< Rhs > &b) const
Definition SparseSolverBase.h:74
ComputationInfo
Enum for reporting the status of a computation.
Definition Constants.h:430
@ Symmetric
Used to support symmetric, non-selfadjoint, complex matrices.
Definition Constants.h:222
@ Lower
View matrix as a lower triangular matrix.
Definition Constants.h:204
@ Upper
View matrix as an upper triangular matrix.
Definition Constants.h:206
@ NumericalIssue
The provided data did not satisfy the prerequisites.
Definition Constants.h:434
@ InvalidInput
The inputs are invalid, or the algorithm has been improperly called.
Definition Constants.h:439
@ Success
Computation was successful.
Definition Constants.h:432
const unsigned int RowMajorBit
for a matrix, this means that the storage order is row-major.
Definition Constants.h:61
@ error
throw a parse_error exception in case of a tag
Holds information about the various numeric (i.e.
Definition NumTraits.h:108
Definition PardisoSupport.h:45
Definition PardisoSupport.h:67
Definition inference.c:32