Classes | Enumerations | Functions
Convergence Namespace Reference

Items related to checking the convergence of numerical algorithms. More...

Classes

struct  Criteria
 Criteria that determine an iterative algorithm has converged. More...
 
struct  HasConverged
 Signals convergence of the algorithm. More...
 

Enumerations

enum  Reason { MaxIterations, AbsoluteResidual, RelativeResidual }
 The reason the algorithm has converged. More...
 

Functions

bool operator== (const Criteria &lhs, const Criteria &rhs) noexcept
 
bool operator!= (const Criteria &lhs, const Criteria &rhs) noexcept
 
boost::optional< Reasoncriteria_match (const Criteria &criteria, size_t iteration_id, double residual_magnitude, double initial_residual_magnitude) noexcept
 Determine whether the criteria are met. More...
 
std::ostreamoperator<< (std::ostream &os, const HasConverged &has_converged) noexcept
 
bool operator== (const HasConverged &lhs, const HasConverged &rhs) noexcept
 
bool operator!= (const HasConverged &lhs, const HasConverged &rhs) noexcept
 
std::ostreamoperator<< (std::ostream &os, const Reason &reason) noexcept
 

Detailed Description

Items related to checking the convergence of numerical algorithms.

Enumeration Type Documentation

◆ Reason

enum Convergence::Reason
strong

The reason the algorithm has converged.

See also
Convergence::Criteria

Function Documentation

◆ criteria_match()

boost::optional< Reason > Convergence::criteria_match ( const Criteria criteria,
size_t  iteration_id,
double  residual_magnitude,
double  initial_residual_magnitude 
)
noexcept

Determine whether the criteria are met.

Note
This function assumes the iteration_id is that of the latest completed step and that it is zero-indexed, where zero indicates the initial state of the algorithm. Therefore, the MaxIteration criterion will match if the iteration_id is equal or higher. For example, a MaxIteration of 0 means the algorithm should run no iterations, so it matches if the iteration_id is 0 or higher since that's the initial state before any steps have been performed. A MaxIteration of 1 matches if the iteration_id is 1 or higher since one iteration is complete. At this point, also the residual_magnitude reflects the state of the algorithm after completion of the first iteration. The initial_residual_magnitude always refers to the state before the first iteration has begun, i.e. where the iteration_id is zero.

Returns: a Convergence::Reason if the criteria are met, or boost::none otherwise.