10#ifndef EIGEN_INCOMPLETE_LU_H
11#define EIGEN_INCOMPLETE_LU_H
14#include "./InternalHeaderCheck.h"
18template <
typename Scalar_>
22 using Base::m_isInitialized;
24 typedef Scalar_ Scalar;
25 typedef Matrix<Scalar, Dynamic, 1> Vector;
26 typedef typename Vector::Index Index;
27 typedef SparseMatrix<Scalar, RowMajor> FactorType;
30 typedef Matrix<Scalar, Dynamic, Dynamic> MatrixType;
34 template <
typename MatrixType>
35 IncompleteLU(
const MatrixType& mat) {
39 Index rows()
const {
return m_lu.rows(); }
40 Index cols()
const {
return m_lu.cols(); }
42 template <
typename MatrixType>
43 IncompleteLU& compute(
const MatrixType& mat) {
45 int size = mat.cols();
47 for (
int i = 0; i < size; ++i) {
48 typename FactorType::InnerIterator k_it(m_lu, i);
49 for (; k_it && k_it.index() < i; ++k_it) {
51 k_it.valueRef() /= diag(k);
53 typename FactorType::InnerIterator j_it(k_it);
54 typename FactorType::InnerIterator kj_it(m_lu, k);
55 while (kj_it && kj_it.index() <= k) ++kj_it;
57 if (kj_it.index() == j_it.index()) {
58 j_it.valueRef() -= k_it.value() * kj_it.value();
61 }
else if (kj_it.index() < j_it.index())
67 if (k_it && k_it.index() == i)
68 diag(i) = k_it.value();
72 m_isInitialized =
true;
76 template <
typename Rhs,
typename Dest>
77 void _solve_impl(
const Rhs& b, Dest& x)
const {
78 x = m_lu.template triangularView<UnitLower>().solve(b);
79 x = m_lu.template triangularView<Upper>().solve(x);
Namespace containing all symbols from the Eigen library.