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
34 { umfpack_di_defaults(control); }
36 inline void umfpack_defaults(
double control[UMFPACK_CONTROL], std::complex<double>,
int)
37 { umfpack_zi_defaults(control); }
39 inline void umfpack_defaults(
double control[UMFPACK_CONTROL],
double, SuiteSparse_long)
40 { umfpack_dl_defaults(control); }
42 inline void umfpack_defaults(
double control[UMFPACK_CONTROL], std::complex<double>, SuiteSparse_long)
43 { umfpack_zl_defaults(control); }
46 inline void umfpack_report_info(
double control[UMFPACK_CONTROL],
double info[UMFPACK_INFO],
double,
int)
47 { umfpack_di_report_info(control, info);}
49 inline void umfpack_report_info(
double control[UMFPACK_CONTROL],
double info[UMFPACK_INFO], std::complex<double>,
int)
50 { umfpack_zi_report_info(control, info);}
52 inline void umfpack_report_info(
double control[UMFPACK_CONTROL],
double info[UMFPACK_INFO],
double, SuiteSparse_long)
53 { umfpack_dl_report_info(control, info);}
55 inline void umfpack_report_info(
double control[UMFPACK_CONTROL],
double info[UMFPACK_INFO], std::complex<double>, SuiteSparse_long)
56 { umfpack_zl_report_info(control, info);}
60 { umfpack_di_report_status(control, status);}
63 { umfpack_zi_report_status(control, status);}
66 { umfpack_dl_report_status(control, status);}
68 inline void umfpack_report_status(
double control[UMFPACK_CONTROL],
int status, std::complex<double>, SuiteSparse_long)
69 { umfpack_zl_report_status(control, status);}
73 { umfpack_di_report_control(control);}
76 { umfpack_zi_report_control(control);}
79 { umfpack_dl_report_control(control);}
82 { umfpack_zl_report_control(control);}
86 { umfpack_di_free_numeric(Numeric); *Numeric = 0; }
89 { umfpack_zi_free_numeric(Numeric); *Numeric = 0; }
92 { umfpack_dl_free_numeric(Numeric); *Numeric = 0; }
95 { umfpack_zl_free_numeric(Numeric); *Numeric = 0; }
99 { umfpack_di_free_symbolic(Symbolic); *Symbolic = 0; }
102 { umfpack_zi_free_symbolic(Symbolic); *Symbolic = 0; }
105 { umfpack_dl_free_symbolic(Symbolic); *Symbolic = 0; }
108 { umfpack_zl_free_symbolic(Symbolic); *Symbolic = 0; }
112 const int Ap[],
const int Ai[],
const double Ax[],
void **Symbolic,
113 const double Control [UMFPACK_CONTROL],
double Info [UMFPACK_INFO])
115 return umfpack_di_symbolic(n_row,n_col,Ap,Ai,Ax,Symbolic,Control,Info);
119 const int Ap[],
const int Ai[],
const std::complex<double> Ax[],
void **Symbolic,
120 const double Control [UMFPACK_CONTROL],
double Info [UMFPACK_INFO])
122 return umfpack_zi_symbolic(n_row,n_col,Ap,Ai,&
numext::real_ref(Ax[0]),0,Symbolic,Control,Info);
125 const SuiteSparse_long Ap[],
const SuiteSparse_long Ai[],
const double Ax[],
void **Symbolic,
126 const double Control [UMFPACK_CONTROL],
double Info [UMFPACK_INFO])
128 return umfpack_dl_symbolic(n_row,n_col,Ap,Ai,Ax,Symbolic,Control,Info);
132 const SuiteSparse_long Ap[],
const SuiteSparse_long Ai[],
const std::complex<double> Ax[],
void **Symbolic,
133 const double Control [UMFPACK_CONTROL],
double Info [UMFPACK_INFO])
135 return umfpack_zl_symbolic(n_row,n_col,Ap,Ai,&
numext::real_ref(Ax[0]),0,Symbolic,Control,Info);
140 void *Symbolic,
void **Numeric,
141 const double Control[UMFPACK_CONTROL],
double Info [UMFPACK_INFO])
143 return umfpack_di_numeric(Ap,Ai,Ax,Symbolic,Numeric,Control,Info);
146 inline int umfpack_numeric(
const int Ap[],
const int Ai[],
const std::complex<double> Ax[],
147 void *Symbolic,
void **Numeric,
148 const double Control[UMFPACK_CONTROL],
double Info [UMFPACK_INFO])
150 return umfpack_zi_numeric(Ap,Ai,&
numext::real_ref(Ax[0]),0,Symbolic,Numeric,Control,Info);
152 inline SuiteSparse_long
umfpack_numeric(
const SuiteSparse_long Ap[],
const SuiteSparse_long Ai[],
const double Ax[],
153 void *Symbolic,
void **Numeric,
154 const double Control[UMFPACK_CONTROL],
double Info [UMFPACK_INFO])
156 return umfpack_dl_numeric(Ap,Ai,Ax,Symbolic,Numeric,Control,Info);
159 inline SuiteSparse_long
umfpack_numeric(
const SuiteSparse_long Ap[],
const SuiteSparse_long Ai[],
const std::complex<double> Ax[],
160 void *Symbolic,
void **Numeric,
161 const double Control[UMFPACK_CONTROL],
double Info [UMFPACK_INFO])
163 return umfpack_zl_numeric(Ap,Ai,&
numext::real_ref(Ax[0]),0,Symbolic,Numeric,Control,Info);
167 inline int umfpack_solve(
int sys,
const int Ap[],
const int Ai[],
const double Ax[],
168 double X[],
const double B[],
void *Numeric,
169 const double Control[UMFPACK_CONTROL],
double Info[UMFPACK_INFO])
171 return umfpack_di_solve(sys,Ap,Ai,Ax,
X,
B,Numeric,Control,Info);
174 inline int umfpack_solve(
int sys,
const int Ap[],
const int Ai[],
const std::complex<double> Ax[],
175 std::complex<double>
X[],
const std::complex<double>
B[],
void *Numeric,
176 const double Control[UMFPACK_CONTROL],
double Info[UMFPACK_INFO])
178 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);
181 inline SuiteSparse_long
umfpack_solve(
int sys,
const SuiteSparse_long Ap[],
const SuiteSparse_long Ai[],
const double Ax[],
182 double X[],
const double B[],
void *Numeric,
183 const double Control[UMFPACK_CONTROL],
double Info[UMFPACK_INFO])
185 return umfpack_dl_solve(sys,Ap,Ai,Ax,
X,
B,Numeric,Control,Info);
188 inline SuiteSparse_long
umfpack_solve(
int sys,
const SuiteSparse_long Ap[],
const SuiteSparse_long Ai[],
const std::complex<double> Ax[],
189 std::complex<double>
X[],
const std::complex<double>
B[],
void *Numeric,
190 const double Control[UMFPACK_CONTROL],
double Info[UMFPACK_INFO])
192 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);
196 inline int umfpack_get_lunz(
int *lnz,
int *unz,
int *n_row,
int *n_col,
int *nz_udiag,
void *Numeric,
double)
198 return umfpack_di_get_lunz(lnz,unz,n_row,n_col,nz_udiag,Numeric);
201 inline int umfpack_get_lunz(
int *lnz,
int *unz,
int *n_row,
int *n_col,
int *nz_udiag,
void *Numeric, std::complex<double>)
203 return umfpack_zi_get_lunz(lnz,unz,n_row,n_col,nz_udiag,Numeric);
206 inline SuiteSparse_long
umfpack_get_lunz( SuiteSparse_long *lnz, SuiteSparse_long *unz, SuiteSparse_long *n_row, SuiteSparse_long *n_col,
207 SuiteSparse_long *nz_udiag,
void *Numeric,
double)
209 return umfpack_dl_get_lunz(lnz,unz,n_row,n_col,nz_udiag,Numeric);
212 inline SuiteSparse_long
umfpack_get_lunz( SuiteSparse_long *lnz, SuiteSparse_long *unz, SuiteSparse_long *n_row, SuiteSparse_long *n_col,
213 SuiteSparse_long *nz_udiag,
void *Numeric, std::complex<double>)
215 return umfpack_zl_get_lunz(lnz,unz,n_row,n_col,nz_udiag,Numeric);
220 int P[],
int Q[],
double Dx[],
int *do_recip,
double Rs[],
void *Numeric)
222 return umfpack_di_get_numeric(Lp,Lj,Lx,Up,Ui,Ux,
P,
Q,Dx,do_recip,Rs,Numeric);
225 inline int umfpack_get_numeric(
int Lp[],
int Lj[], std::complex<double> Lx[],
int Up[],
int Ui[], std::complex<double> Ux[],
226 int P[],
int Q[], std::complex<double> Dx[],
int *do_recip,
double Rs[],
void *Numeric)
231 return umfpack_zi_get_numeric(Lp,Lj,Lx?&lx0_real:0,0,Up,Ui,Ux?&ux0_real:0,0,
P,
Q,
232 Dx?&dx0_real:0,0,do_recip,Rs,Numeric);
234 inline SuiteSparse_long
umfpack_get_numeric(SuiteSparse_long Lp[], SuiteSparse_long Lj[],
double Lx[], SuiteSparse_long Up[], SuiteSparse_long Ui[],
double Ux[],
235 SuiteSparse_long
P[], SuiteSparse_long
Q[],
double Dx[], SuiteSparse_long *do_recip,
double Rs[],
void *Numeric)
237 return umfpack_dl_get_numeric(Lp,Lj,Lx,Up,Ui,Ux,
P,
Q,Dx,do_recip,Rs,Numeric);
240 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[],
241 SuiteSparse_long
P[], SuiteSparse_long
Q[], std::complex<double> Dx[], SuiteSparse_long *do_recip,
double Rs[],
void *Numeric)
246 return umfpack_zl_get_numeric(Lp,Lj,Lx?&lx0_real:0,0,Up,Ui,Ux?&ux0_real:0,0,
P,
Q,
247 Dx?&dx0_real:0,0,do_recip,Rs,Numeric);
253 return umfpack_di_get_determinant(Mx,Ex,NumericHandle,User_Info);
256 inline int umfpack_get_determinant(std::complex<double> *Mx,
double *Ex,
void *NumericHandle,
double User_Info [UMFPACK_INFO],
int)
259 return umfpack_zi_get_determinant(&mx_real,0,Ex,NumericHandle,User_Info);
262 inline SuiteSparse_long
umfpack_get_determinant(
double *Mx,
double *Ex,
void *NumericHandle,
double User_Info [UMFPACK_INFO], SuiteSparse_long)
264 return umfpack_dl_get_determinant(Mx,Ex,NumericHandle,User_Info);
267 inline SuiteSparse_long
umfpack_get_determinant(std::complex<double> *Mx,
double *Ex,
void *NumericHandle,
double User_Info [UMFPACK_INFO], SuiteSparse_long)
270 return umfpack_zl_get_determinant(&mx_real,0,Ex,NumericHandle,User_Info);
289 template<
typename MatrixType_>
296 using Base::_solve_impl;
323 template<
typename InputMatrixType>
379 template<
typename InputMatrixType>
384 grab(matrix.derived());
395 template<
typename InputMatrixType>
401 grab(matrix.derived());
445 template<
typename InputMatrixType>
452 grab(matrix.derived());
486 template<
typename BDerived,
typename XDerived>
509 internal::convert_index<StorageIndex>(
mp_matrix.cols()),
531 template<
typename MatrixDerived>
573 template<
typename MatrixType>
576 if (m_extractedDataAreDirty)
584 m_l.resizeNonZeros(lnz);
587 m_u.resizeNonZeros(unz);
594 m_u.outerIndexPtr(), m_u.innerIndexPtr(), m_u.valuePtr(),
595 m_p.data(), m_q.data(), 0, 0, 0, m_numeric);
597 m_extractedDataAreDirty =
false;
601 template<
typename MatrixType>
609 template<
typename MatrixType>
610 template<
typename BDerived,
typename XDerived>
615 eigen_assert((XDerived::Flags&
RowMajorBit)==0 &&
"UmfPackLU backend does not support non col-major result yet");
616 eigen_assert(
b.derived().data() !=
x.derived().data() &&
" Umfpack does not support inplace solve");
620 if(
x.innerStride()!=1)
623 x_ptr = x_tmp.
data();
625 for (
int j=0;
j<rhsCols; ++
j)
627 if(
x.innerStride()==1)
628 x_ptr = &
x.col(
j).coeffRef(0);
630 mp_matrix.outerIndexPtr(), mp_matrix.innerIndexPtr(), mp_matrix.valuePtr(),
631 x_ptr, &
b.const_cast_derived().col(
j).coeffRef(0),
632 m_numeric, m_control.data(), m_umfpackInfo.data());
633 if(
x.innerStride()!=1)
Projective3d P(Matrix4d::Random())
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.
const Scalar * data() const
constexpr void resize(Index rows, Index cols)
A base class for sparse solvers.
A sparse LU factorization and solver based on UmfPack.
void analyzePattern_impl()
UmfPackLU(const UmfPackLU &)
const LUMatrixType & matrixL() const
Array< double, UMFPACK_CONTROL, 1 > UmfpackControl
UmfpackMatrixRef mp_matrix
Matrix< int, MatrixType::RowsAtCompileTime, 1 > IntColVectorType
void printUmfpackControl()
const IntColVectorType & permutationP() const
MatrixType::RealScalar RealScalar
bool m_extractedDataAreDirty
void compute(const InputMatrixType &matrix)
UmfPackLU(const InputMatrixType &matrix)
UmfpackMatrixType m_dummy
UmfpackInfo m_umfpackInfo
SparseMatrix< Scalar, ColMajor, StorageIndex > UmfpackMatrixType
Scalar determinant() const
const IntRowVectorType & permutationQ() const
void factorize(const InputMatrixType &matrix)
UmfpackControl & umfpackControl()
MatrixType::Scalar Scalar
void grab(const UmfpackMatrixRef &A)
SparseSolverBase< UmfPackLU< MatrixType_ > > Base
StorageIndex m_fact_errorCode
SparseMatrix< Scalar > LUMatrixType
int umfpackFactorizeReturncode() const
bool _solve_impl(const MatrixBase< BDerived > &b, MatrixBase< XDerived > &x) const
Matrix< int, 1, MatrixType::ColsAtCompileTime > IntRowVectorType
ComputationInfo info() const
Reports whether previous computation was successful.
Array< double, UMFPACK_INFO, 1 > UmfpackInfo
void grab(const EigenBase< MatrixDerived > &A)
const LUMatrixType & matrixU() const
Ref< const UmfpackMatrixType, StandardCompressedFormat > UmfpackMatrixRef
void analyzePattern(const InputMatrixType &matrix)
const UmfpackControl & umfpackControl() const
Matrix< Scalar, Dynamic, 1 > Vector
MatrixType::StorageIndex StorageIndex
void printUmfpackStatus()
const unsigned int RowMajorBit
bfloat16() min(const bfloat16 &a, const bfloat16 &b)
T * construct_at(T *p, Args &&... args)
internal::add_const_on_value_type_t< EIGEN_MATHFUNC_RETVAL(real_ref, Scalar) > real_ref(const Scalar &x)
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)
int umfpack_get_determinant(double *Mx, double *Ex, void *NumericHandle, double User_Info[UMFPACK_INFO], int)
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])
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
void umfpack_report_control(double control[UMFPACK_CONTROL], double, int)
void umfpack_free_numeric(void **Numeric, double, int)
void umfpack_defaults(double control[UMFPACK_CONTROL], double, int)
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])
void umfpack_report_status(double control[UMFPACK_CONTROL], int status, double, int)
void umfpack_report_info(double control[UMFPACK_CONTROL], double info[UMFPACK_INFO], double, int)
void umfpack_free_symbolic(void **Symbolic, double, int)
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])
int umfpack_get_lunz(int *lnz, int *unz, int *n_row, int *n_col, int *nz_udiag, void *Numeric, double)