Blender  V3.3
Public Types | Public Member Functions | Protected Attributes | List of all members
Eigen::ConstrainedConjugateGradient< _MatrixType, _UpLo, _FilterMatrixType, _Preconditioner > Class Template Reference

A conjugate gradient solver for sparse self-adjoint problems with additional constraints. More...

#include <ConstrainedConjugateGradient.h>

Inheritance diagram for Eigen::ConstrainedConjugateGradient< _MatrixType, _UpLo, _FilterMatrixType, _Preconditioner >:

Public Types

enum  { UpLo = _UpLo }
 
typedef _MatrixType MatrixType
 
typedef MatrixType::Scalar Scalar
 
typedef MatrixType::Index Index
 
typedef MatrixType::RealScalar RealScalar
 
typedef _FilterMatrixType FilterMatrixType
 
typedef _Preconditioner Preconditioner
 

Public Member Functions

 ConstrainedConjugateGradient ()
 
 ConstrainedConjugateGradient (const MatrixType &A)
 
 ~ConstrainedConjugateGradient ()
 
FilterMatrixTypefilter ()
 
const FilterMatrixTypefilter () const
 
template<typename Rhs , typename Guess >
const internal::solve_retval_with_guess< ConstrainedConjugateGradient, Rhs, Guess > solveWithGuess (const MatrixBase< Rhs > &b, const Guess &x0) const
 
template<typename Rhs , typename Dest >
void _solveWithGuess (const Rhs &b, Dest &x) const
 
template<typename Rhs , typename Dest >
void _solve (const Rhs &b, Dest &x) const
 

Protected Attributes

FilterMatrixType m_filter
 

Detailed Description

template<typename _MatrixType, int _UpLo, typename _FilterMatrixType, typename _Preconditioner>
class Eigen::ConstrainedConjugateGradient< _MatrixType, _UpLo, _FilterMatrixType, _Preconditioner >

A conjugate gradient solver for sparse self-adjoint problems with additional constraints.

This class allows to solve for A.x = b sparse linear problems using a conjugate gradient algorithm. The sparse matrix A must be self-adjoint. The vectors x and b can be either dense or sparse.

Template Parameters
_MatrixTypethe type of the sparse matrix A, can be a dense or a sparse matrix.
_UpLothe triangular part that will be used for the computations. It can be Lower or Upper. Default is Lower.
_Preconditionerthe type of the pre-conditioner. Default is #DiagonalPreconditioner

The maximal number of iterations and tolerance value can be controlled via the setMaxIterations() and setTolerance() methods. The defaults are the size of the problem for the maximal number of iterations and NumTraits<Scalar>::epsilon() for the tolerance.

This class can be used as the direct solver classes. Here is a typical usage example:

int n = 10000;
VectorXd x(n), b(n);
SparseMatrix<double> A(n,n);
// fill A and b
cg.compute(A);
x = cg.solve(b);
std::cout << "#iterations: " << cg.iterations() << std::endl;
std::cout << "estimated error: " << cg.error() << std::endl;
// update b, and solve again
x = cg.solve(b);
#define A
Eigen::ConjugateGradient< lMatrix, Eigen::Lower, Eigen::DiagonalPreconditioner< Scalar > > ConjugateGradient
Definition: eigen_utils.h:186
static const pxr::TfToken b("b", pxr::TfToken::Immortal)

By default the iterations start with x=0 as an initial guess of the solution. One can control the start using the solveWithGuess() method. Here is a step by step execution example starting with a random guess and printing the evolution of the estimated error:

See also
class SimplicialCholesky, DiagonalPreconditioner, IdentityPreconditioner

Definition at line 197 of file ConstrainedConjugateGradient.h.

Member Typedef Documentation

◆ FilterMatrixType

template<typename _MatrixType , int _UpLo, typename _FilterMatrixType , typename _Preconditioner >
typedef _FilterMatrixType Eigen::ConstrainedConjugateGradient< _MatrixType, _UpLo, _FilterMatrixType, _Preconditioner >::FilterMatrixType

Definition at line 212 of file ConstrainedConjugateGradient.h.

◆ Index

template<typename _MatrixType , int _UpLo, typename _FilterMatrixType , typename _Preconditioner >
typedef MatrixType::Index Eigen::ConstrainedConjugateGradient< _MatrixType, _UpLo, _FilterMatrixType, _Preconditioner >::Index

Definition at line 210 of file ConstrainedConjugateGradient.h.

◆ MatrixType

template<typename _MatrixType , int _UpLo, typename _FilterMatrixType , typename _Preconditioner >
typedef _MatrixType Eigen::ConstrainedConjugateGradient< _MatrixType, _UpLo, _FilterMatrixType, _Preconditioner >::MatrixType

Definition at line 208 of file ConstrainedConjugateGradient.h.

◆ Preconditioner

template<typename _MatrixType , int _UpLo, typename _FilterMatrixType , typename _Preconditioner >
typedef _Preconditioner Eigen::ConstrainedConjugateGradient< _MatrixType, _UpLo, _FilterMatrixType, _Preconditioner >::Preconditioner

Definition at line 213 of file ConstrainedConjugateGradient.h.

◆ RealScalar

template<typename _MatrixType , int _UpLo, typename _FilterMatrixType , typename _Preconditioner >
typedef MatrixType::RealScalar Eigen::ConstrainedConjugateGradient< _MatrixType, _UpLo, _FilterMatrixType, _Preconditioner >::RealScalar

Definition at line 211 of file ConstrainedConjugateGradient.h.

◆ Scalar

template<typename _MatrixType , int _UpLo, typename _FilterMatrixType , typename _Preconditioner >
typedef MatrixType::Scalar Eigen::ConstrainedConjugateGradient< _MatrixType, _UpLo, _FilterMatrixType, _Preconditioner >::Scalar

Definition at line 209 of file ConstrainedConjugateGradient.h.

Member Enumeration Documentation

◆ anonymous enum

template<typename _MatrixType , int _UpLo, typename _FilterMatrixType , typename _Preconditioner >
anonymous enum
Enumerator
UpLo 

Definition at line 215 of file ConstrainedConjugateGradient.h.

Constructor & Destructor Documentation

◆ ConstrainedConjugateGradient() [1/2]

template<typename _MatrixType , int _UpLo, typename _FilterMatrixType , typename _Preconditioner >
Eigen::ConstrainedConjugateGradient< _MatrixType, _UpLo, _FilterMatrixType, _Preconditioner >::ConstrainedConjugateGradient ( )
inline

Default constructor.

Definition at line 219 of file ConstrainedConjugateGradient.h.

◆ ConstrainedConjugateGradient() [2/2]

template<typename _MatrixType , int _UpLo, typename _FilterMatrixType , typename _Preconditioner >
Eigen::ConstrainedConjugateGradient< _MatrixType, _UpLo, _FilterMatrixType, _Preconditioner >::ConstrainedConjugateGradient ( const MatrixType A)
inline

Initialize the solver with matrix A for further Ax=b solving.

This constructor is a shortcut for the default constructor followed by a call to compute().

Warning
this class stores a reference to the matrix A as well as some precomputed values that depend on it. Therefore, if A is changed this class becomes invalid. Call compute() to update it with the new matrix A, or modify a copy of A.

Definition at line 233 of file ConstrainedConjugateGradient.h.

References A.

◆ ~ConstrainedConjugateGradient()

template<typename _MatrixType , int _UpLo, typename _FilterMatrixType , typename _Preconditioner >
Eigen::ConstrainedConjugateGradient< _MatrixType, _UpLo, _FilterMatrixType, _Preconditioner >::~ConstrainedConjugateGradient ( )
inline

Definition at line 237 of file ConstrainedConjugateGradient.h.

Member Function Documentation

◆ _solve()

template<typename _MatrixType , int _UpLo, typename _FilterMatrixType , typename _Preconditioner >
template<typename Rhs , typename Dest >
void Eigen::ConstrainedConjugateGradient< _MatrixType, _UpLo, _FilterMatrixType, _Preconditioner >::_solve ( const Rhs &  b,
Dest &  x 
) const
inline

◆ _solveWithGuess()

template<typename _MatrixType , int _UpLo, typename _FilterMatrixType , typename _Preconditioner >
template<typename Rhs , typename Dest >
void Eigen::ConstrainedConjugateGradient< _MatrixType, _UpLo, _FilterMatrixType, _Preconditioner >::_solveWithGuess ( const Rhs &  b,
Dest &  x 
) const
inline

◆ filter() [1/2]

template<typename _MatrixType , int _UpLo, typename _FilterMatrixType , typename _Preconditioner >
FilterMatrixType& Eigen::ConstrainedConjugateGradient< _MatrixType, _UpLo, _FilterMatrixType, _Preconditioner >::filter ( )
inline

◆ filter() [2/2]

template<typename _MatrixType , int _UpLo, typename _FilterMatrixType , typename _Preconditioner >
const FilterMatrixType& Eigen::ConstrainedConjugateGradient< _MatrixType, _UpLo, _FilterMatrixType, _Preconditioner >::filter ( ) const
inline

◆ solveWithGuess()

template<typename _MatrixType , int _UpLo, typename _FilterMatrixType , typename _Preconditioner >
template<typename Rhs , typename Guess >
const internal::solve_retval_with_guess<ConstrainedConjugateGradient, Rhs, Guess> Eigen::ConstrainedConjugateGradient< _MatrixType, _UpLo, _FilterMatrixType, _Preconditioner >::solveWithGuess ( const MatrixBase< Rhs > &  b,
const Guess &  x0 
) const
inline
Returns
the solution x of $ A x = b $ using the current decomposition of A x0 as an initial solution.
See also
compute()

Definition at line 257 of file ConstrainedConjugateGradient.h.

References usdtokens::b().

Member Data Documentation

◆ m_filter

template<typename _MatrixType , int _UpLo, typename _FilterMatrixType , typename _Preconditioner >
FilterMatrixType Eigen::ConstrainedConjugateGradient< _MatrixType, _UpLo, _FilterMatrixType, _Preconditioner >::m_filter
protected

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