10 #ifndef EIGEN_PASTIXSUPPORT_H
11 #define EIGEN_PASTIXSUPPORT_H
18 #define PASTIX_COMPLEX COMPLEX
19 #define PASTIX_DCOMPLEX DCOMPLEX
21 #define PASTIX_COMPLEX std::complex<float>
22 #define PASTIX_DCOMPLEX std::complex<double>
33 template<
typename MatrixType_,
bool IsStrSym = false>
class PastixLU;
34 template<
typename MatrixType_,
int Options>
class PastixLLT;
35 template<
typename MatrixType_,
int Options>
class PastixLDLT;
40 template<
class Pastix>
struct pastix_traits;
42 template<
typename MatrixType_>
43 struct pastix_traits< PastixLU<MatrixType_> >
46 typedef typename MatrixType_::Scalar Scalar;
47 typedef typename MatrixType_::RealScalar RealScalar;
48 typedef typename MatrixType_::StorageIndex StorageIndex;
51 template<
typename MatrixType_,
int Options>
52 struct pastix_traits< PastixLLT<MatrixType_,Options> >
55 typedef typename MatrixType_::Scalar Scalar;
56 typedef typename MatrixType_::RealScalar RealScalar;
57 typedef typename MatrixType_::StorageIndex StorageIndex;
60 template<
typename MatrixType_,
int Options>
61 struct pastix_traits< PastixLDLT<MatrixType_,Options> >
64 typedef typename MatrixType_::Scalar Scalar;
65 typedef typename MatrixType_::RealScalar RealScalar;
66 typedef typename MatrixType_::StorageIndex StorageIndex;
69 inline void eigen_pastix(pastix_data_t **pastix_data,
int pastix_comm,
int n,
int *ptr,
int *idx,
float *vals,
int *perm,
int * invp,
float *
x,
int nbrhs,
int *iparm,
double *dparm)
71 if (
n == 0) { ptr = NULL; idx = NULL; vals = NULL; }
72 if (nbrhs == 0) {
x = NULL; nbrhs=1;}
73 s_pastix(pastix_data, pastix_comm,
n, ptr, idx, vals, perm, invp,
x, nbrhs, iparm, dparm);
76 inline void eigen_pastix(pastix_data_t **pastix_data,
int pastix_comm,
int n,
int *ptr,
int *idx,
double *vals,
int *perm,
int * invp,
double *
x,
int nbrhs,
int *iparm,
double *dparm)
78 if (
n == 0) { ptr = NULL; idx = NULL; vals = NULL; }
79 if (nbrhs == 0) {
x = NULL; nbrhs=1;}
80 d_pastix(pastix_data, pastix_comm,
n, ptr, idx, vals, perm, invp,
x, nbrhs, iparm, dparm);
83 inline void eigen_pastix(pastix_data_t **pastix_data,
int pastix_comm,
int n,
int *ptr,
int *idx, std::complex<float> *vals,
int *perm,
int * invp, std::complex<float> *
x,
int nbrhs,
int *iparm,
double *dparm)
85 if (
n == 0) { ptr = NULL; idx = NULL; vals = NULL; }
86 if (nbrhs == 0) {
x = NULL; nbrhs=1;}
87 c_pastix(pastix_data, pastix_comm,
n, ptr, idx,
reinterpret_cast<PASTIX_COMPLEX*
>(vals), perm, invp,
reinterpret_cast<PASTIX_COMPLEX*
>(
x), nbrhs, iparm, dparm);
90 inline void eigen_pastix(pastix_data_t **pastix_data,
int pastix_comm,
int n,
int *ptr,
int *idx, std::complex<double> *vals,
int *perm,
int * invp, std::complex<double> *
x,
int nbrhs,
int *iparm,
double *dparm)
92 if (
n == 0) { ptr = NULL; idx = NULL; vals = NULL; }
93 if (nbrhs == 0) {
x = NULL; nbrhs=1;}
94 z_pastix(pastix_data, pastix_comm,
n, ptr, idx,
reinterpret_cast<PASTIX_DCOMPLEX*
>(vals), perm, invp,
reinterpret_cast<PASTIX_DCOMPLEX*
>(
x), nbrhs, iparm, dparm);
98 template <
typename MatrixType>
101 if ( !(
mat.outerIndexPtr()[0]) )
104 for(
i = 0;
i <=
mat.rows(); ++
i)
105 ++
mat.outerIndexPtr()[
i];
106 for(
i = 0;
i <
mat.nonZeros(); ++
i)
107 ++
mat.innerIndexPtr()[
i];
112 template <
typename MatrixType>
116 if (
mat.outerIndexPtr()[0] == 1 )
119 for(
i = 0;
i <=
mat.rows(); ++
i)
120 --
mat.outerIndexPtr()[
i];
121 for(
i = 0;
i <
mat.nonZeros(); ++
i)
122 --
mat.innerIndexPtr()[
i];
129 template <
class Derived>
137 using Base::_solve_impl;
163 template<
typename Rhs,
typename Dest>
235 m_iparm(IPARM_START_TASK) = API_TASK_CLEAN;
236 m_iparm(IPARM_END_TASK) = API_TASK_CLEAN;
260 template <
class Derived>
264 m_iparm.setZero(IPARM_SIZE);
265 m_dparm.setZero(DPARM_SIZE);
267 m_iparm(IPARM_MODIFY_PARAMETER) = API_NO;
268 pastix(&m_pastixdata, MPI_COMM_WORLD,
270 0, 0, 0, 1, m_iparm.data(), m_dparm.data());
272 m_iparm[IPARM_MATRIX_VERIFICATION] = API_NO;
273 m_iparm[IPARM_VERBOSE] = API_VERBOSE_NOT;
274 m_iparm[IPARM_ORDERING] = API_ORDER_SCOTCH;
275 m_iparm[IPARM_INCOMPLETE] = API_NO;
276 m_iparm[IPARM_OOC_LIMIT] = 2000;
277 m_iparm[IPARM_RHS_MAKING] = API_RHS_B;
278 m_iparm(IPARM_MATRIX_VERIFICATION) = API_NO;
280 m_iparm(IPARM_START_TASK) = API_TASK_INIT;
281 m_iparm(IPARM_END_TASK) = API_TASK_INIT;
283 0, 0, 0, 0, m_iparm.data(), m_dparm.data());
286 if(m_iparm(IPARM_ERROR_NUMBER)) {
296 template <
class Derived>
304 m_iparm(IPARM_MATRIX_VERIFICATION) = API_NO;
308 template <
class Derived>
311 eigen_assert(m_initisOk &&
"The initialization of PaSTiX failed");
317 m_size = internal::convert_index<int>(
mat.
rows());
318 m_perm.resize(m_size);
319 m_invp.resize(m_size);
321 m_iparm(IPARM_START_TASK) = API_TASK_ORDERING;
322 m_iparm(IPARM_END_TASK) = API_TASK_ANALYSE;
324 mat.valuePtr(), m_perm.
data(), m_invp.data(), 0, 0, m_iparm.data(), m_dparm.data());
327 if(m_iparm(IPARM_ERROR_NUMBER))
330 m_analysisIsOk =
false;
335 m_analysisIsOk =
true;
339 template <
class Derived>
343 eigen_assert(m_analysisIsOk &&
"The analysis phase should be called before the factorization phase");
344 m_iparm(IPARM_START_TASK) = API_TASK_NUMFACT;
345 m_iparm(IPARM_END_TASK) = API_TASK_NUMFACT;
346 m_size = internal::convert_index<int>(
mat.
rows());
349 mat.valuePtr(), m_perm.
data(), m_invp.data(), 0, 0, m_iparm.data(), m_dparm.data());
352 if(m_iparm(IPARM_ERROR_NUMBER))
355 m_factorizationIsOk =
false;
356 m_isInitialized =
false;
361 m_factorizationIsOk =
true;
362 m_isInitialized =
true;
367 template<
typename Base>
368 template<
typename Rhs,
typename Dest>
371 eigen_assert(m_isInitialized &&
"The matrix should be factorized first");
373 THIS_METHOD_IS_ONLY_FOR_COLUMN_MAJOR_MATRICES);
378 for (
int i = 0;
i <
b.cols();
i++){
379 m_iparm[IPARM_START_TASK] = API_TASK_SOLVE;
380 m_iparm[IPARM_END_TASK] = API_TASK_REFINE;
383 m_perm.data(), m_invp.data(), &
x(0,
i), rhs, m_iparm.data(), m_dparm.data());
389 return m_iparm(IPARM_ERROR_NUMBER)==0;
413 template<
typename MatrixType_,
bool IsStrSym>
474 m_iparm(IPARM_SYM) = API_SYM_NO;
475 m_iparm(IPARM_FACTORIZATION) = API_FACT_LU;
525 template<
typename MatrixType_,
int UpLo_>
580 m_iparm(IPARM_SYM) = API_SYM_YES;
581 m_iparm(IPARM_FACTORIZATION) = API_FACT_LLT;
586 out.
resize(matrix.rows(), matrix.cols());
588 out.template selfadjointView<Lower>() = matrix.template selfadjointView<UpLo>();
609 template<
typename MatrixType_,
int UpLo_>
665 m_iparm(IPARM_SYM) = API_SYM_YES;
666 m_iparm(IPARM_FACTORIZATION) = API_FACT_LDLT;
672 out.
resize(matrix.rows(), matrix.cols());
673 out.template selfadjointView<Lower>() = matrix.template selfadjointView<UpLo>();
#define EIGEN_STATIC_ASSERT(X, MSG)
Matrix< float, 1, Dynamic > MatrixType
General-purpose arrays with easy API for coefficient-wise operations.
NumTraits< Scalar >::Real RealScalar
internal::traits< Derived >::StorageIndex StorageIndex
The type used to store indices.
internal::traits< Derived >::Scalar Scalar
Base class for all dense matrices, vectors, and expressions.
Array< double, DPARM_SIZE, 1 > m_dparm
void analyzePattern(ColSpMatrix &mat)
internal::pastix_traits< Derived >::MatrixType MatrixType_
Matrix< StorageIndex, Dynamic, 1 > m_invp
MatrixType::StorageIndex StorageIndex
Array< StorageIndex, IPARM_SIZE, 1 > & iparm()
Matrix< StorageIndex, Dynamic, 1 > m_perm
MatrixType::RealScalar RealScalar
void compute(ColSpMatrix &mat)
ComputationInfo info() const
Reports whether previous computation was successful.
int & iparm(int idxparam)
Array< int, IPARM_SIZE, 1 > m_iparm
bool _solve_impl(const MatrixBase< Rhs > &b, MatrixBase< Dest > &x) const
double & dparm(int idxparam)
MatrixType::Scalar Scalar
Matrix< Scalar, Dynamic, 1 > Vector
void factorize(ColSpMatrix &mat)
pastix_data_t * m_pastixdata
SparseMatrix< Scalar, ColMajor > ColSpMatrix
Array< double, DPARM_SIZE, 1 > & dparm()
SparseSolverBase< Derived > Base
A sparse direct supernodal Cholesky (LLT) factorization and solver based on the PaStiX library.
Base::ColSpMatrix ColSpMatrix
void grabMatrix(const MatrixType &matrix, ColSpMatrix &out)
PastixBase< PastixLDLT< MatrixType, UpLo_ > > Base
Array< int, IPARM_SIZE, 1 > m_iparm
PastixLDLT(const MatrixType &matrix)
void compute(const MatrixType &matrix)
void analyzePattern(const MatrixType &matrix)
void factorize(const MatrixType &matrix)
A sparse direct supernodal Cholesky (LLT) factorization and solver based on the PaStiX library.
PastixLLT(const MatrixType &matrix)
Array< int, IPARM_SIZE, 1 > m_iparm
void compute(const MatrixType &matrix)
void factorize(const MatrixType &matrix)
void analyzePattern(const MatrixType &matrix)
PastixBase< PastixLLT< MatrixType, UpLo_ > > Base
void grabMatrix(const MatrixType &matrix, ColSpMatrix &out)
Base::ColSpMatrix ColSpMatrix
Interface to the PaStix solver.
bool m_structureIsUptodate
void analyzePattern(const MatrixType &matrix)
void factorize(const MatrixType &matrix)
Array< int, IPARM_SIZE, 1 > m_iparm
void compute(const MatrixType &matrix)
PastixLU(const MatrixType &matrix)
PastixBase< PastixLU< MatrixType > > Base
void grabMatrix(const MatrixType &matrix, ColSpMatrix &out)
MatrixType::StorageIndex StorageIndex
ColSpMatrix m_transposedStructure
Base::ColSpMatrix ColSpMatrix
EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
const Scalar * data() const
EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
TransposeReturnType transpose()
A versatible sparse matrix representation.
void resize(Index rows, Index cols)
A base class for sparse solvers.
const unsigned int RowMajorBit
void fortran_to_c_numbering(MatrixType &mat)
void c_to_fortran_numbering(MatrixType &mat)
void eigen_pastix(pastix_data_t **pastix_data, int pastix_comm, int n, int *ptr, int *idx, float *vals, int *perm, int *invp, float *x, int nbrhs, int *iparm, double *dparm)
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.