10#ifndef EIGEN_BASIC_PRECONDITIONERS_H
11#define EIGEN_BASIC_PRECONDITIONERS_H
35template <
typename _Scalar>
38 typedef _Scalar Scalar;
41 typedef typename Vector::StorageIndex StorageIndex;
43 ColsAtCompileTime = Dynamic,
44 MaxColsAtCompileTime = Dynamic
49 template<
typename MatType>
55 Index rows()
const {
return m_invdiag.size(); }
56 Index cols()
const {
return m_invdiag.size(); }
58 template<
typename MatType>
64 template<
typename MatType>
68 for(
int j=0;
j<
mat.outerSize(); ++
j)
70 typename MatType::InnerIterator it(
mat,
j);
71 while(it && it.index()!=
j) ++it;
72 if(it && it.index()==
j && it.value()!=Scalar(0))
73 m_invdiag(
j) = Scalar(1)/it.value();
75 m_invdiag(
j) = Scalar(1);
77 m_isInitialized =
true;
81 template<
typename MatType>
84 return factorize(
mat);
88 template<
typename Rhs,
typename Dest>
89 void _solve_impl(
const Rhs& b,
Dest& x)
const
91 x = m_invdiag.array() * b.array() ;
97 eigen_assert(m_isInitialized &&
"DiagonalPreconditioner is not initialized.");
98 eigen_assert(m_invdiag.size()==b.rows()
99 &&
"DiagonalPreconditioner::solve(): invalid number of rows of the right hand side matrix b");
107 bool m_isInitialized;
127template <
typename _Scalar>
130 typedef _Scalar Scalar;
131 typedef typename NumTraits<Scalar>::Real
RealScalar;
133 using Base::m_invdiag;
138 template<
typename MatType>
144 template<
typename MatType>
150 template<
typename MatType>
155 for(Index
j=0;
j<
mat.outerSize(); ++
j)
163 Base::m_isInitialized =
true;
167 template<
typename MatType>
170 return factorize(
mat);
191 template<
typename MatrixType>
194 template<
typename MatrixType>
197 template<
typename MatrixType>
200 template<
typename MatrixType>
203 template<
typename Rhs>
204 inline const Rhs& solve(
const Rhs& b)
const {
return b; }
A preconditioner based on the digonal entries.
Definition BasicPreconditioners.h:37
A naive preconditioner which approximates any matrix as the identity matrix.
Definition BasicPreconditioners.h:186
Jacobi preconditioner for LeastSquaresConjugateGradient.
Definition BasicPreconditioners.h:129
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void resize(Index rows, Index cols)
Resizes *this to a rows x cols matrix.
Definition PlainObjectBase.h:252
Pseudo expression representing a solving operation.
Definition Solve.h:63
ComputationInfo
Enum for reporting the status of a computation.
Definition Constants.h:430
@ Success
Computation was successful.
Definition Constants.h:432