gko::log::Convergence#

The simplest solver-facing logger. Records the iteration count at which a solver converged (or stopped) and the residual norm at that point. Attach to any iterative solver to read back these two numbers after apply.

template<typename ValueType = default_precision>
class Convergence #

Inherits from

Convergence is a Logger which logs data strictly from the criterion_check_completed event. The purpose of this logger is to give a simple access to standard data generated by the solver once it has stopped with minimal overhead.

This logger also computes the residual norm from the residual when the residual norm was not available. This can add some slight overhead.

Public Functions

inline bool has_converged() const noexcept#

Returns true if the solver has converged.

Returns:

the bool flag for convergence status

inline void reset_convergence_status()#

Resets the convergence status to false.

inline const size_type &get_num_iterations() const noexcept#

Returns the number of iterations

Returns:

the number of iterations

inline const LinOp *get_residual() const noexcept#

Returns the residual

Returns:

the residual

inline const LinOp *get_residual_norm() const noexcept#

Returns the residual norm

Returns:

the residual norm

inline const LinOp *get_implicit_sq_resnorm() const noexcept#

Returns the implicit squared residual norm

Returns:

the implicit squared residual norm

Public Static Functions

static inline std::unique_ptr<Convergence> create(
std::shared_ptr<const Executor>,
const mask_type &enabled_events = Logger::criterion_events_mask | Logger::iteration_complete_mask,
)#

Creates a convergence logger. This dynamically allocates the memory, constructs the object and returns an std::unique_ptr to this object.

Parameters:
  • exec – the executor

  • enabled_events – the events enabled for this logger. By default all events.

Returns:

an std::unique_ptr to the the constructed object

static inline std::unique_ptr<Convergence> create(
const mask_type &enabled_events = Logger::criterion_events_mask | Logger::iteration_complete_mask,
)#

Creates a convergence logger. This dynamically allocates the memory, constructs the object and returns an std::unique_ptr to this object.

Parameters:

enabled_events – the events enabled for this logger. By default all events.

Returns:

an std::unique_ptr to the the constructed object