32 #ifndef EIGEN_PARDISOSUPPORT_H
33 #define EIGEN_PARDISOSUPPORT_H
39 template<
typename MatrixType_>
class PardisoLU;
40 template<
typename MatrixType_,
int Options=Upper>
class PardisoLLT;
41 template<
typename MatrixType_,
int Options=Upper>
class PardisoLDLT;
45 template<
typename IndexType>
46 struct pardiso_run_selector
48 static IndexType run( _MKL_DSS_HANDLE_t pt, IndexType maxfct, IndexType mnum, IndexType type, IndexType phase, IndexType
n,
void *
a,
49 IndexType *ia, IndexType *ja, IndexType *perm, IndexType nrhs, IndexType *iparm, IndexType msglvl,
void *
b,
void *
x)
52 ::pardiso(pt, &maxfct, &mnum, &type, &phase, &
n,
a, ia, ja, perm, &nrhs, iparm, &msglvl,
b,
x, &error);
57 struct pardiso_run_selector<long long int>
59 typedef long long int IndexType;
60 static IndexType run( _MKL_DSS_HANDLE_t pt, IndexType maxfct, IndexType mnum, IndexType type, IndexType phase, IndexType
n,
void *
a,
61 IndexType *ia, IndexType *ja, IndexType *perm, IndexType nrhs, IndexType *iparm, IndexType msglvl,
void *
b,
void *
x)
64 ::pardiso_64(pt, &maxfct, &mnum, &type, &phase, &
n,
a, ia, ja, perm, &nrhs, iparm, &msglvl,
b,
x, &error);
69 template<
class Pardiso>
struct pardiso_traits;
71 template<
typename MatrixType_>
72 struct pardiso_traits< PardisoLU<MatrixType_> >
75 typedef typename MatrixType_::Scalar Scalar;
76 typedef typename MatrixType_::RealScalar RealScalar;
77 typedef typename MatrixType_::StorageIndex StorageIndex;
80 template<
typename MatrixType_,
int Options>
81 struct pardiso_traits< PardisoLLT<MatrixType_, Options> >
84 typedef typename MatrixType_::Scalar Scalar;
85 typedef typename MatrixType_::RealScalar RealScalar;
86 typedef typename MatrixType_::StorageIndex StorageIndex;
89 template<
typename MatrixType_,
int Options>
90 struct pardiso_traits< PardisoLDLT<MatrixType_, Options> >
93 typedef typename MatrixType_::Scalar Scalar;
94 typedef typename MatrixType_::RealScalar RealScalar;
95 typedef typename MatrixType_::StorageIndex StorageIndex;
100 template<
class Derived>
108 typedef internal::pardiso_traits<Derived>
Traits;
110 using Base::_solve_impl;
181 template<
typename Rhs,
typename Dest>
189 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,
209 m_iparm[10] = symmetric ? 0 : 1;
211 m_iparm[12] = symmetric ? 0 : 1;
261 template<
class Derived>
268 m_perm.setZero(m_size);
269 derived().getMatrix(
a);
272 error = internal::pardiso_run_selector<StorageIndex>::run(m_pt, 1, 1, m_type, 12, internal::convert_index<StorageIndex>(m_size),
273 m_matrix.valuePtr(), m_matrix.outerIndexPtr(), m_matrix.innerIndexPtr(),
274 m_perm.data(), 0, m_iparm.data(), m_msglvl, NULL, NULL);
275 manageErrorCode(error);
276 m_analysisIsOk =
true;
277 m_factorizationIsOk =
true;
278 m_isInitialized =
true;
282 template<
class Derived>
289 m_perm.setZero(m_size);
290 derived().getMatrix(
a);
293 error = internal::pardiso_run_selector<StorageIndex>::run(m_pt, 1, 1, m_type, 11, internal::convert_index<StorageIndex>(m_size),
294 m_matrix.valuePtr(), m_matrix.outerIndexPtr(), m_matrix.innerIndexPtr(),
295 m_perm.data(), 0, m_iparm.data(), m_msglvl, NULL, NULL);
297 manageErrorCode(error);
298 m_analysisIsOk =
true;
299 m_factorizationIsOk =
false;
300 m_isInitialized =
true;
304 template<
class Derived>
307 eigen_assert(m_analysisIsOk &&
"You must first call analyzePattern()");
310 derived().getMatrix(
a);
313 error = internal::pardiso_run_selector<StorageIndex>::run(m_pt, 1, 1, m_type, 22, internal::convert_index<StorageIndex>(m_size),
314 m_matrix.valuePtr(), m_matrix.outerIndexPtr(), m_matrix.innerIndexPtr(),
315 m_perm.data(), 0, m_iparm.data(), m_msglvl, NULL, NULL);
317 manageErrorCode(error);
318 m_factorizationIsOk =
true;
322 template<
class Derived>
323 template<
typename BDerived,
typename XDerived>
353 if(rhs_ptr ==
x.derived().data())
356 rhs_ptr = tmp.
data();
360 error = internal::pardiso_run_selector<StorageIndex>::run(m_pt, 1, 1, m_type, 33, internal::convert_index<StorageIndex>(m_size),
361 m_matrix.valuePtr(), m_matrix.outerIndexPtr(), m_matrix.innerIndexPtr(),
362 m_perm.data(), internal::convert_index<StorageIndex>(nrhs), m_iparm.data(), m_msglvl,
363 rhs_ptr,
x.derived().data());
365 manageErrorCode(error);
386 template<
typename MatrixType>
442 template<
typename MatrixType,
int UpLo_>
479 m_matrix.template selfadjointView<Upper>() = matrix.template selfadjointView<UpLo>().
twistedBy(p_null);
505 template<
typename MatrixType,
int Options>
540 m_matrix.template selfadjointView<Upper>() = matrix.template selfadjointView<UpLo>().
twistedBy(p_null);
const AbsReturnType abs() const
Matrix< float, 1, Dynamic > MatrixType
Base class for all dense matrices, vectors, and expressions.
Derived & compute(const MatrixType &matrix)
Matrix< StorageIndex, MatrixType::RowsAtCompileTime, 1 > IntColVectorType
void _solve_impl(const MatrixBase< Rhs > &b, MatrixBase< Dest > &dest) const
Traits::StorageIndex StorageIndex
Traits::MatrixType MatrixType
ParameterType & pardisoParameterArray()
SparseMatrixType m_matrix
Traits::RealScalar RealScalar
void pardisoInit(int type)
Array< StorageIndex, 64, 1, DontAlign > ParameterType
Derived & factorize(const MatrixType &matrix)
ComputationInfo info() const
Reports whether previous computation was successful.
Matrix< Scalar, Dynamic, 1 > VectorType
internal::pardiso_traits< Derived > Traits
Matrix< StorageIndex, 1, MatrixType::ColsAtCompileTime > IntRowVectorType
SparseMatrix< Scalar, RowMajor, StorageIndex > SparseMatrixType
void manageErrorCode(Index error) const
SparseSolverBase< Derived > Base
Derived & analyzePattern(const MatrixType &matrix)
A sparse direct Cholesky (LDLT) factorization and solver based on the PARDISO library.
Base::RealScalar RealScalar
PardisoImpl< PardisoLDLT< MatrixType, Options > > Base
PardisoLDLT(const MatrixType &matrix)
void getMatrix(const MatrixType &matrix)
Base::StorageIndex StorageIndex
A sparse direct Cholesky (LLT) factorization and solver based on the PARDISO library.
Base::StorageIndex StorageIndex
void getMatrix(const MatrixType &matrix)
PardisoLLT(const MatrixType &matrix)
PardisoImpl< PardisoLLT< MatrixType, UpLo_ > > Base
Base::RealScalar RealScalar
A sparse direct LU factorization and solver based on the PARDISO library.
Derived & compute(const MatrixType &matrix)
SparseMatrixType m_matrix
void pardisoInit(int type)
Base::RealScalar RealScalar
PardisoImpl< PardisoLU > Base
PardisoLU(const MatrixType &matrix)
void getMatrix(const MatrixType &matrix)
EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
const Scalar * data() const
EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Derived & setZero(Index size)
SparseSymmetricPermutationProduct< Derived, Upper|Lower > twistedBy(const PermutationMatrix< Dynamic, Dynamic, StorageIndex > &perm) const
void resize(Index rows, Index cols)
A base class for sparse solvers.
const Solve< Derived, Rhs > solve(const MatrixBase< Rhs > &b) const
const unsigned int RowMajorBit
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.