Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
Eigen::ConjugateGradient< _MatrixType, _UpLo, _Preconditioner > Class Template Reference

A conjugate gradient solver for sparse (or dense) self-adjoint problems. More...

#include <src/eigen/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h>

+ Inheritance diagram for Eigen::ConjugateGradient< _MatrixType, _UpLo, _Preconditioner >:
+ Collaboration diagram for Eigen::ConjugateGradient< _MatrixType, _UpLo, _Preconditioner >:

Public Types

enum  { UpLo = _UpLo }
 
typedef _MatrixType MatrixType
 
typedef MatrixType::Scalar Scalar
 
typedef MatrixType::RealScalar RealScalar
 
typedef _Preconditioner Preconditioner
 
enum  
 
typedef MatrixType::StorageIndex StorageIndex
 

Public Member Functions

 ConjugateGradient ()
 
template<typename MatrixDerived >
 ConjugateGradient (const EigenBase< MatrixDerived > &A)
 
 ~ConjugateGradient ()
 
template<typename Rhs , typename Dest >
void _solve_with_guess_impl (const Rhs &b, Dest &x) const
 
template<typename Rhs , typename Dest >
void _solve_impl (const MatrixBase< Rhs > &b, Dest &x) const
 
template<typename Rhs , typename DestDerived >
void _solve_impl (const Rhs &b, SparseMatrixBase< DestDerived > &aDest) const
 
ConjugateGradient< _MatrixType, _UpLo, _Preconditioner > & analyzePattern (const EigenBase< MatrixDerived > &A)
 
ConjugateGradient< _MatrixType, _UpLo, _Preconditioner > & factorize (const EigenBase< MatrixDerived > &A)
 
ConjugateGradient< _MatrixType, _UpLo, _Preconditioner > & compute (const EigenBase< MatrixDerived > &A)
 
Index rows () const
 
Index cols () const
 
RealScalar tolerance () const
 
ConjugateGradient< _MatrixType, _UpLo, _Preconditioner > & setTolerance (const RealScalar &tolerance)
 
Preconditionerpreconditioner ()
 
const Preconditionerpreconditioner () const
 
Index maxIterations () const
 
ConjugateGradient< _MatrixType, _UpLo, _Preconditioner > & setMaxIterations (Index maxIters)
 
Index iterations () const
 
RealScalar error () const
 
const SolveWithGuess< ConjugateGradient< _MatrixType, _UpLo, _Preconditioner >, Rhs, Guess > solveWithGuess (const MatrixBase< Rhs > &b, const Guess &x0) const
 
ComputationInfo info () const
 
template<typename Rhs , typename Dest >
void _solve_impl (const SparseMatrixBase< Rhs > &b, SparseMatrixBase< Dest > &dest) const
 
ConjugateGradient< _MatrixType, _UpLo, _Preconditioner > & derived ()
 
const ConjugateGradient< _MatrixType, _UpLo, _Preconditioner > & derived () const
 
template<typename Rhs >
const Solve< Derived, Rhs > solve (const MatrixBase< Rhs > &b) const
 
template<typename Rhs >
const Solve< Derived, Rhs > solve (const SparseMatrixBase< Rhs > &b) const
 

Protected Types

typedef internal::generic_matrix_wrapper< MatrixTypeMatrixWrapper
 
typedef MatrixWrapper::ActualMatrixType ActualMatrixType
 

Protected Member Functions

void init ()
 
void grab (const InputType &A)
 

Protected Attributes

MatrixWrapper m_matrixWrapper
 
Preconditioner m_preconditioner
 
Index m_maxIterations
 
RealScalar m_tolerance
 
bool m_analysisIsOk
 
bool m_factorizationIsOk
 
bool m_isInitialized
 

Private Types

typedef IterativeSolverBase< ConjugateGradientBase
 

Private Member Functions

const ActualMatrixTypematrix () const
 

Private Attributes

RealScalar m_error
 
Index m_iterations
 
ComputationInfo m_info
 

Detailed Description

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

A conjugate gradient solver for sparse (or dense) self-adjoint problems.

This class allows to solve for A.x = b linear problems using an iterative conjugate gradient algorithm. The matrix A must be selfadjoint. The matrix A and the vectors x and b can be either dense or sparse.

Template Parameters
_MatrixTypethe type of the matrix A, can be a dense or a sparse matrix.
_UpLothe triangular part that will be used for the computations. It can be Lower, Upper, or Lower|Upper in which the full matrix entries will be considered. Default is Lower, best performance is Lower|Upper.
_Preconditionerthe type of the preconditioner. Default is DiagonalPreconditioner

\implsparsesolverconcept

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.

The tolerance corresponds to the relative residual error: |Ax-b|/|b|

Performance: Even though the default value of _UpLo is Lower, significantly higher performance is achieved when using a complete matrix and Lower|Upper as the _UpLo template parameter. Moreover, in this case multi-threading can be exploited if the user code is compiled with OpenMP enabled. See TopicMultiThreading for details.

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

int n = 10000;
VectorXd x(n), b(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);
A conjugate gradient solver for sparse (or dense) self-adjoint problems.
Definition ConjugateGradient.h:159
A versatible sparse matrix representation.
Definition SparseMatrix.h:98
@ Lower
Definition Constants.h:204
@ Upper
Definition Constants.h:206

By default the iterations start with x=0 as an initial guess of the solution. One can control the start using the solveWithGuess() method.

ConjugateGradient can also be used in a matrix-free context, see the following example .

See also
class LeastSquaresConjugateGradient, class SimplicialCholesky, DiagonalPreconditioner, IdentityPreconditioner

Member Typedef Documentation

◆ ActualMatrixType

typedef MatrixWrapper::ActualMatrixType Eigen::IterativeSolverBase< ConjugateGradient< _MatrixType, _UpLo, _Preconditioner > >::ActualMatrixType
protectedinherited

◆ Base

template<typename _MatrixType , int _UpLo, typename _Preconditioner >
typedef IterativeSolverBase<ConjugateGradient> Eigen::ConjugateGradient< _MatrixType, _UpLo, _Preconditioner >::Base
private

◆ MatrixType

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

◆ MatrixWrapper

typedef internal::generic_matrix_wrapper<MatrixType> Eigen::IterativeSolverBase< ConjugateGradient< _MatrixType, _UpLo, _Preconditioner > >::MatrixWrapper
protectedinherited

◆ Preconditioner

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

◆ RealScalar

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

◆ Scalar

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

◆ StorageIndex

typedef MatrixType::StorageIndex Eigen::IterativeSolverBase< ConjugateGradient< _MatrixType, _UpLo, _Preconditioner > >::StorageIndex
inherited

Member Enumeration Documentation

◆ anonymous enum

template<typename _MatrixType , int _UpLo, typename _Preconditioner >
anonymous enum
Enumerator
UpLo 
172 {
173 UpLo = _UpLo
174 };
@ UpLo
Definition ConjugateGradient.h:173

◆ anonymous enum

anonymous enum
inherited
156 {
157 ColsAtCompileTime = MatrixType::ColsAtCompileTime,
158 MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime
159 };

Constructor & Destructor Documentation

◆ ConjugateGradient() [1/2]

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

Default constructor.

179: Base() {}
IterativeSolverBase< ConjugateGradient > Base
Definition ConjugateGradient.h:160

◆ ConjugateGradient() [2/2]

template<typename _MatrixType , int _UpLo, typename _Preconditioner >
template<typename MatrixDerived >
Eigen::ConjugateGradient< _MatrixType, _UpLo, _Preconditioner >::ConjugateGradient ( const EigenBase< MatrixDerived > &  A)
inlineexplicit

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.
192: Base(A.derived()) {}

◆ ~ConjugateGradient()

template<typename _MatrixType , int _UpLo, typename _Preconditioner >
Eigen::ConjugateGradient< _MatrixType, _UpLo, _Preconditioner >::~ConjugateGradient ( )
inline
194{}

Member Function Documentation

◆ _solve_impl() [1/3]

template<typename _MatrixType , int _UpLo, typename _Preconditioner >
template<typename Rhs , typename Dest >
void Eigen::ConjugateGradient< _MatrixType, _UpLo, _Preconditioner >::_solve_impl ( const MatrixBase< Rhs > &  b,
Dest &  x 
) const
inline
235 {
236 x.setZero();
237 _solve_with_guess_impl(b.derived(),x);
238 }
void _solve_with_guess_impl(const Rhs &b, Dest &x) const
Definition ConjugateGradient.h:198
TCoord< P > x(const P &p)
Definition geometry_traits.hpp:297

References Eigen::ConjugateGradient< _MatrixType, _UpLo, _Preconditioner >::_solve_with_guess_impl().

+ Here is the call graph for this function:

◆ _solve_impl() [2/3]

template<typename _MatrixType , int _UpLo, typename _Preconditioner >
template<typename Rhs , typename DestDerived >
void Eigen::IterativeSolverBase< Derived >::_solve_impl ( const Rhs &  b,
SparseMatrixBase< DestDerived > &  aDest 
) const
inline
335 {
336 eigen_assert(rows()==b.rows());
337
338 Index rhsCols = b.cols();
339 Index size = b.rows();
340 DestDerived& dest(aDest.derived());
341 typedef typename DestDerived::Scalar DestScalar;
344 // We do not directly fill dest because sparse expressions have to be free of aliasing issue.
345 // For non square least-square problems, b and dest might not have the same size whereas they might alias each-other.
346 typename DestDerived::PlainObject tmp(cols(),rhsCols);
347 for(Index k=0; k<rhsCols; ++k)
348 {
349 tb = b.col(k);
350 tx = derived().solve(tb);
351 tmp.col(k) = tx.sparseView(0);
352 }
353 dest.swap(tmp);
354 }
#define eigen_assert(x)
Definition Macros.h:579
ConjugateGradient< _MatrixType, _UpLo, _Preconditioner > & derived()
Definition SparseSolverBase.h:79
The matrix class, also used for vectors and row-vectors.
Definition Matrix.h:180
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:33
constexpr auto size(const C &c) -> decltype(c.size())
Definition span.hpp:183

◆ _solve_impl() [3/3]

template<typename Derived >
template<typename Rhs , typename Dest >
void Eigen::SparseSolverBase< Derived >::_solve_impl ( const SparseMatrixBase< Rhs > &  b,
SparseMatrixBase< Dest > &  dest 
) const
inlineinherited
112 {
113 internal::solve_sparse_through_dense_panels(derived(), b.derived(), dest.derived());
114 }
Derived & derived()
Definition SparseSolverBase.h:79
enable_if< Rhs::ColsAtCompileTime!=1 &&Dest::ColsAtCompileTime!=1 >::type solve_sparse_through_dense_panels(const Decomposition &dec, const Rhs &rhs, Dest &dest)
Definition SparseSolverBase.h:23

References Eigen::SparseSolverBase< Derived >::derived(), Eigen::SparseMatrixBase< Derived >::derived(), and Eigen::internal::solve_sparse_through_dense_panels().

+ Here is the call graph for this function:

◆ _solve_with_guess_impl()

template<typename _MatrixType , int _UpLo, typename _Preconditioner >
template<typename Rhs , typename Dest >
void Eigen::ConjugateGradient< _MatrixType, _UpLo, _Preconditioner >::_solve_with_guess_impl ( const Rhs &  b,
Dest &  x 
) const
inline
199 {
200 typedef typename Base::MatrixWrapper MatrixWrapper;
202 enum {
203 TransposeInput = (!MatrixWrapper::MatrixFree)
204 && (UpLo==(Lower|Upper))
205 && (!MatrixType::IsRowMajor)
206 && (!NumTraits<Scalar>::IsComplex)
207 };
208 typedef typename internal::conditional<TransposeInput,Transpose<const ActualMatrixType>, ActualMatrixType const&>::type RowMajorWrapper;
209 EIGEN_STATIC_ASSERT(EIGEN_IMPLIES(MatrixWrapper::MatrixFree,UpLo==(Lower|Upper)),MATRIX_FREE_CONJUGATE_GRADIENT_IS_COMPATIBLE_WITH_UPPER_UNION_LOWER_MODE_ONLY);
210 typedef typename internal::conditional<UpLo==(Lower|Upper),
211 RowMajorWrapper,
212 typename MatrixWrapper::template ConstSelfAdjointViewReturnType<UpLo>::Type
213 >::type SelfAdjointWrapper;
216
217 for(Index j=0; j<b.cols(); ++j)
218 {
221
222 typename Dest::ColXpr xj(x,j);
223 RowMajorWrapper row_mat(matrix());
224 internal::conjugate_gradient(SelfAdjointWrapper(row_mat), b.col(j), xj, Base::m_preconditioner, m_iterations, m_error);
225 }
226
227 m_isInitialized = true;
229 }
#define EIGEN_IMPLIES(a, b)
Definition Macros.h:902
#define EIGEN_STATIC_ASSERT(CONDITION, MSG)
Definition StaticAssert.h:124
ComputationInfo m_info
Definition IterativeSolverBase.h:388
RealScalar m_error
Definition IterativeSolverBase.h:386
Index m_iterations
Definition IterativeSolverBase.h:387
const ActualMatrixType & matrix() const
Definition IterativeSolverBase.h:369
internal::generic_matrix_wrapper< MatrixType > MatrixWrapper
Definition IterativeSolverBase.h:366
Index maxIterations() const
Definition IterativeSolverBase.h:281
MatrixWrapper::ActualMatrixType ActualMatrixType
Definition IterativeSolverBase.h:367
Preconditioner m_preconditioner
Definition IterativeSolverBase.h:381
RealScalar m_tolerance
Definition IterativeSolverBase.h:384
@ Success
Definition Constants.h:432
@ NoConvergence
Definition Constants.h:436
EIGEN_DONT_INLINE void conjugate_gradient(const MatrixType &mat, const Rhs &rhs, Dest &x, const Preconditioner &precond, Index &iters, typename Dest::RealScalar &tol_error)
Definition ConjugateGradient.h:28

References Eigen::internal::conjugate_gradient(), EIGEN_IMPLIES, EIGEN_STATIC_ASSERT, Eigen::Lower, Eigen::ConjugateGradient< _MatrixType, _UpLo, _Preconditioner >::m_error, Eigen::ConjugateGradient< _MatrixType, _UpLo, _Preconditioner >::m_info, Eigen::IterativeSolverBase< ConjugateGradient< _MatrixType, _UpLo, _Preconditioner > >::m_isInitialized, Eigen::ConjugateGradient< _MatrixType, _UpLo, _Preconditioner >::m_iterations, Eigen::IterativeSolverBase< Derived >::m_preconditioner, Eigen::IterativeSolverBase< Derived >::m_tolerance, Eigen::ConjugateGradient< _MatrixType, _UpLo, _Preconditioner >::matrix(), Eigen::IterativeSolverBase< Derived >::maxIterations(), Eigen::NoConvergence, Eigen::Success, Eigen::ConjugateGradient< _MatrixType, _UpLo, _Preconditioner >::UpLo, and Eigen::Upper.

Referenced by Eigen::ConjugateGradient< _MatrixType, _UpLo, _Preconditioner >::_solve_impl().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ analyzePattern()

ConjugateGradient< _MatrixType, _UpLo, _Preconditioner > & Eigen::IterativeSolverBase< ConjugateGradient< _MatrixType, _UpLo, _Preconditioner > >::analyzePattern ( const EigenBase< MatrixDerived > &  A)
inlineinherited

Initializes the iterative solver for the sparsity pattern of the matrix A for further solving Ax=b problems.

Currently, this function mostly calls analyzePattern on the preconditioner. In the future we might, for instance, implement column reordering for faster matrix vector products.

198 {
199 grab(A.derived());
200 m_preconditioner.analyzePattern(matrix());
201 m_isInitialized = true;
202 m_analysisIsOk = true;
203 m_info = m_preconditioner.info();
204 return derived();
205 }
void grab(const InputType &A)
Definition IterativeSolverBase.h:375
const ActualMatrixType & matrix() const
Definition IterativeSolverBase.h:369

◆ cols()

Index Eigen::IterativeSolverBase< ConjugateGradient< _MatrixType, _UpLo, _Preconditioner > >::cols ( ) const
inlineinherited
253{ return matrix().cols(); }

◆ compute()

ConjugateGradient< _MatrixType, _UpLo, _Preconditioner > & Eigen::IterativeSolverBase< ConjugateGradient< _MatrixType, _UpLo, _Preconditioner > >::compute ( const EigenBase< MatrixDerived > &  A)
inlineinherited

Initializes the iterative solver with the matrix A for further solving Ax=b problems.

Currently, this function mostly initializes/computes the preconditioner. In the future we might, for instance, implement column reordering for faster matrix vector products.

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.
239 {
240 grab(A.derived());
241 m_preconditioner.compute(matrix());
242 m_isInitialized = true;
243 m_analysisIsOk = true;
244 m_factorizationIsOk = true;
245 m_info = m_preconditioner.info();
246 return derived();
247 }

◆ derived() [1/2]

ConjugateGradient< _MatrixType, _UpLo, _Preconditioner > & Eigen::SparseSolverBase< ConjugateGradient< _MatrixType, _UpLo, _Preconditioner > >::derived ( )
inlineinherited
79{ return *static_cast<Derived*>(this); }

◆ derived() [2/2]

const ConjugateGradient< _MatrixType, _UpLo, _Preconditioner > & Eigen::SparseSolverBase< ConjugateGradient< _MatrixType, _UpLo, _Preconditioner > >::derived ( ) const
inlineinherited
80{ return *static_cast<const Derived*>(this); }

◆ error()

RealScalar Eigen::IterativeSolverBase< ConjugateGradient< _MatrixType, _UpLo, _Preconditioner > >::error ( ) const
inlineinherited
Returns
the tolerance error reached during the last solve. It is a close approximation of the true relative residual error |Ax-b|/|b|.
306 {
307 eigen_assert(m_isInitialized && "ConjugateGradient is not initialized.");
308 return m_error;
309 }

◆ factorize()

ConjugateGradient< _MatrixType, _UpLo, _Preconditioner > & Eigen::IterativeSolverBase< ConjugateGradient< _MatrixType, _UpLo, _Preconditioner > >::factorize ( const EigenBase< MatrixDerived > &  A)
inlineinherited

Initializes the iterative solver with the numerical values of the matrix A for further solving Ax=b problems.

Currently, this function mostly calls factorize on the preconditioner.

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.
218 {
219 eigen_assert(m_analysisIsOk && "You must first call analyzePattern()");
220 grab(A.derived());
221 m_preconditioner.factorize(matrix());
222 m_factorizationIsOk = true;
223 m_info = m_preconditioner.info();
224 return derived();
225 }

◆ grab()

void Eigen::IterativeSolverBase< ConjugateGradient< _MatrixType, _UpLo, _Preconditioner > >::grab ( const InputType &  A)
inlineprotectedinherited
376 {
377 m_matrixWrapper.grab(A);
378 }

◆ info()

ComputationInfo Eigen::IterativeSolverBase< ConjugateGradient< _MatrixType, _UpLo, _Preconditioner > >::info ( ) const
inlineinherited
Returns
Success if the iterations converged, and NoConvergence otherwise.
327 {
328 eigen_assert(m_isInitialized && "IterativeSolverBase is not initialized.");
329 return m_info;
330 }

◆ init()

void Eigen::IterativeSolverBase< ConjugateGradient< _MatrixType, _UpLo, _Preconditioner > >::init ( )
inlineprotectedinherited
358 {
359 m_isInitialized = false;
360 m_analysisIsOk = false;
361 m_factorizationIsOk = false;
362 m_maxIterations = -1;
363 m_tolerance = NumTraits<Scalar>::epsilon();
364 }

◆ iterations()

Index Eigen::IterativeSolverBase< ConjugateGradient< _MatrixType, _UpLo, _Preconditioner > >::iterations ( ) const
inlineinherited
Returns
the number of iterations performed during the last solve
297 {
298 eigen_assert(m_isInitialized && "ConjugateGradient is not initialized.");
299 return m_iterations;
300 }

◆ matrix()

template<typename _MatrixType , int _UpLo, typename _Preconditioner >
const ActualMatrixType & Eigen::IterativeSolverBase< Derived >::matrix ( ) const
inlineprivate
370 {
371 return m_matrixWrapper.matrix();
372 }

Referenced by Eigen::ConjugateGradient< _MatrixType, _UpLo, _Preconditioner >::_solve_with_guess_impl().

+ Here is the caller graph for this function:

◆ maxIterations()

Index Eigen::IterativeSolverBase< ConjugateGradient< _MatrixType, _UpLo, _Preconditioner > >::maxIterations ( ) const
inlineinherited
Returns
the max number of iterations. It is either the value setted by setMaxIterations or, by default, twice the number of columns of the matrix.
282 {
283 return (m_maxIterations<0) ? 2*matrix().cols() : m_maxIterations;
284 }

◆ preconditioner() [1/2]

Preconditioner & Eigen::IterativeSolverBase< ConjugateGradient< _MatrixType, _UpLo, _Preconditioner > >::preconditioner ( )
inlineinherited
Returns
a read-write reference to the preconditioner for custom configuration.
272{ return m_preconditioner; }

◆ preconditioner() [2/2]

const Preconditioner & Eigen::IterativeSolverBase< ConjugateGradient< _MatrixType, _UpLo, _Preconditioner > >::preconditioner ( ) const
inlineinherited
Returns
a read-only reference to the preconditioner.
275{ return m_preconditioner; }

◆ rows()

Index Eigen::IterativeSolverBase< ConjugateGradient< _MatrixType, _UpLo, _Preconditioner > >::rows ( ) const
inlineinherited
250{ return matrix().rows(); }

◆ setMaxIterations()

ConjugateGradient< _MatrixType, _UpLo, _Preconditioner > & Eigen::IterativeSolverBase< ConjugateGradient< _MatrixType, _UpLo, _Preconditioner > >::setMaxIterations ( Index  maxIters)
inlineinherited

Sets the max number of iterations. Default is twice the number of columns of the matrix.

290 {
291 m_maxIterations = maxIters;
292 return derived();
293 }

◆ setTolerance()

ConjugateGradient< _MatrixType, _UpLo, _Preconditioner > & Eigen::IterativeSolverBase< ConjugateGradient< _MatrixType, _UpLo, _Preconditioner > >::setTolerance ( const RealScalar tolerance)
inlineinherited

Sets the tolerance threshold used by the stopping criteria.

This value is used as an upper bound to the relative residual error: |Ax-b|/|b|. The default value is the machine precision given by NumTraits<Scalar>::epsilon()

266 {
268 return derived();
269 }

◆ solve() [1/2]

template<typename Derived >
template<typename Rhs >
const Solve< Derived, Rhs > Eigen::SparseSolverBase< Derived >::solve ( const MatrixBase< Rhs > &  b) const
inlineinherited
Returns
an expression of the solution x of $ A x = b $ using the current decomposition of A.
See also
compute()
89 {
90 eigen_assert(m_isInitialized && "Solver is not initialized.");
91 eigen_assert(derived().rows()==b.rows() && "solve(): invalid number of rows of the right hand side matrix b");
92 return Solve<Derived, Rhs>(derived(), b.derived());
93 }
bool m_isInitialized
Definition SparseSolverBase.h:119
size_t rows(const T &raster)
Definition MarchingSquares.hpp:55

References Eigen::SparseSolverBase< Derived >::derived(), eigen_assert, and Eigen::SparseSolverBase< Derived >::m_isInitialized.

Referenced by igl::embree::bone_heat(), igl::Frame_field_deformer::compute_optimal_positions(), igl::eigs(), igl::copyleft::comiso::FrameInterpolator::interpolateSymmetric(), igl::slim::solve_weighted_arap(), and igl::copyleft::comiso::NRosyField::solveNoRoundings().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ solve() [2/2]

template<typename Derived >
template<typename Rhs >
const Solve< Derived, Rhs > Eigen::SparseSolverBase< Derived >::solve ( const SparseMatrixBase< Rhs > &  b) const
inlineinherited
Returns
an expression of the solution x of $ A x = b $ using the current decomposition of A.
See also
compute()
102 {
103 eigen_assert(m_isInitialized && "Solver is not initialized.");
104 eigen_assert(derived().rows()==b.rows() && "solve(): invalid number of rows of the right hand side matrix b");
105 return Solve<Derived, Rhs>(derived(), b.derived());
106 }

◆ solveWithGuess()

const SolveWithGuess< ConjugateGradient< _MatrixType, _UpLo, _Preconditioner > , Rhs, Guess > Eigen::IterativeSolverBase< ConjugateGradient< _MatrixType, _UpLo, _Preconditioner > >::solveWithGuess ( const MatrixBase< Rhs > &  b,
const Guess &  x0 
) const
inlineinherited
Returns
the solution x of $ A x = b $ using the current decomposition of A and x0 as an initial solution.
See also
solve(), compute()
319 {
320 eigen_assert(m_isInitialized && "Solver is not initialized.");
321 eigen_assert(derived().rows()==b.rows() && "solve(): invalid number of rows of the right hand side matrix b");
322 return SolveWithGuess<Derived, Rhs, Guess>(derived(), b.derived(), x0);
323 }

◆ tolerance()

RealScalar Eigen::IterativeSolverBase< ConjugateGradient< _MatrixType, _UpLo, _Preconditioner > >::tolerance ( ) const
inlineinherited
Returns
the tolerance threshold used by the stopping criteria.
See also
setTolerance()
258{ return m_tolerance; }

Member Data Documentation

◆ m_analysisIsOk

bool Eigen::IterativeSolverBase< ConjugateGradient< _MatrixType, _UpLo, _Preconditioner > >::m_analysisIsOk
mutableprotectedinherited

◆ m_error

template<typename _MatrixType , int _UpLo, typename _Preconditioner >
RealScalar Eigen::IterativeSolverBase< Derived >::m_error
mutableprivate

◆ m_factorizationIsOk

bool Eigen::IterativeSolverBase< ConjugateGradient< _MatrixType, _UpLo, _Preconditioner > >::m_factorizationIsOk
protectedinherited

◆ m_info

template<typename _MatrixType , int _UpLo, typename _Preconditioner >
ComputationInfo Eigen::IterativeSolverBase< Derived >::m_info
mutableprivate

◆ m_isInitialized

bool Eigen::SparseSolverBase< ConjugateGradient< _MatrixType, _UpLo, _Preconditioner > >::m_isInitialized
mutableprotectedinherited

◆ m_iterations

template<typename _MatrixType , int _UpLo, typename _Preconditioner >
Index Eigen::IterativeSolverBase< Derived >::m_iterations
mutableprivate

◆ m_matrixWrapper

MatrixWrapper Eigen::IterativeSolverBase< ConjugateGradient< _MatrixType, _UpLo, _Preconditioner > >::m_matrixWrapper
protectedinherited

◆ m_maxIterations

Index Eigen::IterativeSolverBase< ConjugateGradient< _MatrixType, _UpLo, _Preconditioner > >::m_maxIterations
protectedinherited

◆ m_preconditioner

Preconditioner Eigen::IterativeSolverBase< ConjugateGradient< _MatrixType, _UpLo, _Preconditioner > >::m_preconditioner
protectedinherited

◆ m_tolerance

RealScalar Eigen::IterativeSolverBase< ConjugateGradient< _MatrixType, _UpLo, _Preconditioner > >::m_tolerance
protectedinherited

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