Ginkgo  Generated from pipelines/2222355941 branch based on develop. Ginkgo version 1.12.0
A numerical linear algebra library targeting many-core architectures
Classes | Typedefs | Enumerations | Functions
gko::stop Namespace Reference

The Stopping criterion namespace. More...

Classes

class  AbsoluteResidualNorm
 The AbsoluteResidualNorm class is a stopping criterion which stops the iteration process when the residual norm is below a certain threshold, i.e. More...
 
class  Combined
 The Combined class is used to combine multiple criterions together through an OR operation. More...
 
class  Criterion
 The Criterion class is a base class for all stopping criteria. More...
 
struct  CriterionArgs
 This struct is used to pass parameters to the EnableDefaultCriterionFactoryCriterionFactory::generate() method. More...
 
class  ImplicitResidualNorm
 The ImplicitResidualNorm class is a stopping criterion which stops the iteration process when the implicit residual norm is below a certain threshold relative to. More...
 
class  Iteration
 The Iteration class is a stopping criterion which stops the iteration process after a preset number of iterations. More...
 
class  RelativeResidualNorm
 The RelativeResidualNorm class is a stopping criterion which stops the iteration process when the residual norm is below a certain threshold relative to the norm of the right-hand side, i.e. More...
 
class  ResidualNorm
 The ResidualNorm class is a stopping criterion which stops the iteration process when the actual residual norm is below a certain threshold relative to. More...
 
class  ResidualNormBase
 The ResidualNormBase class provides a framework for stopping criteria related to the residual norm. More...
 
class  ResidualNormReduction
 The ResidualNormReduction class is a stopping criterion which stops the iteration process when the residual norm is below a certain threshold relative to the norm of the initial residual, i.e. More...
 
class  Time
 The Time class is a stopping criterion which stops the iteration process after a certain amount of time has passed. More...
 

Typedefs

using CriterionFactory = AbstractFactory< Criterion, CriterionArgs >
 Declares an Abstract Factory specialized for Criterions.
 
template<typename ConcreteFactory , typename ConcreteCriterion , typename ParametersType , typename PolymorphicBase = CriterionFactory>
using EnableDefaultCriterionFactory = EnableDefaultFactory< ConcreteFactory, ConcreteCriterion, ParametersType, PolymorphicBase >
 This is an alias for the EnableDefaultFactory mixin, which correctly sets the template parameters to enable a subclass of CriterionFactory. More...
 

Enumerations

enum  mode { absolute, initial_resnorm, rhs_norm }
 The mode for the residual norm criterion. More...
 

Functions

template<typename FactoryContainer >
std::shared_ptr< const CriterionFactorycombine (FactoryContainer &&factories)
 Combines multiple criterion factories into a single combined criterion factory. More...
 
deferred_factory_parameter< Iteration::Factorymax_iters (size_type count)
 Creates the precursor to an Iteration stopping criterion factory, to be used in conjunction with .with_criteria(...) function calls when building a solver factory. More...
 
deferred_factory_parameter< CriterionFactoryabsolute_residual_norm (double tolerance)
 Creates the precursor to a ResidualNorm stopping criterion factory, to be used in conjunction with .with_criteria(...) function calls when building a solver factory. More...
 
deferred_factory_parameter< CriterionFactoryrelative_residual_norm (double tolerance)
 Creates the precursor to a ResidualNorm stopping criterion factory, to be used in conjunction with .with_criteria(...) function calls when building a solver factory. More...
 
deferred_factory_parameter< CriterionFactoryinitial_residual_norm (double tolerance)
 Creates the precursor to a ResidualNorm stopping criterion factory, to be used in conjunction with .with_criteria(...) function calls when building a solver factory. More...
 
deferred_factory_parameter< CriterionFactoryabsolute_implicit_residual_norm (double tolerance)
 Creates the precursor to a ResidualNorm stopping criterion factory, to be used in conjunction with .with_criteria(...) function calls when building a solver factory. More...
 
deferred_factory_parameter< CriterionFactoryrelative_implicit_residual_norm (double tolerance)
 Creates the precursor to a ResidualNorm stopping criterion factory, to be used in conjunction with .with_criteria(...) function calls when building a solver factory. More...
 
deferred_factory_parameter< CriterionFactoryinitial_implicit_residual_norm (double tolerance)
 Creates the precursor to a ResidualNorm stopping criterion factory, to be used in conjunction with .with_criteria(...) function calls when building a solver factory. More...
 
deferred_factory_parameter< Time::Factorytime_limit (std::chrono::nanoseconds duration)
 Creates the precursor to a Time stopping criterion factory, to be used in conjunction with .with_criteria(...) function calls when building a solver factory. More...
 

Detailed Description

The Stopping criterion namespace.

Stopping criteria

Typedef Documentation

◆ EnableDefaultCriterionFactory

template<typename ConcreteFactory , typename ConcreteCriterion , typename ParametersType , typename PolymorphicBase = CriterionFactory>
using gko::stop::EnableDefaultCriterionFactory = typedef EnableDefaultFactory<ConcreteFactory, ConcreteCriterion, ParametersType, PolymorphicBase>

This is an alias for the EnableDefaultFactory mixin, which correctly sets the template parameters to enable a subclass of CriterionFactory.

Template Parameters
ConcreteFactorythe concrete factory which is being implemented [CRTP parameter]
ConcreteCriterionthe concrete Criterion type which this factory produces, needs to have a constructor which takes a const ConcreteFactory *, and a const CriterionArgs * as parameters.
ParametersTypea subclass of enable_parameters_type template which defines all of the parameters of the factory
PolymorphicBaseparent of ConcreteFactory in the polymorphic hierarchy, has to be a subclass of CriterionFactory

Function Documentation

◆ absolute_implicit_residual_norm()

deferred_factory_parameter<CriterionFactory> gko::stop::absolute_implicit_residual_norm ( double  tolerance)

Creates the precursor to a ResidualNorm stopping criterion factory, to be used in conjunction with .with_criteria(...) function calls when building a solver factory.

This stopping criterion will stop the iteration after the residual norm has decreased below the specified value or by the specified amount.

Full usage example: Stop after 100 iterations or when the absolute residual norm is below $10^{-10}$, whichever happens first.

Parameters
tolerancethe value the residual norm needs to be below. With residual $r$, initial guess $x_0$, right-hand side $b$, matrix $A$, absolute means the exact value of the norm $||r||$, relative means the norm relative to the right-hand side $||r||/||b||$, initial means the norm relative to the initial residual $||r||/||b - A x_0||$. An implicit stopping criterion is only available with some solvers, and refers to either the energy norm $||r||_A$ in short-recurrence solvers like Cg or the euclidian norm $||r||$ in solvers like GMRES. Implicit residual norms are cheaper to compute, but may be less precise due to accumulating rounding errors.
Returns
a deferred_factory_parameter that can be passed to the with_criteria function when building a solver.

◆ absolute_residual_norm()

deferred_factory_parameter<CriterionFactory> gko::stop::absolute_residual_norm ( double  tolerance)

Creates the precursor to a ResidualNorm stopping criterion factory, to be used in conjunction with .with_criteria(...) function calls when building a solver factory.

This stopping criterion will stop the iteration after the residual norm has decreased below the specified value or by the specified amount.

Full usage example: Stop after 100 iterations or when the absolute residual norm is below $10^{-10}$, whichever happens first.

Parameters
tolerancethe value the residual norm needs to be below. With residual $r$, initial guess $x_0$, right-hand side $b$, matrix $A$, absolute means the exact value of the norm $||r||$, relative means the norm relative to the right-hand side $||r||/||b||$, initial means the norm relative to the initial residual $||r||/||b - A x_0||$. An implicit stopping criterion is only available with some solvers, and refers to either the energy norm $||r||_A$ in short-recurrence solvers like Cg or the euclidian norm $||r||$ in solvers like GMRES. Implicit residual norms are cheaper to compute, but may be less precise due to accumulating rounding errors.
Returns
a deferred_factory_parameter that can be passed to the with_criteria function when building a solver.

◆ initial_implicit_residual_norm()

deferred_factory_parameter<CriterionFactory> gko::stop::initial_implicit_residual_norm ( double  tolerance)

Creates the precursor to a ResidualNorm stopping criterion factory, to be used in conjunction with .with_criteria(...) function calls when building a solver factory.

This stopping criterion will stop the iteration after the residual norm has decreased below the specified value or by the specified amount.

Full usage example: Stop after 100 iterations or when the absolute residual norm is below $10^{-10}$, whichever happens first.

Parameters
tolerancethe value the residual norm needs to be below. With residual $r$, initial guess $x_0$, right-hand side $b$, matrix $A$, absolute means the exact value of the norm $||r||$, relative means the norm relative to the right-hand side $||r||/||b||$, initial means the norm relative to the initial residual $||r||/||b - A x_0||$. An implicit stopping criterion is only available with some solvers, and refers to either the energy norm $||r||_A$ in short-recurrence solvers like Cg or the euclidian norm $||r||$ in solvers like GMRES. Implicit residual norms are cheaper to compute, but may be less precise due to accumulating rounding errors.
Returns
a deferred_factory_parameter that can be passed to the with_criteria function when building a solver.

◆ initial_residual_norm()

deferred_factory_parameter<CriterionFactory> gko::stop::initial_residual_norm ( double  tolerance)

Creates the precursor to a ResidualNorm stopping criterion factory, to be used in conjunction with .with_criteria(...) function calls when building a solver factory.

This stopping criterion will stop the iteration after the residual norm has decreased below the specified value or by the specified amount.

Full usage example: Stop after 100 iterations or when the absolute residual norm is below $10^{-10}$, whichever happens first.

Parameters
tolerancethe value the residual norm needs to be below. With residual $r$, initial guess $x_0$, right-hand side $b$, matrix $A$, absolute means the exact value of the norm $||r||$, relative means the norm relative to the right-hand side $||r||/||b||$, initial means the norm relative to the initial residual $||r||/||b - A x_0||$. An implicit stopping criterion is only available with some solvers, and refers to either the energy norm $||r||_A$ in short-recurrence solvers like Cg or the euclidian norm $||r||$ in solvers like GMRES. Implicit residual norms are cheaper to compute, but may be less precise due to accumulating rounding errors.
Returns
a deferred_factory_parameter that can be passed to the with_criteria function when building a solver.

◆ max_iters()

deferred_factory_parameter<Iteration::Factory> gko::stop::max_iters ( size_type  count)

Creates the precursor to an Iteration stopping criterion factory, to be used in conjunction with .with_criteria(...) function calls when building a solver factory.

This stopping criterion will stop the iteration after count iterations of the solver have finished.

Full usage example: Stop after 100 iterations or when the relative residual norm is below $10^{-10}$, whichever happens first.

Parameters
countthe number of iterations after which to stop
Returns
a deferred_factory_parameter that can be passed to the with_criteria function when building a solver.

◆ relative_implicit_residual_norm()

deferred_factory_parameter<CriterionFactory> gko::stop::relative_implicit_residual_norm ( double  tolerance)

Creates the precursor to a ResidualNorm stopping criterion factory, to be used in conjunction with .with_criteria(...) function calls when building a solver factory.

This stopping criterion will stop the iteration after the residual norm has decreased below the specified value or by the specified amount.

Full usage example: Stop after 100 iterations or when the absolute residual norm is below $10^{-10}$, whichever happens first.

Parameters
tolerancethe value the residual norm needs to be below. With residual $r$, initial guess $x_0$, right-hand side $b$, matrix $A$, absolute means the exact value of the norm $||r||$, relative means the norm relative to the right-hand side $||r||/||b||$, initial means the norm relative to the initial residual $||r||/||b - A x_0||$. An implicit stopping criterion is only available with some solvers, and refers to either the energy norm $||r||_A$ in short-recurrence solvers like Cg or the euclidian norm $||r||$ in solvers like GMRES. Implicit residual norms are cheaper to compute, but may be less precise due to accumulating rounding errors.
Returns
a deferred_factory_parameter that can be passed to the with_criteria function when building a solver.

◆ relative_residual_norm()

deferred_factory_parameter<CriterionFactory> gko::stop::relative_residual_norm ( double  tolerance)

Creates the precursor to a ResidualNorm stopping criterion factory, to be used in conjunction with .with_criteria(...) function calls when building a solver factory.

This stopping criterion will stop the iteration after the residual norm has decreased below the specified value or by the specified amount.

Full usage example: Stop after 100 iterations or when the absolute residual norm is below $10^{-10}$, whichever happens first.

Parameters
tolerancethe value the residual norm needs to be below. With residual $r$, initial guess $x_0$, right-hand side $b$, matrix $A$, absolute means the exact value of the norm $||r||$, relative means the norm relative to the right-hand side $||r||/||b||$, initial means the norm relative to the initial residual $||r||/||b - A x_0||$. An implicit stopping criterion is only available with some solvers, and refers to either the energy norm $||r||_A$ in short-recurrence solvers like Cg or the euclidian norm $||r||$ in solvers like GMRES. Implicit residual norms are cheaper to compute, but may be less precise due to accumulating rounding errors.
Returns
a deferred_factory_parameter that can be passed to the with_criteria function when building a solver.

◆ time_limit()

deferred_factory_parameter<Time::Factory> gko::stop::time_limit ( std::chrono::nanoseconds  duration)

Creates the precursor to a Time stopping criterion factory, to be used in conjunction with .with_criteria(...) function calls when building a solver factory.

This stopping criterion will stop the iteration after the specified amount of time since the start of the solver run has elapsed.

Full usage example: Stop after 1 second or when the relative residual norm is below $10^{-10}$, whichever happens first.

.with_criteria(
gko::stop::time_limit(std::chrono::seconds(1)),
.on(exec);
Parameters
durationthe time limit after which to stop the iteration. Thanks to std::chrono's converting constructors, you can specify any time units, and they will be converted to nanoseconds automatically.
Returns
a deferred_factory_parameter that can be passed to the with_criteria function when building a solver.
gko::stop::time_limit
deferred_factory_parameter< Time::Factory > time_limit(std::chrono::nanoseconds duration)
Creates the precursor to a Time stopping criterion factory, to be used in conjunction with ....
gko::stop::absolute_residual_norm
deferred_factory_parameter< CriterionFactory > absolute_residual_norm(double tolerance)
Creates the precursor to a ResidualNorm stopping criterion factory, to be used in conjunction with ....
gko::log::profile_event_category::factory
LinOpFactory events.
gko::stop::relative_residual_norm
deferred_factory_parameter< CriterionFactory > relative_residual_norm(double tolerance)
Creates the precursor to a ResidualNorm stopping criterion factory, to be used in conjunction with ....
gko::stop::max_iters
deferred_factory_parameter< Iteration::Factory > max_iters(size_type count)
Creates the precursor to an Iteration stopping criterion factory, to be used in conjunction with ....
gko::solver::Cg
CG or the conjugate gradient method is an iterative type Krylov subspace method which is suitable for...
Definition: cg.hpp:48