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>;
35 template <
typename MatrixType>
36 IncompleteLU(
const MatrixType& mat) {
40 Index rows()
const {
return m_lu.rows(); }
41 Index cols()
const {
return m_lu.cols(); }
43 template <
typename MatrixType>
44 IncompleteLU& compute(
const MatrixType& mat) {
46 Index size = mat.cols();
48 for (Index i = 0; i < size; ++i) {
49 typename FactorType::InnerIterator k_it(m_lu, i);
50 for (; k_it && k_it.index() < i; ++k_it) {
51 Index k = k_it.index();
52 k_it.valueRef() /= diag(k);
54 typename FactorType::InnerIterator j_it(k_it);
55 typename FactorType::InnerIterator kj_it(m_lu, k);
56 while (kj_it && kj_it.index() <= k) ++kj_it;
58 if (kj_it.index() == j_it.index()) {
59 j_it.valueRef() -= k_it.value() * kj_it.value();
62 }
else if (kj_it.index() < j_it.index())
68 if (k_it && k_it.index() == i)
69 diag(i) = k_it.value();
73 m_isInitialized =
true;
77 template <
typename Rhs,
typename Dest>
78 void _solve_impl(
const Rhs& b, Dest& x)
const {
79 x = m_lu.template triangularView<UnitLower>().solve(b);
80 x = m_lu.template triangularView<Upper>().solve(x);
A base class for sparse solvers.
Definition SparseSolverBase.h:68
SparseSolverBase()=default