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;
126 : m_analysisIsOk(
false), m_factorizationIsOk(
false)
128 eigen_assert((
sizeof(StorageIndex) >=
sizeof(
_INTEGER_t) &&
sizeof(StorageIndex) <= 8) &&
"Non-supported index type");
131 m_isInitialized =
false;
139 inline Index cols()
const {
return m_size; }
140 inline Index rows()
const {
return m_size; }
149 eigen_assert(m_isInitialized &&
"Decomposition is not initialized.");
177 Derived& compute(
const MatrixType& matrix);
179 template<
typename Rhs,
typename Dest>
183 void pardisoRelease()
187 internal::pardiso_run_selector<StorageIndex>::run(m_pt, 1, 1, m_type, -1, internal::convert_index<StorageIndex>(m_size),0, 0, 0, m_perm.
data(), 0,
189 m_isInitialized =
false;
193 void pardisoInit(
int type)
196 bool symmetric = std::abs(m_type) < 10;
207 m_iparm[10] = symmetric ? 0 : 1;
209 m_iparm[12] = symmetric ? 0 : 1;
221 m_iparm[27] = (
sizeof(RealScalar) == 4) ? 1 : 0;
226 memset(m_pt, 0,
sizeof(m_pt));
232 void manageErrorCode(
Index error)
const
248 mutable SparseMatrixType m_matrix;
250 bool m_analysisIsOk, m_factorizationIsOk;
251 StorageIndex m_type, m_msglvl;
252 mutable void *m_pt[64];
253 mutable ParameterType m_iparm;
254 mutable IntColVectorType m_perm;
259template<
class Derived>
260Derived& PardisoImpl<Derived>::compute(
const MatrixType& a)
263 eigen_assert(a.rows() == a.cols());
266 m_perm.setZero(m_size);
267 derived().getMatrix(a);
270 error = internal::pardiso_run_selector<StorageIndex>::run(m_pt, 1, 1, m_type, 12, internal::convert_index<StorageIndex>(m_size),
271 m_matrix.valuePtr(), m_matrix.outerIndexPtr(), m_matrix.innerIndexPtr(),
272 m_perm.data(), 0, m_iparm.data(), m_msglvl, NULL, NULL);
273 manageErrorCode(error);
274 m_analysisIsOk =
true;
275 m_factorizationIsOk =
true;
276 m_isInitialized =
true;
280template<
class Derived>
284 eigen_assert(m_size == a.cols());
287 m_perm.setZero(m_size);
288 derived().getMatrix(a);
292 m_matrix.valuePtr(), m_matrix.outerIndexPtr(), m_matrix.innerIndexPtr(),
293 m_perm.data(), 0, m_iparm.data(), m_msglvl,
NULL,
NULL);
295 manageErrorCode(error);
296 m_analysisIsOk =
true;
297 m_factorizationIsOk =
false;
298 m_isInitialized =
true;
302template<
class Derived>
305 eigen_assert(m_analysisIsOk &&
"You must first call analyzePattern()");
306 eigen_assert(m_size == a.rows() && m_size == a.cols());
308 derived().getMatrix(a);
312 m_matrix.valuePtr(), m_matrix.outerIndexPtr(), m_matrix.innerIndexPtr(),
313 m_perm.data(), 0, m_iparm.data(), m_msglvl,
NULL,
NULL);
315 manageErrorCode(error);
316 m_factorizationIsOk =
true;
320template<
class Derived>
321template<
typename BDerived,
typename XDerived>
332 eigen_assert(m_size==b.rows());
335 eigen_assert(((nrhs == 1) || b.outerStride() == b.rows()));
347 Scalar* rhs_ptr =
const_cast<Scalar*
>(b.derived().data());
351 if(rhs_ptr == x.derived().data())
354 rhs_ptr = tmp.data();
358 error = internal::pardiso_run_selector<StorageIndex>::run(m_pt, 1, 1, m_type, 33, internal::convert_index<StorageIndex>(m_size),
359 m_matrix.valuePtr(), m_matrix.outerIndexPtr(), m_matrix.innerIndexPtr(),
360 m_perm.data(), internal::convert_index<StorageIndex>(nrhs), m_iparm.data(), m_msglvl,
361 rhs_ptr, x.derived().data());
363 manageErrorCode(error);
384template<
typename MatrixType>
389 using Base::pardisoInit;
390 using Base::m_matrix;
395 typedef typename Base::Scalar Scalar;
396 typedef typename Base::RealScalar RealScalar;
404 pardisoInit(Base::ScalarIsComplex ? 13 : 11);
407 explicit PardisoLU(
const MatrixType& matrix)
410 pardisoInit(Base::ScalarIsComplex ? 13 : 11);
414 void getMatrix(
const MatrixType& matrix)
440template<
typename MatrixType,
int _UpLo>
445 using Base::pardisoInit;
446 using Base::m_matrix;
451 typedef typename Base::Scalar Scalar;
452 typedef typename Base::RealScalar RealScalar;
453 typedef typename Base::StorageIndex StorageIndex;
454 enum { UpLo =
_UpLo };
460 pardisoInit(Base::ScalarIsComplex ? 4 : 2);
466 pardisoInit(Base::ScalarIsComplex ? 4 : 2);
472 void getMatrix(
const MatrixType& matrix)
476 m_matrix.
resize(matrix.rows(), matrix.cols());
503template<
typename MatrixType,
int Options>
508 using Base::pardisoInit;
509 using Base::m_matrix;
514 typedef typename Base::Scalar Scalar;
515 typedef typename Base::RealScalar RealScalar;
516 typedef typename Base::StorageIndex StorageIndex;
523 pardisoInit(Base::ScalarIsComplex ? (
bool(Options&
Symmetric) ? 6 : -4 ) : -2);
529 pardisoInit(Base::ScalarIsComplex ? (
bool(Options&
Symmetric) ? 6 : -4 ) : -2);
533 void getMatrix(
const MatrixType& matrix)
537 m_matrix.
resize(matrix.rows(), matrix.cols());
Base class for all dense matrices, vectors, and expressions.
Definition MatrixBase.h:50
@ Flags
This stores expression Flags flags which may or may not be inherited by new expressions constructed f...
Definition DenseBase.h:165
Definition PardisoSupport.h:100
Derived & factorize(const MatrixType &matrix)
Performs a numeric decomposition of matrix.
Definition PardisoSupport.h:303
ParameterType & pardisoParameterArray()
Definition PardisoSupport.h:156
ComputationInfo info() const
Reports whether previous computation was successful.
Definition PardisoSupport.h:147
Derived & analyzePattern(const MatrixType &matrix)
Performs a symbolic decomposition on the sparcity of matrix.
Definition PardisoSupport.h:281
A sparse direct Cholesky (LDLT) factorization and solver based on the PARDISO library.
Definition PardisoSupport.h:505
A sparse direct Cholesky (LLT) factorization and solver based on the PARDISO library.
Definition PardisoSupport.h:442
A sparse direct LU factorization and solver based on the PARDISO library.
Definition PardisoSupport.h:386
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar * data() const
Definition PlainObjectBase.h:247
EIGEN_DEVICE_FUNC Derived & setZero(Index size)
Resizes to the given size, and sets all coefficients in this expression to zero.
Definition CwiseNullaryOp.h:562
void makeCompressed()
Turns the matrix into the compressed format.
Definition SparseMatrix.h:467
void resize(Index rows, Index cols)
Resizes the matrix to a rows x cols matrix and initializes it to zero.
Definition SparseMatrix.h:626
A base class for sparse solvers.
Definition SparseSolverBase.h:68
const Solve< Derived, Rhs > solve(const MatrixBase< Rhs > &b) const
Definition SparseSolverBase.h:88
ComputationInfo
Enum for reporting the status of a computation.
Definition Constants.h:440
@ Symmetric
Used to support symmetric, non-selfadjoint, complex matrices.
Definition Constants.h:227
@ Lower
View matrix as a lower triangular matrix.
Definition Constants.h:209
@ Upper
View matrix as an upper triangular matrix.
Definition Constants.h:211
@ NumericalIssue
The provided data did not satisfy the prerequisites.
Definition Constants.h:444
@ InvalidInput
The inputs are invalid, or the algorithm has been improperly called.
Definition Constants.h:449
@ Success
Computation was successful.
Definition Constants.h:442
const unsigned int RowMajorBit
for a matrix, this means that the storage order is row-major.
Definition Constants.h:66
Namespace containing all symbols from the Eigen library.
Definition LDLT.h:16
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:74
const int Dynamic
This value means that a positive quantity (e.g., a size) is not known at compile-time,...
Definition Constants.h:22
@ error
throw a parse_error exception in case of a tag
Holds information about the various numeric (i.e.
Definition NumTraits.h:236
Definition PardisoSupport.h:45
Definition PardisoSupport.h:67
Definition inference.c:32