10 #ifndef EIGEN_KLUSUPPORT_H
11 #define EIGEN_KLUSUPPORT_H
34 inline int klu_solve(klu_symbolic *Symbolic, klu_numeric *Numeric,
Index ldim,
Index nrhs,
double B [ ], klu_common *Common,
double) {
35 return klu_solve(Symbolic, Numeric, internal::convert_index<int>(ldim), internal::convert_index<int>(nrhs), B, Common);
38 inline int klu_solve(klu_symbolic *Symbolic, klu_numeric *Numeric,
Index ldim,
Index nrhs, std::complex<double>B[], klu_common *Common, std::complex<double>) {
39 return klu_z_solve(Symbolic, Numeric, internal::convert_index<int>(ldim), internal::convert_index<int>(nrhs), &
numext::real_ref(B[0]), Common);
42 inline int klu_tsolve(klu_symbolic *Symbolic, klu_numeric *Numeric,
Index ldim,
Index nrhs,
double B[], klu_common *Common,
double) {
43 return klu_tsolve(Symbolic, Numeric, internal::convert_index<int>(ldim), internal::convert_index<int>(nrhs), B, Common);
46 inline int klu_tsolve(klu_symbolic *Symbolic, klu_numeric *Numeric,
Index ldim,
Index nrhs, std::complex<double>B[], klu_common *Common, std::complex<double>) {
47 return klu_z_tsolve(Symbolic, Numeric, internal::convert_index<int>(ldim), internal::convert_index<int>(nrhs), &
numext::real_ref(B[0]), 0, Common);
50 inline klu_numeric*
klu_factor(
int Ap [ ],
int Ai [ ],
double Ax [ ], klu_symbolic *Symbolic, klu_common *Common,
double) {
51 return klu_factor(Ap, Ai, Ax, Symbolic, Common);
54 inline klu_numeric*
klu_factor(
int Ap[],
int Ai[], std::complex<double> Ax[], klu_symbolic *Symbolic, klu_common *Common, std::complex<double>) {
59 template<
typename _MatrixType>
68 typedef typename MatrixType::Scalar
Scalar;
90 template<
typename InputMatrixType>
91 explicit KLU(
const InputMatrixType& matrix)
146 template<
typename InputMatrixType>
151 grab(matrix.derived());
162 template<
typename InputMatrixType>
168 grab(matrix.derived());
200 template<
typename InputMatrixType>
207 grab(matrix.derived());
213 template<
typename BDerived,
typename XDerived>
217 Scalar determinant()
const;
219 void extractData()
const;
263 template<
typename MatrixDerived>
303 template<
typename MatrixType>
304 void KLU<MatrixType>::extractData()
const
306 if (m_extractedDataAreDirty)
308 eigen_assert(
false &&
"KLU: extractData Not Yet Implemented");
311 int lnz, unz, rows, cols, nz_udiag;
315 m_l.resize(rows,(
std::min)(rows,cols));
316 m_l.resizeNonZeros(lnz);
318 m_u.resize((
std::min)(rows,cols),cols);
319 m_u.resizeNonZeros(unz);
326 m_u.outerIndexPtr(), m_u.innerIndexPtr(), m_u.valuePtr(),
327 m_p.data(), m_q.data(), 0, 0, 0, m_numeric);
329 m_extractedDataAreDirty =
false;
333 template<
typename MatrixType>
336 eigen_assert(
false &&
"KLU: extractData Not Yet Implemented");
341 template<
typename MatrixType>
342 template<
typename BDerived,
typename XDerived>
345 Index rhsCols = b.cols();
347 eigen_assert(m_factorizationIsOk &&
"The decomposition is not in a valid state for solving, you must first call either compute() or analyzePattern()/factorize()");
350 int info =
klu_solve(m_symbolic, m_numeric, b.rows(), rhsCols, x.const_cast_derived().data(),
const_cast<klu_common*
>(&m_common),
Scalar());
#define EIGEN_NOEXCEPT
Definition: Macros.h:1418
#define EIGEN_CONSTEXPR
Definition: Macros.h:787
#define eigen_assert(x)
Definition: Macros.h:1037
#define EIGEN_STATIC_ASSERT(CONDITION, MSG)
Definition: StaticAssert.h:127
Definition: KLUSupport.h:61
klu_common & kluCommon()
Definition: KLUSupport.h:189
Ref< const KLUMatrixType, StandardCompressedFormat > KLUMatrixRef
Definition: KLUSupport.h:76
KLUMatrixRef mp_matrix
Definition: KLUSupport.h:288
~KLU()
Definition: KLUSupport.h:98
void factorize_impl()
Definition: KLUSupport.h:251
void compute(const InputMatrixType &matrix)
Definition: KLUSupport.h:147
SparseMatrix< Scalar, ColMajor, int > KLUMatrixType
Definition: KLUSupport.h:75
void analyzePattern_impl()
Definition: KLUSupport.h:235
void grab(const KLUMatrixRef &A)
Definition: KLUSupport.h:270
@ MaxColsAtCompileTime
Definition: KLUSupport.h:79
@ ColsAtCompileTime
Definition: KLUSupport.h:78
_MatrixType MatrixType
Definition: KLUSupport.h:67
klu_numeric * m_numeric
Definition: KLUSupport.h:290
const klu_common & kluCommon() const
Definition: KLUSupport.h:178
EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Definition: KLUSupport.h:104
MatrixType::RealScalar RealScalar
Definition: KLUSupport.h:69
void grab(const EigenBase< MatrixDerived > &A)
Definition: KLUSupport.h:264
int m_factorizationIsOk
Definition: KLUSupport.h:294
void factorize(const InputMatrixType &matrix)
Definition: KLUSupport.h:201
ComputationInfo m_info
Definition: KLUSupport.h:293
SparseSolverBase< KLU< _MatrixType > > Base
Definition: KLUSupport.h:63
bool m_extractedDataAreDirty
Definition: KLUSupport.h:296
MatrixType::StorageIndex StorageIndex
Definition: KLUSupport.h:70
KLU()
Definition: KLUSupport.h:84
klu_common m_common
Definition: KLUSupport.h:292
EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Definition: KLUSupport.h:105
void analyzePattern(const InputMatrixType &matrix)
Definition: KLUSupport.h:163
Matrix< int, 1, MatrixType::ColsAtCompileTime > IntRowVectorType
Definition: KLUSupport.h:72
klu_symbolic * m_symbolic
Definition: KLUSupport.h:291
Matrix< int, MatrixType::RowsAtCompileTime, 1 > IntColVectorType
Definition: KLUSupport.h:73
SparseMatrix< Scalar > LUMatrixType
Definition: KLUSupport.h:74
KLU(const KLU &)
Definition: KLUSupport.h:299
bool _solve_impl(const MatrixBase< BDerived > &b, MatrixBase< XDerived > &x) const
Definition: KLUSupport.h:343
KLU(const InputMatrixType &matrix)
Definition: KLUSupport.h:91
MatrixType::Scalar Scalar
Definition: KLUSupport.h:68
KLUMatrixType m_dummy
Definition: KLUSupport.h:287
int m_analysisIsOk
Definition: KLUSupport.h:295
void init()
Definition: KLUSupport.h:224
Matrix< Scalar, Dynamic, 1 > Vector
Definition: KLUSupport.h:71
ComputationInfo info() const
Reports whether previous computation was successful.
Definition: KLUSupport.h:112
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:50
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
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
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74
klu_numeric * klu_factor(int Ap[], int Ai[], double Ax[], klu_symbolic *Symbolic, klu_common *Common, double)
Definition: KLUSupport.h:50
int klu_solve(klu_symbolic *Symbolic, klu_numeric *Numeric, Index ldim, Index nrhs, double B[], klu_common *Common, double)
A sparse LU factorization and solver based on KLU.
Definition: KLUSupport.h:34
int klu_tsolve(klu_symbolic *Symbolic, klu_numeric *Numeric, Index ldim, Index nrhs, double B[], klu_common *Common, double)
Definition: KLUSupport.h:42
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
#define const
Definition: zconf.h:233