5#ifndef GKO_PUBLIC_CORE_STOP_STOPPING_STATUS_HPP_
6#define GKO_PUBLIC_CORE_STOP_STOPPING_STATUS_HPP_
9#include <ginkgo/core/base/array.hpp>
10#include <ginkgo/core/base/types.hpp>
22 friend GKO_ATTRIBUTES GKO_INLINE
bool operator==(
24 friend GKO_ATTRIBUTES GKO_INLINE
bool operator!=(
43 return data_ & converged_mask_;
53 return data_ & finalized_mask_;
62 return data_ & id_mask_;
68 GKO_ATTRIBUTES GKO_INLINE
void reset() noexcept { data_ =
uint8{0}; }
78 bool set_finalized =
true) noexcept
81 data_ |= (
id & id_mask_);
83 data_ |= finalized_mask_;
95 bool set_finalized =
true) noexcept
98 data_ |= converged_mask_ | (
id & id_mask_);
100 data_ |= finalized_mask_;
112 data_ |= finalized_mask_;
117 static constexpr uint8 converged_mask_ =
uint8{1} << 7;
118 static constexpr uint8 finalized_mask_ =
uint8{1} << 6;
137 return x.data_ == y.data_;
152 return x.data_ != y.data_;
This class is used to keep track of the stopping status of one vector.
Definition stopping_status.hpp:21
friend bool operator==(const stopping_status &x, const stopping_status &y) noexcept
Checks if two stopping statuses are equivalent.
Definition stopping_status.hpp:134
void finalize() noexcept
Set the result to be finalized (it needs to be stopped or converged first).
Definition stopping_status.hpp:109
void converge(uint8 id, bool set_finalized=true) noexcept
Call if convergence occurred.
Definition stopping_status.hpp:94
bool is_finalized() const noexcept
Check if the corresponding vector stores the finalized result.
Definition stopping_status.hpp:51
bool has_converged() const noexcept
Check if convergence was reached.
Definition stopping_status.hpp:41
void stop(uint8 id, bool set_finalized=true) noexcept
Call if a stop occurred due to a hard limit (and convergence was not reached).
Definition stopping_status.hpp:77
friend bool operator!=(const stopping_status &x, const stopping_status &y) noexcept
Checks if two stopping statuses are different.
Definition stopping_status.hpp:149
uint8 get_id() const noexcept
Get the id of the stopping criterion which caused the stop.
Definition stopping_status.hpp:60
bool has_stopped() const noexcept
Check if any stopping criteria was fulfilled.
Definition stopping_status.hpp:32
void reset() noexcept
Clear all flags.
Definition stopping_status.hpp:68
The Ginkgo namespace.
Definition abstract_factory.hpp:20
std::uint8_t uint8
8-bit unsigned integral type.
Definition types.hpp:118