|
Ginkgo
Generated from pipelines/1556235455 branch based on develop. Ginkgo version 1.9.0
A numerical linear algebra library targeting many-core architectures
|
5 #ifndef GKO_PUBLIC_CORE_LOG_CONVERGENCE_HPP_
6 #define GKO_PUBLIC_CORE_LOG_CONVERGENCE_HPP_
11 #include <ginkgo/core/log/logger.hpp>
12 #include <ginkgo/core/matrix/dense.hpp>
13 #include <ginkgo/core/stop/criterion.hpp>
36 template <
typename ValueType = default_precision>
41 const LinOp* residual,
const LinOp* residual_norm,
42 const LinOp* solution,
const uint8& stopping_id,
44 const bool& one_changed,
const bool& all_stopped)
const override;
48 const LinOp* residual,
const LinOp* residual_norm,
49 const LinOp* implicit_sq_resnorm,
const LinOp* solution,
50 const uint8& stopping_id,
const bool& set_finalized,
52 const bool& all_stopped)
const override;
56 const LinOp* residual,
57 const LinOp* residual_norm,
58 const LinOp* implicit_resnorm_sq,
60 bool stopped)
const override;
72 GKO_DEPRECATED(
"use single-parameter create")
76 Logger::iteration_complete_mask)
78 return std::unique_ptr<Convergence>(
new Convergence(enabled_events));
90 static std::unique_ptr<Convergence>
create(
92 Logger::iteration_complete_mask)
94 return std::unique_ptr<Convergence>(
new Convergence(enabled_events));
116 return num_iterations_;
133 return residual_norm_.get();
143 return implicit_sq_resnorm_.get();
154 GKO_DEPRECATED(
"use single-parameter constructor")
158 Logger::iteration_complete_mask)
168 explicit Convergence(
170 Logger::iteration_complete_mask)
171 : Logger(enabled_events)
175 mutable bool convergence_status_{
false};
177 mutable std::unique_ptr<LinOp> residual_{};
178 mutable std::unique_ptr<LinOp> residual_norm_{};
179 mutable std::unique_ptr<LinOp> implicit_sq_resnorm_{};
187 #endif // GKO_PUBLIC_CORE_LOG_CONVERGENCE_HPP_
std::uint8_t uint8
8-bit unsigned integral type.
Definition: types.hpp:115
const LinOp * get_residual() const noexcept
Returns the residual.
Definition: convergence.hpp:124
static 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.
Definition: convergence.hpp:73
Definition: lin_op.hpp:117
const size_type & get_num_iterations() const noexcept
Returns the number of iterations.
Definition: convergence.hpp:114
void reset_convergence_status()
Resets the convergence status to false.
Definition: convergence.hpp:107
const LinOp * get_implicit_sq_resnorm() const noexcept
Returns the implicit squared residual norm.
Definition: convergence.hpp:141
Stopping criterion events.
std::size_t size_type
Integral type used for allocation quantities.
Definition: types.hpp:86
The Ginkgo namespace.
Definition: abstract_factory.hpp:20
An array is a container which encapsulates fixed-sized arrays, stored on the Executor tied to the arr...
Definition: array.hpp:26
static constexpr mask_type criterion_events_mask
Bitset Mask which activates all criterion events.
Definition: logger.hpp:635
Convergence is a Logger which logs data strictly from the criterion_check_completed event.
Definition: convergence.hpp:37
static std::unique_ptr< Convergence > create(const mask_type &enabled_events=Logger::criterion_events_mask|Logger::iteration_complete_mask)
Creates a convergence logger.
Definition: convergence.hpp:90
bool has_converged() const noexcept
Returns true if the solver has converged.
Definition: convergence.hpp:102
Definition: logger.hpp:75
void on_criterion_check_completed(const stop::Criterion *criterion, const size_type &num_iterations, const LinOp *residual, const LinOp *residual_norm, const LinOp *solution, const uint8 &stopping_id, const bool &set_finalized, const array< stopping_status > *status, const bool &one_changed, const bool &all_stopped) const override
stop::Criterion's check completed event.
The Criterion class is a base class for all stopping criteria.
Definition: criterion.hpp:36
The first step in using the Ginkgo library consists of creating an executor.
Definition: executor.hpp:615
const LinOp * get_residual_norm() const noexcept
Returns the residual norm.
Definition: convergence.hpp:131
void on_iteration_complete(const LinOp *solver, const LinOp *b, const LinOp *x, const size_type &num_iterations, const LinOp *residual, const LinOp *residual_norm, const LinOp *implicit_resnorm_sq, const array< stopping_status > *status, bool stopped) const override
Register the iteration_complete event which logs every completed iterations.