10 #ifndef EIGEN_UMFPACKSUPPORT_H
11 #define EIGEN_UMFPACKSUPPORT_H
15 #ifndef SuiteSparse_long
17 #define SuiteSparse_long UF_long
19 #error neither SuiteSparse_long nor UF_long are defined
32 { umfpack_di_defaults(control); }
34 inline void umfpack_defaults(
double control[UMFPACK_CONTROL], std::complex<double>,
int)
35 { umfpack_zi_defaults(control); }
37 inline void umfpack_defaults(
double control[UMFPACK_CONTROL],
double, SuiteSparse_long)
38 { umfpack_dl_defaults(control); }
40 inline void umfpack_defaults(
double control[UMFPACK_CONTROL], std::complex<double>, SuiteSparse_long)
41 { umfpack_zl_defaults(control); }
44 inline void umfpack_report_info(
double control[UMFPACK_CONTROL],
double info[UMFPACK_INFO],
double,
int)
45 { umfpack_di_report_info(control, info);}
47 inline void umfpack_report_info(
double control[UMFPACK_CONTROL],
double info[UMFPACK_INFO], std::complex<double>,
int)
48 { umfpack_zi_report_info(control, info);}
50 inline void umfpack_report_info(
double control[UMFPACK_CONTROL],
double info[UMFPACK_INFO],
double, SuiteSparse_long)
51 { umfpack_dl_report_info(control, info);}
53 inline void umfpack_report_info(
double control[UMFPACK_CONTROL],
double info[UMFPACK_INFO], std::complex<double>, SuiteSparse_long)
54 { umfpack_zl_report_info(control, info);}
58 { umfpack_di_report_status(control, status);}
61 { umfpack_zi_report_status(control, status);}
64 { umfpack_dl_report_status(control, status);}
66 inline void umfpack_report_status(
double control[UMFPACK_CONTROL],
int status, std::complex<double>, SuiteSparse_long)
67 { umfpack_zl_report_status(control, status);}
71 { umfpack_di_report_control(control);}
74 { umfpack_zi_report_control(control);}
77 { umfpack_dl_report_control(control);}
80 { umfpack_zl_report_control(control);}
84 { umfpack_di_free_numeric(Numeric); *Numeric = 0; }
87 { umfpack_zi_free_numeric(Numeric); *Numeric = 0; }
90 { umfpack_dl_free_numeric(Numeric); *Numeric = 0; }
93 { umfpack_zl_free_numeric(Numeric); *Numeric = 0; }
97 { umfpack_di_free_symbolic(Symbolic); *Symbolic = 0; }
100 { umfpack_zi_free_symbolic(Symbolic); *Symbolic = 0; }
103 { umfpack_dl_free_symbolic(Symbolic); *Symbolic = 0; }
106 { umfpack_zl_free_symbolic(Symbolic); *Symbolic = 0; }
110 const int Ap[],
const int Ai[],
const double Ax[],
void **Symbolic,
111 const double Control [UMFPACK_CONTROL],
double Info [UMFPACK_INFO])
113 return umfpack_di_symbolic(n_row,n_col,Ap,Ai,Ax,Symbolic,Control,Info);
117 const int Ap[],
const int Ai[],
const std::complex<double> Ax[],
void **Symbolic,
118 const double Control [UMFPACK_CONTROL],
double Info [UMFPACK_INFO])
120 return umfpack_zi_symbolic(n_row,n_col,Ap,Ai,&
numext::real_ref(Ax[0]),0,Symbolic,Control,Info);
123 const SuiteSparse_long Ap[],
const SuiteSparse_long Ai[],
const double Ax[],
void **Symbolic,
124 const double Control [UMFPACK_CONTROL],
double Info [UMFPACK_INFO])
126 return umfpack_dl_symbolic(n_row,n_col,Ap,Ai,Ax,Symbolic,Control,Info);
130 const SuiteSparse_long Ap[],
const SuiteSparse_long Ai[],
const std::complex<double> Ax[],
void **Symbolic,
131 const double Control [UMFPACK_CONTROL],
double Info [UMFPACK_INFO])
133 return umfpack_zl_symbolic(n_row,n_col,Ap,Ai,&
numext::real_ref(Ax[0]),0,Symbolic,Control,Info);
138 void *Symbolic,
void **Numeric,
139 const double Control[UMFPACK_CONTROL],
double Info [UMFPACK_INFO])
141 return umfpack_di_numeric(Ap,Ai,Ax,Symbolic,Numeric,Control,Info);
144 inline int umfpack_numeric(
const int Ap[],
const int Ai[],
const std::complex<double> Ax[],
145 void *Symbolic,
void **Numeric,
146 const double Control[UMFPACK_CONTROL],
double Info [UMFPACK_INFO])
148 return umfpack_zi_numeric(Ap,Ai,&
numext::real_ref(Ax[0]),0,Symbolic,Numeric,Control,Info);
150 inline SuiteSparse_long
umfpack_numeric(
const SuiteSparse_long Ap[],
const SuiteSparse_long Ai[],
const double Ax[],
151 void *Symbolic,
void **Numeric,
152 const double Control[UMFPACK_CONTROL],
double Info [UMFPACK_INFO])
154 return umfpack_dl_numeric(Ap,Ai,Ax,Symbolic,Numeric,Control,Info);
157 inline SuiteSparse_long
umfpack_numeric(
const SuiteSparse_long Ap[],
const SuiteSparse_long Ai[],
const std::complex<double> Ax[],
158 void *Symbolic,
void **Numeric,
159 const double Control[UMFPACK_CONTROL],
double Info [UMFPACK_INFO])
161 return umfpack_zl_numeric(Ap,Ai,&
numext::real_ref(Ax[0]),0,Symbolic,Numeric,Control,Info);
165 inline int umfpack_solve(
int sys,
const int Ap[],
const int Ai[],
const double Ax[],
166 double X[],
const double B[],
void *Numeric,
167 const double Control[UMFPACK_CONTROL],
double Info[UMFPACK_INFO])
169 return umfpack_di_solve(sys,Ap,Ai,Ax,X,B,Numeric,Control,Info);
172 inline int umfpack_solve(
int sys,
const int Ap[],
const int Ai[],
const std::complex<double> Ax[],
173 std::complex<double> X[],
const std::complex<double> B[],
void *Numeric,
174 const double Control[UMFPACK_CONTROL],
double Info[UMFPACK_INFO])
176 return umfpack_zi_solve(sys,Ap,Ai,&
numext::real_ref(Ax[0]),0,&
numext::real_ref(X[0]),0,&
numext::real_ref(B[0]),0,Numeric,Control,Info);
179 inline SuiteSparse_long
umfpack_solve(
int sys,
const SuiteSparse_long Ap[],
const SuiteSparse_long Ai[],
const double Ax[],
180 double X[],
const double B[],
void *Numeric,
181 const double Control[UMFPACK_CONTROL],
double Info[UMFPACK_INFO])
183 return umfpack_dl_solve(sys,Ap,Ai,Ax,X,B,Numeric,Control,Info);
186 inline SuiteSparse_long
umfpack_solve(
int sys,
const SuiteSparse_long Ap[],
const SuiteSparse_long Ai[],
const std::complex<double> Ax[],
187 std::complex<double> X[],
const std::complex<double> B[],
void *Numeric,
188 const double Control[UMFPACK_CONTROL],
double Info[UMFPACK_INFO])
190 return umfpack_zl_solve(sys,Ap,Ai,&
numext::real_ref(Ax[0]),0,&
numext::real_ref(X[0]),0,&
numext::real_ref(B[0]),0,Numeric,Control,Info);
194 inline int umfpack_get_lunz(
int *lnz,
int *unz,
int *n_row,
int *n_col,
int *nz_udiag,
void *Numeric,
double)
196 return umfpack_di_get_lunz(lnz,unz,n_row,n_col,nz_udiag,Numeric);
199 inline int umfpack_get_lunz(
int *lnz,
int *unz,
int *n_row,
int *n_col,
int *nz_udiag,
void *Numeric, std::complex<double>)
201 return umfpack_zi_get_lunz(lnz,unz,n_row,n_col,nz_udiag,Numeric);
204 inline SuiteSparse_long
umfpack_get_lunz( SuiteSparse_long *lnz, SuiteSparse_long *unz, SuiteSparse_long *n_row, SuiteSparse_long *n_col,
205 SuiteSparse_long *nz_udiag,
void *Numeric,
double)
207 return umfpack_dl_get_lunz(lnz,unz,n_row,n_col,nz_udiag,Numeric);
210 inline SuiteSparse_long
umfpack_get_lunz( SuiteSparse_long *lnz, SuiteSparse_long *unz, SuiteSparse_long *n_row, SuiteSparse_long *n_col,
211 SuiteSparse_long *nz_udiag,
void *Numeric, std::complex<double>)
213 return umfpack_zl_get_lunz(lnz,unz,n_row,n_col,nz_udiag,Numeric);
218 int P[],
int Q[],
double Dx[],
int *do_recip,
double Rs[],
void *Numeric)
220 return umfpack_di_get_numeric(Lp,Lj,Lx,Up,Ui,Ux,P,Q,Dx,do_recip,Rs,Numeric);
223 inline int umfpack_get_numeric(
int Lp[],
int Lj[], std::complex<double> Lx[],
int Up[],
int Ui[], std::complex<double> Ux[],
224 int P[],
int Q[], std::complex<double> Dx[],
int *do_recip,
double Rs[],
void *Numeric)
229 return umfpack_zi_get_numeric(Lp,Lj,Lx?&lx0_real:0,0,Up,Ui,Ux?&ux0_real:0,0,P,Q,
230 Dx?&dx0_real:0,0,do_recip,Rs,Numeric);
232 inline SuiteSparse_long
umfpack_get_numeric(SuiteSparse_long Lp[], SuiteSparse_long Lj[],
double Lx[], SuiteSparse_long Up[], SuiteSparse_long Ui[],
double Ux[],
233 SuiteSparse_long P[], SuiteSparse_long Q[],
double Dx[], SuiteSparse_long *do_recip,
double Rs[],
void *Numeric)
235 return umfpack_dl_get_numeric(Lp,Lj,Lx,Up,Ui,Ux,P,Q,Dx,do_recip,Rs,Numeric);
238 inline SuiteSparse_long
umfpack_get_numeric(SuiteSparse_long Lp[], SuiteSparse_long Lj[], std::complex<double> Lx[], SuiteSparse_long Up[], SuiteSparse_long Ui[], std::complex<double> Ux[],
239 SuiteSparse_long P[], SuiteSparse_long Q[], std::complex<double> Dx[], SuiteSparse_long *do_recip,
double Rs[],
void *Numeric)
244 return umfpack_zl_get_numeric(Lp,Lj,Lx?&lx0_real:0,0,Up,Ui,Ux?&ux0_real:0,0,P,Q,
245 Dx?&dx0_real:0,0,do_recip,Rs,Numeric);
251 return umfpack_di_get_determinant(Mx,Ex,NumericHandle,User_Info);
254 inline int umfpack_get_determinant(std::complex<double> *Mx,
double *Ex,
void *NumericHandle,
double User_Info [UMFPACK_INFO],
int)
257 return umfpack_zi_get_determinant(&mx_real,0,Ex,NumericHandle,User_Info);
260 inline SuiteSparse_long
umfpack_get_determinant(
double *Mx,
double *Ex,
void *NumericHandle,
double User_Info [UMFPACK_INFO], SuiteSparse_long)
262 return umfpack_dl_get_determinant(Mx,Ex,NumericHandle,User_Info);
265 inline SuiteSparse_long
umfpack_get_determinant(std::complex<double> *Mx,
double *Ex,
void *NumericHandle,
double User_Info [UMFPACK_INFO], SuiteSparse_long)
268 return umfpack_zl_get_determinant(&mx_real,0,Ex,NumericHandle,User_Info);
287 template<
typename _MatrixType>
296 typedef typename MatrixType::Scalar
Scalar;
321 template<
typename InputMatrixType>
377 template<
typename InputMatrixType>
382 grab(matrix.derived());
393 template<
typename InputMatrixType>
399 grab(matrix.derived());
443 template<
typename InputMatrixType>
450 grab(matrix.derived());
484 template<
typename BDerived,
typename XDerived>
507 internal::convert_index<StorageIndex>(
mp_matrix.cols()),
529 template<
typename MatrixDerived>
571 template<
typename MatrixType>
574 if (m_extractedDataAreDirty)
581 m_l.resize(rows,(
std::min)(rows,cols));
582 m_l.resizeNonZeros(lnz);
584 m_u.resize((
std::min)(rows,cols),cols);
585 m_u.resizeNonZeros(unz);
592 m_u.outerIndexPtr(), m_u.innerIndexPtr(), m_u.valuePtr(),
593 m_p.data(), m_q.data(), 0, 0, 0, m_numeric);
595 m_extractedDataAreDirty =
false;
599 template<
typename MatrixType>
607 template<
typename MatrixType>
608 template<
typename BDerived,
typename XDerived>
611 Index rhsCols = b.cols();
614 eigen_assert(b.derived().data() != x.derived().data() &&
" Umfpack does not support inplace solve");
618 if(x.innerStride()!=1)
621 x_ptr = x_tmp.
data();
623 for (
int j=0; j<rhsCols; ++j)
625 if(x.innerStride()==1)
626 x_ptr = &x.col(j).coeffRef(0);
628 mp_matrix.outerIndexPtr(), mp_matrix.innerIndexPtr(), mp_matrix.valuePtr(),
629 x_ptr, &b.const_cast_derived().col(j).coeffRef(0),
630 m_numeric, m_control.data(), m_umfpackInfo.data());
631 if(x.innerStride()!=1)
#define eigen_assert(x)
Definition: Macros.h:1037
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:50
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void resize(Index rows, Index cols)
Definition: PlainObjectBase.h:271
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar * data() const
Definition: PlainObjectBase.h:247
A base class for sparse solvers.
Definition: SparseSolverBase.h:68
void _solve_impl(const SparseMatrixBase< Rhs > &b, SparseMatrixBase< Dest > &dest) const
Definition: SparseSolverBase.h:111
bool m_isInitialized
Definition: SparseSolverBase.h:119
A sparse LU factorization and solver based on UmfPack.
Definition: UmfPackSupport.h:289
void compute(const InputMatrixType &matrix)
Definition: UmfPackSupport.h:378
UmfpackInfo m_umfpackInfo
Definition: UmfPackSupport.h:549
SparseMatrix< Scalar, ColMajor, StorageIndex > UmfpackMatrixType
Definition: UmfPackSupport.h:303
void factorize(const InputMatrixType &matrix)
Definition: UmfPackSupport.h:444
~UmfPackLU()
Definition: UmfPackSupport.h:329
void grab(const EigenBase< MatrixDerived > &A)
Definition: UmfPackSupport.h:530
void printUmfpackControl()
Definition: UmfPackSupport.h:459
void * m_numeric
Definition: UmfPackSupport.h:558
int m_factorizationIsOk
Definition: UmfPackSupport.h:562
void factorize_impl()
Definition: UmfPackSupport.h:518
void * m_symbolic
Definition: UmfPackSupport.h:559
UmfpackMatrixRef mp_matrix
Definition: UmfPackSupport.h:556
const LUMatrixType & matrixL() const
Definition: UmfPackSupport.h:349
UmfPackLU(const InputMatrixType &matrix)
Definition: UmfPackSupport.h:322
StorageIndex m_fact_errorCode
Definition: UmfPackSupport.h:547
Scalar determinant() const
Definition: UmfPackSupport.h:600
Array< double, UMFPACK_INFO, 1 > UmfpackInfo
Definition: UmfPackSupport.h:313
Index rows() const
Definition: UmfPackSupport.h:335
MatrixType::RealScalar RealScalar
Definition: UmfPackSupport.h:297
void init()
Definition: UmfPackSupport.h:493
MatrixType::Scalar Scalar
Definition: UmfPackSupport.h:296
LUMatrixType m_l
Definition: UmfPackSupport.h:546
UmfpackControl & umfpackControl()
Definition: UmfPackSupport.h:432
ComputationInfo info() const
Reports whether previous computation was successful.
Definition: UmfPackSupport.h:343
Array< double, UMFPACK_CONTROL, 1 > UmfpackControl
Definition: UmfPackSupport.h:312
int m_analysisIsOk
Definition: UmfPackSupport.h:563
void extractData() const
Definition: UmfPackSupport.h:572
int umfpackFactorizeReturncode() const
Definition: UmfPackSupport.h:409
bool _solve_impl(const MatrixBase< BDerived > &b, MatrixBase< XDerived > &x) const
Definition: UmfPackSupport.h:609
MatrixType::StorageIndex StorageIndex
Definition: UmfPackSupport.h:298
Matrix< Scalar, Dynamic, 1 > Vector
Definition: UmfPackSupport.h:299
Matrix< int, 1, MatrixType::ColsAtCompileTime > IntRowVectorType
Definition: UmfPackSupport.h:300
bool m_extractedDataAreDirty
Definition: UmfPackSupport.h:564
UmfpackControl m_control
Definition: UmfPackSupport.h:548
void printUmfpackInfo()
Definition: UmfPackSupport.h:468
void analyzePattern_impl()
Definition: UmfPackSupport.h:504
IntColVectorType m_p
Definition: UmfPackSupport.h:552
IntRowVectorType m_q
Definition: UmfPackSupport.h:553
const IntColVectorType & permutationP() const
Definition: UmfPackSupport.h:361
_MatrixType MatrixType
Definition: UmfPackSupport.h:295
Index cols() const
Definition: UmfPackSupport.h:336
ComputationInfo m_info
Definition: UmfPackSupport.h:561
Matrix< int, MatrixType::RowsAtCompileTime, 1 > IntColVectorType
Definition: UmfPackSupport.h:301
void grab(const UmfpackMatrixRef &A)
Definition: UmfPackSupport.h:536
const IntRowVectorType & permutationQ() const
Definition: UmfPackSupport.h:367
UmfpackMatrixType m_dummy
Definition: UmfPackSupport.h:555
void analyzePattern(const InputMatrixType &matrix)
Definition: UmfPackSupport.h:394
UmfPackLU(const UmfPackLU &)
Definition: UmfPackSupport.h:567
LUMatrixType m_u
Definition: UmfPackSupport.h:551
SparseMatrix< Scalar > LUMatrixType
Definition: UmfPackSupport.h:302
@ ColsAtCompileTime
Definition: UmfPackSupport.h:306
@ MaxColsAtCompileTime
Definition: UmfPackSupport.h:307
Ref< const UmfpackMatrixType, StandardCompressedFormat > UmfpackMatrixRef
Definition: UmfPackSupport.h:304
const UmfpackControl & umfpackControl() const
Definition: UmfPackSupport.h:421
void printUmfpackStatus()
Definition: UmfPackSupport.h:478
SparseSolverBase< UmfPackLU< _MatrixType > > Base
Definition: UmfPackSupport.h:291
UmfPackLU()
Definition: UmfPackSupport.h:315
const LUMatrixType & matrixU() const
Definition: UmfPackSupport.h:355
ComputationInfo
Definition: Constants.h:440
@ NumericalIssue
Definition: Constants.h:444
@ InvalidInput
Definition: Constants.h:449
@ Success
Definition: Constants.h:442
const unsigned int RowMajorBit
Definition: Constants.h:66
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16() min(const bfloat16 &a, const bfloat16 &b)
Definition: BFloat16.h:571
EIGEN_DEVICE_FUNC internal::add_const_on_value_type< EIGEN_MATHFUNC_RETVAL(real_ref, Scalar) >::type real_ref(const Scalar &x)
Definition: MathFunctions.h:1237
Namespace containing all symbols from the Eigen library.
Definition: LDLT.h:16
int umfpack_get_numeric(int Lp[], int Lj[], double Lx[], int Up[], int Ui[], double Ux[], int P[], int Q[], double Dx[], int *do_recip, double Rs[], void *Numeric)
Definition: UmfPackSupport.h:217
int umfpack_get_determinant(double *Mx, double *Ex, void *NumericHandle, double User_Info[UMFPACK_INFO], int)
Definition: UmfPackSupport.h:249
int umfpack_solve(int sys, const int Ap[], const int Ai[], const double Ax[], double X[], const double B[], void *Numeric, const double Control[UMFPACK_CONTROL], double Info[UMFPACK_INFO])
Definition: UmfPackSupport.h:165
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74
void umfpack_report_control(double control[UMFPACK_CONTROL], double, int)
Definition: UmfPackSupport.h:70
void umfpack_free_numeric(void **Numeric, double, int)
Definition: UmfPackSupport.h:83
void umfpack_defaults(double control[UMFPACK_CONTROL], double, int)
Definition: UmfPackSupport.h:31
int umfpack_symbolic(int n_row, int n_col, const int Ap[], const int Ai[], const double Ax[], void **Symbolic, const double Control[UMFPACK_CONTROL], double Info[UMFPACK_INFO])
Definition: UmfPackSupport.h:109
void umfpack_report_status(double control[UMFPACK_CONTROL], int status, double, int)
Definition: UmfPackSupport.h:57
void umfpack_report_info(double control[UMFPACK_CONTROL], double info[UMFPACK_INFO], double, int)
Definition: UmfPackSupport.h:44
void umfpack_free_symbolic(void **Symbolic, double, int)
Definition: UmfPackSupport.h:96
int umfpack_numeric(const int Ap[], const int Ai[], const double Ax[], void *Symbolic, void **Numeric, const double Control[UMFPACK_CONTROL], double Info[UMFPACK_INFO])
Definition: UmfPackSupport.h:137
int umfpack_get_lunz(int *lnz, int *unz, int *n_row, int *n_col, int *nz_udiag, void *Numeric, double)
Definition: UmfPackSupport.h:194
Flags
Special flags for archives.
Definition: cereal.hpp:185
Definition: EigenBase.h:30
EIGEN_DEVICE_FUNC Derived & derived()
Definition: EigenBase.h:46