IncompleteLU.h
Go to the documentation of this file.
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2011 Gael Guennebaud <gael.guennebaud@inria.fr>
5 //
6 // This Source Code Form is subject to the terms of the Mozilla
7 // Public License v. 2.0. If a copy of the MPL was not distributed
8 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 
10 #ifndef EIGEN_INCOMPLETE_LU_H
11 #define EIGEN_INCOMPLETE_LU_H
12 
13 namespace Eigen {
14 
15 template <typename _Scalar>
16 class IncompleteLU : public SparseSolverBase<IncompleteLU<_Scalar> >
17 {
18  protected:
21 
22  typedef _Scalar Scalar;
24  typedef typename Vector::Index Index;
26 
27  public:
29 
31 
32  template<typename MatrixType>
34  {
35  compute(mat);
36  }
37 
38  Index rows() const { return m_lu.rows(); }
39  Index cols() const { return m_lu.cols(); }
40 
41  template<typename MatrixType>
43  {
44  m_lu = mat;
45  int size = mat.cols();
46  Vector diag(size);
47  for(int i=0; i<size; ++i)
48  {
49  typename FactorType::InnerIterator k_it(m_lu,i);
50  for(; k_it && k_it.index()<i; ++k_it)
51  {
52  int k = k_it.index();
53  k_it.valueRef() /= diag(k);
54 
55  typename FactorType::InnerIterator j_it(k_it);
56  typename FactorType::InnerIterator kj_it(m_lu, k);
57  while(kj_it && kj_it.index()<=k) ++kj_it;
58  for(++j_it; j_it; )
59  {
60  if(kj_it.index()==j_it.index())
61  {
62  j_it.valueRef() -= k_it.value() * kj_it.value();
63  ++j_it;
64  ++kj_it;
65  }
66  else if(kj_it.index()<j_it.index()) ++kj_it;
67  else ++j_it;
68  }
69  }
70  if(k_it && k_it.index()==i) diag(i) = k_it.value();
71  else diag(i) = 1;
72  }
73  m_isInitialized = true;
74  return *this;
75  }
76 
77  template<typename Rhs, typename Dest>
78  void _solve_impl(const Rhs& b, Dest& x) const
79  {
80  x = m_lu.template triangularView<UnitLower>().solve(b);
81  x = m_lu.template triangularView<Upper>().solve(x);
82  }
83 
84  protected:
86 };
87 
88 } // end namespace Eigen
89 
90 #endif // EIGEN_INCOMPLETE_LU_H
Eigen::SparseMatrix::cols
Index cols() const
Definition: SparseMatrix.h:140
Eigen::IncompleteLU
Definition: IncompleteLU.h:16
Eigen::IncompleteLU::Scalar
_Scalar Scalar
Definition: IncompleteLU.h:22
Eigen
Namespace containing all symbols from the Eigen library.
Definition: jet.h:637
Eigen::SparseMatrix< Scalar, RowMajor >
Eigen::IncompleteLU::MatrixType
Matrix< Scalar, Dynamic, Dynamic > MatrixType
Definition: IncompleteLU.h:28
Eigen::IncompleteLU::m_lu
FactorType m_lu
Definition: IncompleteLU.h:85
Eigen::IncompleteLU::FactorType
SparseMatrix< Scalar, RowMajor > FactorType
Definition: IncompleteLU.h:25
b
Scalar * b
Definition: benchVecAdd.cpp:17
gtsam::diag
Matrix diag(const std::vector< Matrix > &Hs)
Definition: Matrix.cpp:206
x
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
Definition: gnuplot_common_settings.hh:12
Eigen::IncompleteLU::IncompleteLU
IncompleteLU()
Definition: IncompleteLU.h:30
Eigen::IncompleteLU::IncompleteLU
IncompleteLU(const MatrixType &mat)
Definition: IncompleteLU.h:33
mat
MatrixXf mat
Definition: Tutorial_AdvancedInitialization_CommaTemporary.cpp:1
Eigen::IncompleteLU::Index
Vector::Index Index
Definition: IncompleteLU.h:24
size
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
Eigen::IncompleteLU::rows
Index rows() const
Definition: IncompleteLU.h:38
Eigen::SparseSolverBase
A base class for sparse solvers.
Definition: SparseSolverBase.h:67
Eigen::SparseMatrix< Scalar, RowMajor >::InnerIterator
Base::InnerIterator InnerIterator
Definition: SparseMatrix.h:114
Eigen::IncompleteLU::Vector
Matrix< Scalar, Dynamic, 1 > Vector
Definition: IncompleteLU.h:23
Eigen::internal::Rhs
@ Rhs
Definition: TensorContractionMapper.h:18
Eigen::IncompleteLU::_solve_impl
void _solve_impl(const Rhs &b, Dest &x) const
Definition: IncompleteLU.h:78
Eigen::Matrix< Scalar, Dynamic, 1 >
Eigen::IncompleteLU::Base
SparseSolverBase< IncompleteLU< _Scalar > > Base
Definition: IncompleteLU.h:19
Eigen::IncompleteLU::cols
Index cols() const
Definition: IncompleteLU.h:39
Eigen::IncompleteLU::compute
IncompleteLU & compute(const MatrixType &mat)
Definition: IncompleteLU.h:42
Eigen::SparseMatrix::rows
Index rows() const
Definition: SparseMatrix.h:138
i
int i
Definition: BiCGSTAB_step_by_step.cpp:9
Eigen::Index
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74
Eigen::SparseSolverBase< IncompleteLU< _Scalar > >::m_isInitialized
bool m_isInitialized
Definition: SparseSolverBase.h:119


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:02:27