11#ifndef EIGEN_INCOMPLETE_LU_H
12#define EIGEN_INCOMPLETE_LU_H
15#include "./InternalHeaderCheck.h"
19template <
typename Scalar_>
23 using Base::m_isInitialized;
25 using Scalar = Scalar_;
26 using Vector = Matrix<Scalar, Dynamic, 1>;
27 using Index =
typename Vector::Index;
28 using FactorType = SparseMatrix<Scalar, RowMajor>;
31 using MatrixType = Matrix<Scalar, Dynamic, Dynamic>;
33 static constexpr int ColsAtCompileTime = Dynamic;
34 static constexpr int MaxColsAtCompileTime = Dynamic;
38 template <
typename MatrixType>
39 IncompleteLU(
const MatrixType& mat) {
43 Index rows()
const {
return m_lu.rows(); }
44 Index cols()
const {
return m_lu.cols(); }
46 template <
typename MatrixType>
47 IncompleteLU& analyzePattern(
const MatrixType&) {
51 template <
typename MatrixType>
52 IncompleteLU& factorize(
const MatrixType& mat) {
56 template <
typename MatrixType>
57 IncompleteLU& compute(
const MatrixType& mat) {
59 Index size = mat.cols();
61 for (Index i = 0; i < size; ++i) {
62 typename FactorType::InnerIterator k_it(m_lu, i);
63 for (; k_it && k_it.index() < i; ++k_it) {
64 Index k = k_it.index();
65 k_it.valueRef() /= diag(k);
67 typename FactorType::InnerIterator j_it(k_it);
68 typename FactorType::InnerIterator kj_it(m_lu, k);
69 while (kj_it && kj_it.index() <= k) ++kj_it;
70 for (++j_it; j_it && kj_it;) {
71 if (kj_it.index() == j_it.index()) {
72 j_it.valueRef() -= k_it.value() * kj_it.value();
75 }
else if (kj_it.index() < j_it.index())
81 if (k_it && k_it.index() == i)
82 diag(i) = k_it.value();
86 m_isInitialized =
true;
92 template <
typename Rhs,
typename Dest>
93 void _solve_impl(
const Rhs& b, Dest& x)
const {
94 x = m_lu.template triangularView<UnitLower>().solve(b);
95 x = m_lu.template triangularView<Upper>().solve(x);
typename internal::traits< Derived >::StorageIndex StorageIndex
Definition SparseMatrixBase.h:45
A base class for sparse solvers.
Definition SparseSolverBase.h:68
SparseSolverBase()=default
ComputationInfo
Definition Constants.h:455
@ Success
Definition Constants.h:457