Eigen::LeastSquareDiagonalPreconditioner< Scalar_ > Class Template Reference

Jacobi preconditioner for LeastSquaresConjugateGradient. More...

+ Inheritance diagram for Eigen::LeastSquareDiagonalPreconditioner< Scalar_ >:

Public Member Functions

template<typename MatType >
LeastSquareDiagonalPreconditioneranalyzePattern (const MatType &)
 
template<typename MatType >
LeastSquareDiagonalPreconditionercompute (const MatType &mat)
 
template<typename MatType >
LeastSquareDiagonalPreconditionerfactorize (const MatType &mat)
 
ComputationInfo info ()
 
 LeastSquareDiagonalPreconditioner ()
 
template<typename MatType >
 LeastSquareDiagonalPreconditioner (const MatType &mat)
 
- Public Member Functions inherited from Eigen::DiagonalPreconditioner< Scalar_ >
template<typename Rhs , typename Dest >
void _solve_impl (const Rhs &b, Dest &x) const
 
template<typename MatType >
DiagonalPreconditioneranalyzePattern (const MatType &)
 
EIGEN_CONSTEXPR Index cols () const EIGEN_NOEXCEPT
 
template<typename MatType >
DiagonalPreconditionercompute (const MatType &mat)
 
 DiagonalPreconditioner ()
 
template<typename MatType >
 DiagonalPreconditioner (const MatType &mat)
 
template<typename MatType >
DiagonalPreconditionerfactorize (const MatType &mat)
 
ComputationInfo info ()
 
EIGEN_CONSTEXPR Index rows () const EIGEN_NOEXCEPT
 
template<typename Rhs >
const Solve< DiagonalPreconditioner, Rhs > solve (const MatrixBase< Rhs > &b) const
 

Private Types

typedef DiagonalPreconditioner< Scalar_ > Base
 
typedef NumTraits< Scalar >::Real RealScalar
 
typedef Scalar_ Scalar
 

Private Attributes

Vector m_invdiag
 

Additional Inherited Members

- Public Types inherited from Eigen::DiagonalPreconditioner< Scalar_ >
enum  {
  ColsAtCompileTime ,
  MaxColsAtCompileTime
}
 
typedef Vector::StorageIndex StorageIndex
 
- Protected Attributes inherited from Eigen::DiagonalPreconditioner< Scalar_ >
Vector m_invdiag
 
bool m_isInitialized
 

Detailed Description

template<typename Scalar_>
class Eigen::LeastSquareDiagonalPreconditioner< Scalar_ >

Jacobi preconditioner for LeastSquaresConjugateGradient.

This class allows to approximately solve for A' A x = A' b problems assuming A' A is a diagonal matrix. In other words, this preconditioner neglects all off diagonal entries and, in Eigen's language, solves for:

(A.adjoint() * A).diagonal().asDiagonal() * x = b
Array< int, 3, 1 > b
MatrixXcf A
Template Parameters
Scalar_the type of the scalar.

This class follows the sparse solver concept .

The diagonal entries are pre-inverted and stored into a dense vector.

See also
class LeastSquaresConjugateGradient, class DiagonalPreconditioner

Definition at line 130 of file BasicPreconditioners.h.

Member Typedef Documentation

◆ Base

template<typename Scalar_ >
typedef DiagonalPreconditioner<Scalar_> Eigen::LeastSquareDiagonalPreconditioner< Scalar_ >::Base
private

Definition at line 134 of file BasicPreconditioners.h.

◆ RealScalar

template<typename Scalar_ >
typedef NumTraits<Scalar>::Real Eigen::LeastSquareDiagonalPreconditioner< Scalar_ >::RealScalar
private

Definition at line 133 of file BasicPreconditioners.h.

◆ Scalar

template<typename Scalar_ >
typedef Scalar_ Eigen::LeastSquareDiagonalPreconditioner< Scalar_ >::Scalar
private

Definition at line 132 of file BasicPreconditioners.h.

Constructor & Destructor Documentation

◆ LeastSquareDiagonalPreconditioner() [1/2]

template<typename Scalar_ >
Eigen::LeastSquareDiagonalPreconditioner< Scalar_ >::LeastSquareDiagonalPreconditioner ( )
inline

Definition at line 138 of file BasicPreconditioners.h.

138 : Base() {}
DiagonalPreconditioner< Scalar_ > Base

◆ LeastSquareDiagonalPreconditioner() [2/2]

template<typename Scalar_ >
template<typename MatType >
Eigen::LeastSquareDiagonalPreconditioner< Scalar_ >::LeastSquareDiagonalPreconditioner ( const MatType &  mat)
inlineexplicit

Definition at line 141 of file BasicPreconditioners.h.

141  : Base()
142  {
143  compute(mat);
144  }
LeastSquareDiagonalPreconditioner & compute(const MatType &mat)

Member Function Documentation

◆ analyzePattern()

template<typename Scalar_ >
template<typename MatType >
LeastSquareDiagonalPreconditioner& Eigen::LeastSquareDiagonalPreconditioner< Scalar_ >::analyzePattern ( const MatType &  )
inline

Definition at line 147 of file BasicPreconditioners.h.

148  {
149  return *this;
150  }

◆ compute()

template<typename Scalar_ >
template<typename MatType >
LeastSquareDiagonalPreconditioner& Eigen::LeastSquareDiagonalPreconditioner< Scalar_ >::compute ( const MatType &  mat)
inline

Definition at line 185 of file BasicPreconditioners.h.

186  {
187  return factorize(mat);
188  }
LeastSquareDiagonalPreconditioner & factorize(const MatType &mat)

◆ factorize()

template<typename Scalar_ >
template<typename MatType >
LeastSquareDiagonalPreconditioner& Eigen::LeastSquareDiagonalPreconditioner< Scalar_ >::factorize ( const MatType &  mat)
inline

Definition at line 153 of file BasicPreconditioners.h.

154  {
155  // Compute the inverse squared-norm of each column of mat
156  m_invdiag.resize(mat.cols());
157  if(MatType::IsRowMajor)
158  {
159  m_invdiag.setZero();
160  for(Index j=0; j<mat.outerSize(); ++j)
161  {
162  for(typename MatType::InnerIterator it(mat,j); it; ++it)
163  m_invdiag(it.index()) += numext::abs2(it.value());
164  }
165  for(Index j=0; j<mat.cols(); ++j)
168  }
169  else
170  {
171  for(Index j=0; j<mat.outerSize(); ++j)
172  {
173  RealScalar sum = mat.col(j).squaredNorm();
174  if(sum>RealScalar(0))
175  m_invdiag(j) = RealScalar(1)/sum;
176  else
177  m_invdiag(j) = RealScalar(1);
178  }
179  }
180  Base::m_isInitialized = true;
181  return *this;
182  }
RealReturnType real() const
Derived & setZero(Index size)
constexpr void resize(Index rows, Index cols)
bool abs2(bool x)
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:82
std::ptrdiff_t j

◆ info()

template<typename Scalar_ >
ComputationInfo Eigen::LeastSquareDiagonalPreconditioner< Scalar_ >::info ( )
inline

Definition at line 190 of file BasicPreconditioners.h.

190 { return Success; }
@ Success
Definition: Constants.h:446

Member Data Documentation

◆ m_invdiag

template<typename Scalar_ >
Vector Eigen::DiagonalPreconditioner< Scalar_ >::m_invdiag
private

Definition at line 108 of file BasicPreconditioners.h.


The documentation for this class was generated from the following file: