10 #ifndef EIGEN_PASTIXSUPPORT_H
11 #define EIGEN_PASTIXSUPPORT_H
16 #define PASTIX_COMPLEX COMPLEX
17 #define PASTIX_DCOMPLEX DCOMPLEX
19 #define PASTIX_COMPLEX std::complex<float>
20 #define PASTIX_DCOMPLEX std::complex<double>
31 template<
typename _MatrixType,
bool IsStrSym = false>
class PastixLU;
32 template<
typename _MatrixType,
int Options>
class PastixLLT;
33 template<
typename _MatrixType,
int Options>
class PastixLDLT;
40 template<
typename _MatrixType>
49 template<
typename _MatrixType,
int Options>
58 template<
typename _MatrixType,
int Options>
67 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)
70 if (nbrhs == 0) {
x =
NULL; nbrhs=1;}
71 s_pastix(pastix_data, pastix_comm,
n, ptr, idx, vals,
perm, invp,
x, nbrhs, iparm, dparm);
74 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)
77 if (nbrhs == 0) {
x =
NULL; nbrhs=1;}
78 d_pastix(pastix_data, pastix_comm,
n, ptr, idx, vals,
perm, invp,
x, nbrhs, iparm, dparm);
81 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)
84 if (nbrhs == 0) {
x =
NULL; nbrhs=1;}
85 c_pastix(pastix_data, pastix_comm,
n, ptr, idx,
reinterpret_cast<PASTIX_COMPLEX*
>(vals),
perm, invp,
reinterpret_cast<PASTIX_COMPLEX*
>(
x), nbrhs, iparm, dparm);
88 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)
91 if (nbrhs == 0) {
x =
NULL; nbrhs=1;}
92 z_pastix(pastix_data, pastix_comm,
n, ptr, idx,
reinterpret_cast<PASTIX_DCOMPLEX*
>(vals),
perm, invp,
reinterpret_cast<PASTIX_DCOMPLEX*
>(
x), nbrhs, iparm, dparm);
96 template <
typename MatrixType>
99 if ( !(
mat.outerIndexPtr()[0]) )
102 for(
i = 0;
i <=
mat.rows(); ++
i)
103 ++
mat.outerIndexPtr()[
i];
104 for(
i = 0;
i <
mat.nonZeros(); ++
i)
105 ++
mat.innerIndexPtr()[
i];
110 template <
typename MatrixType>
114 if (
mat.outerIndexPtr()[0] == 1 )
117 for(
i = 0;
i <=
mat.rows(); ++
i)
118 --
mat.outerIndexPtr()[
i];
119 for(
i = 0;
i <
mat.nonZeros(); ++
i)
120 --
mat.innerIndexPtr()[
i];
127 template <
class Derived>
161 template<
typename Rhs,
typename Dest>
233 m_iparm(IPARM_START_TASK) = API_TASK_CLEAN;
234 m_iparm(IPARM_END_TASK) = API_TASK_CLEAN;
258 template <
class Derived>
262 m_iparm.setZero(IPARM_SIZE);
263 m_dparm.setZero(DPARM_SIZE);
265 m_iparm(IPARM_MODIFY_PARAMETER) = API_NO;
266 pastix(&m_pastixdata, MPI_COMM_WORLD,
268 0, 0, 0, 1, m_iparm.data(), m_dparm.data());
270 m_iparm[IPARM_MATRIX_VERIFICATION] = API_NO;
271 m_iparm[IPARM_VERBOSE] = API_VERBOSE_NOT;
272 m_iparm[IPARM_ORDERING] = API_ORDER_SCOTCH;
273 m_iparm[IPARM_INCOMPLETE] = API_NO;
274 m_iparm[IPARM_OOC_LIMIT] = 2000;
275 m_iparm[IPARM_RHS_MAKING] = API_RHS_B;
276 m_iparm(IPARM_MATRIX_VERIFICATION) = API_NO;
278 m_iparm(IPARM_START_TASK) = API_TASK_INIT;
279 m_iparm(IPARM_END_TASK) = API_TASK_INIT;
281 0, 0, 0, 0, m_iparm.data(), m_dparm.data());
284 if(m_iparm(IPARM_ERROR_NUMBER)) {
294 template <
class Derived>
302 m_iparm(IPARM_MATRIX_VERIFICATION) = API_NO;
306 template <
class Derived>
309 eigen_assert(m_initisOk &&
"The initialization of PaSTiX failed");
315 m_size = internal::convert_index<int>(
mat.rows());
316 m_perm.resize(m_size);
317 m_invp.resize(m_size);
319 m_iparm(IPARM_START_TASK) = API_TASK_ORDERING;
320 m_iparm(IPARM_END_TASK) = API_TASK_ANALYSE;
322 mat.valuePtr(), m_perm.data(), m_invp.data(), 0, 0, m_iparm.data(), m_dparm.data());
325 if(m_iparm(IPARM_ERROR_NUMBER))
328 m_analysisIsOk =
false;
333 m_analysisIsOk =
true;
337 template <
class Derived>
341 eigen_assert(m_analysisIsOk &&
"The analysis phase should be called before the factorization phase");
342 m_iparm(IPARM_START_TASK) = API_TASK_NUMFACT;
343 m_iparm(IPARM_END_TASK) = API_TASK_NUMFACT;
344 m_size = internal::convert_index<int>(
mat.rows());
347 mat.valuePtr(), m_perm.data(), m_invp.data(), 0, 0, m_iparm.data(), m_dparm.data());
350 if(m_iparm(IPARM_ERROR_NUMBER))
353 m_factorizationIsOk =
false;
354 m_isInitialized =
false;
359 m_factorizationIsOk =
true;
360 m_isInitialized =
true;
365 template<
typename Base>
366 template<
typename Rhs,
typename Dest>
369 eigen_assert(m_isInitialized &&
"The matrix should be factorized first");
371 THIS_METHOD_IS_ONLY_FOR_COLUMN_MAJOR_MATRICES);
376 for (
int i = 0;
i <
b.cols();
i++){
377 m_iparm[IPARM_START_TASK] = API_TASK_SOLVE;
378 m_iparm[IPARM_END_TASK] = API_TASK_REFINE;
381 m_perm.data(), m_invp.data(), &
x(0,
i), rhs, m_iparm.data(), m_dparm.data());
387 return m_iparm(IPARM_ERROR_NUMBER)==0;
411 template<
typename _MatrixType,
bool IsStrSym>
472 m_iparm(IPARM_SYM) = API_SYM_NO;
473 m_iparm(IPARM_FACTORIZATION) = API_FACT_LU;
523 template<
typename _MatrixType,
int _UpLo>
578 m_iparm(IPARM_SYM) = API_SYM_YES;
579 m_iparm(IPARM_FACTORIZATION) = API_FACT_LLT;
586 out.template selfadjointView<Lower>() =
matrix.template selfadjointView<UpLo>();
607 template<
typename _MatrixType,
int _UpLo>
608 class PastixLDLT :
public PastixBase< PastixLDLT<_MatrixType, _UpLo> >
663 m_iparm(IPARM_SYM) = API_SYM_YES;
664 m_iparm(IPARM_FACTORIZATION) = API_FACT_LDLT;
671 out.template selfadjointView<Lower>() =
matrix.template selfadjointView<UpLo>();