5#ifndef GKO_PUBLIC_CORE_STOP_COMBINED_HPP_
6#define GKO_PUBLIC_CORE_STOP_COMBINED_HPP_
11#include <ginkgo/core/stop/criterion.hpp>
43 std::vector<std::shared_ptr<const CriterionFactory>>
44 GKO_DEFERRED_FACTORY_VECTOR_PARAMETER(
criteria);
50 friend class ::gko::EnablePolymorphicObject<
52 friend class ::gko::enable_parameters_type<parameters_type, Factory>;
59 explicit Factory(std::shared_ptr<const ::gko::Executor> exec);
60 explicit Factory(std::shared_ptr<const ::gko::Executor> exec,
61 const parameters_type& parameters);
63 Factory(
const Factory& other) =
default;
64 Factory(Factory&& other) =
default;
66 Factory& operator=(
const Factory& other);
71 const parameters_type& get_parameters()
const {
return parameters_; }
74 bool check_impl(
uint8 stoppingId,
bool setFinalized,
76 const Updater&)
override;
78 explicit Combined(std::shared_ptr<const gko::Executor> exec);
80 explicit Combined(
const Factory* factory,
const CriterionArgs& args);
83 friend ::gko::stop::EnableDefaultCriterionFactory<Factory, Combined,
86 parameters_type parameters_;
88 std::vector<std::unique_ptr<Criterion>> criteria_{};
108template <
typename FactoryContainer>
109std::shared_ptr<const CriterionFactory>
combine(FactoryContainer&& factories)
111 switch (factories.size()) {
113 GKO_NOT_SUPPORTED(
nullptr);
115 if (factories[0] ==
nullptr) {
116 GKO_NOT_SUPPORTED(
nullptr);
120 if (factories[0] ==
nullptr) {
122 GKO_NOT_SUPPORTED(
nullptr);
124 auto exec = factories[0]->get_executor();
125 return Combined::build()
126 .with_criteria(std::forward<FactoryContainer>(factories))
This mixin inherits from (a subclass of) PolymorphicObject and provides a base implementation of a ne...
Definition polymorphic_object.hpp:662
The enable_parameters_type mixin is used to create a base implementation of the factory parameters st...
Definition abstract_factory.hpp:211
Definition combined.hpp:49
The Criterion class is a base class for all stopping criteria.
Definition criterion.hpp:36
std::shared_ptr< const CriterionFactory > combine(FactoryContainer &&factories)
Combines multiple criterion factories into a single combined criterion factory.
Definition combined.hpp:109
The Stopping criterion namespace.
Definition logger.hpp:52
AbstractFactory< Criterion, CriterionArgs > CriterionFactory
Declares an Abstract Factory specialized for Criterions.
Definition criterion.hpp:226
EnableDefaultFactory< ConcreteFactory, ConcreteCriterion, ParametersType, PolymorphicBase > EnableDefaultCriterionFactory
This is an alias for the EnableDefaultFactory mixin, which correctly sets the template parameters to ...
Definition criterion.hpp:246
The Ginkgo namespace.
Definition abstract_factory.hpp:20
std::uint8_t uint8
8-bit unsigned integral type.
Definition types.hpp:118
@ array
The matrix should be written as dense matrix in column-major order.
Definition mtx_io.hpp:96
Definition combined.hpp:33
std::vector< std::shared_ptr< const CriterionFactory > > criteria
Criterion factories to combine.
Definition combined.hpp:44