33 #ifndef GKO_CORE_STOP_STOPPING_STATUS_HPP_ 34 #define GKO_CORE_STOP_STOPPING_STATUS_HPP_ 37 #include <ginkgo/core/base/array.hpp> 38 #include <ginkgo/core/base/types.hpp> 50 friend GKO_ATTRIBUTES GKO_INLINE
bool operator==(
52 friend GKO_ATTRIBUTES GKO_INLINE
bool operator!=(
71 return data_ & converged_mask_;
81 return data_ & finalized_mask_;
90 return data_ & id_mask_;
96 GKO_ATTRIBUTES GKO_INLINE
void reset() noexcept { data_ =
uint8{0}; }
106 bool set_finalized =
true) noexcept
109 data_ |= (
id & id_mask_);
111 data_ |= finalized_mask_;
123 bool set_finalized =
true) noexcept
126 data_ |= converged_mask_ | (
id & id_mask_);
128 data_ |= finalized_mask_;
140 data_ |= finalized_mask_;
145 static constexpr
uint8 converged_mask_ =
uint8{1} << 7;
146 static constexpr
uint8 finalized_mask_ =
uint8{1} << 6;
165 return x.data_ == y.data_;
180 return x.data_ != y.data_;
187 #endif // GKO_CORE_STOP_STOPPING_STATUS_HPP_ friend bool operator!=(const stopping_status &x, const stopping_status &y) noexcept
Checks if two stopping statuses are different.
Definition: stopping_status.hpp:177
friend bool operator==(const stopping_status &x, const stopping_status &y) noexcept
Checks if two stopping statuses are equivalent.
Definition: stopping_status.hpp:162
The Ginkgo namespace.
Definition: abstract_factory.hpp:45
This class is used to keep track of the stopping status of one vector.
Definition: stopping_status.hpp:49
bool has_stopped() const noexcept
Check if any stopping criteria was fulfilled.
Definition: stopping_status.hpp:60
std::uint8_t uint8
8-bit unsigned integral type.
Definition: types.hpp:123
uint8 get_id() const noexcept
Get the id of the stopping criterion which caused the stop.
Definition: stopping_status.hpp:88
void reset() noexcept
Clear all flags.
Definition: stopping_status.hpp:96
bool is_finalized() const noexcept
Check if the corresponding vector stores the finalized result.
Definition: stopping_status.hpp:79
void stop(uint8 id, bool set_finalized=true) noexcept
Call if a stop occured due to a hard limit (and convergence was not reached).
Definition: stopping_status.hpp:105
bool has_converged() const noexcept
Check if convergence was reached.
Definition: stopping_status.hpp:69
void finalize() noexcept
Set the result to be finalized (it needs to be stopped or converged first).
Definition: stopping_status.hpp:137
void converge(uint8 id, bool set_finalized=true) noexcept
Call if convergence occured.
Definition: stopping_status.hpp:122