 |
Ginkgo
Generated from pipelines/2222355941 branch based on develop. Ginkgo version 1.12.0
A numerical linear algebra library targeting many-core architectures
|
5 #ifndef GKO_PUBLIC_CORE_STOP_RESIDUAL_NORM_HPP_
6 #define GKO_PUBLIC_CORE_STOP_RESIDUAL_NORM_HPP_
11 #include <ginkgo/core/base/array.hpp>
12 #include <ginkgo/core/base/math.hpp>
13 #include <ginkgo/core/base/types.hpp>
14 #include <ginkgo/core/base/utils.hpp>
15 #include <ginkgo/core/matrix/dense.hpp>
16 #include <ginkgo/core/stop/criterion.hpp>
37 enum class mode { absolute, initial_resnorm, rhs_norm };
49 template <
typename ValueType>
54 GKO_ASSERT_SUPPORTED_VALUE_TYPE;
61 bool check_impl(
uint8 stoppingId,
bool setFinalized,
67 device_storage_{exec, 2}
72 absolute_type reduction_factor,
mode baseline);
75 std::unique_ptr<NormVector> starting_tau_{};
76 std::unique_ptr<NormVector> u_dense_tau_{};
81 mode baseline_{mode::rhs_norm};
82 std::shared_ptr<const LinOp> system_matrix_{};
83 std::shared_ptr<const LinOp> b_{};
85 std::shared_ptr<const Vector> one_{};
86 std::shared_ptr<const Vector> neg_one_{};
112 template <
typename ValueType = default_precision>
125 5 * std ::numeric_limits<remove_complex<ValueType>>::epsilon()};
129 this->reduction_factor = value;
143 explicit ResidualNorm(std::shared_ptr<const gko::Executor> exec)
149 factory->get_executor(), args,
150 factory->get_parameters().reduction_factor,
151 factory->get_parameters().baseline),
152 parameters_{factory->get_parameters()}
174 template <
typename ValueType = default_precision>
187 5 * std ::numeric_limits<remove_complex<ValueType>>::epsilon()};
191 this->reduction_factor = value;
208 bool check_impl(
uint8 stoppingId,
bool setFinalized,
219 factory->get_executor(), args,
220 factory->get_parameters().reduction_factor,
221 factory->get_parameters().baseline),
222 parameters_{factory->get_parameters()}
285 GKO_BEGIN_DISABLE_DEPRECATION_WARNINGS
307 template <
typename ValueType = default_precision>
308 class GKO_DEPRECATED(
309 "Please use the class
ResidualNorm with the factory parameter baseline =
"
310 "mode::initial_resnorm
") ResidualNormReduction
311 : public ResidualNormBase<ValueType> {
313 using ComplexVector = matrix::Dense<to_complex<ValueType>>;
314 using NormVector = matrix::Dense<remove_complex<ValueType>>;
315 using Vector = matrix::Dense<ValueType>;
317 GKO_CREATE_FACTORY_PARAMETERS(parameters, Factory)
322 remove_complex<ValueType> reduction_factor{
323 5 * std ::numeric_limits<remove_complex<ValueType>>::epsilon()};
325 parameters_type& with_reduction_factor(remove_complex<ValueType> value)
327 this->reduction_factor = value;
331 GKO_ENABLE_CRITERION_FACTORY(ResidualNormReduction<ValueType>, parameters,
333 GKO_ENABLE_BUILD_METHOD(Factory);
336 explicit ResidualNormReduction(std::shared_ptr<const gko::Executor> exec)
337 : ResidualNormBase<ValueType>(exec)
340 explicit ResidualNormReduction(const Factory* factory,
341 const CriterionArgs& args)
342 : ResidualNormBase<ValueType>(
343 factory->get_executor(), args,
344 factory->get_parameters().reduction_factor,
345 mode::initial_resnorm),
346 parameters_{factory->get_parameters()}
369 template <typename ValueType = default_precision>
370 class GKO_DEPRECATED(
371 "Please use the
class ResidualNorm with the factory parameter baseline =
"
372 "mode::rhs_norm
") RelativeResidualNorm
373 : public ResidualNormBase<ValueType> {
375 using ComplexVector = matrix::Dense<to_complex<ValueType>>;
376 using NormVector = matrix::Dense<remove_complex<ValueType>>;
377 using Vector = matrix::Dense<ValueType>;
379 GKO_CREATE_FACTORY_PARAMETERS(parameters, Factory)
384 remove_complex<ValueType> tolerance{
385 5 * std ::numeric_limits<remove_complex<ValueType>>::epsilon()};
388 parameters_type& with_tolerance(remove_complex<ValueType> value)
390 this->tolerance = value;
394 GKO_ENABLE_CRITERION_FACTORY(RelativeResidualNorm<ValueType>, parameters,
396 GKO_ENABLE_BUILD_METHOD(Factory);
399 explicit RelativeResidualNorm(std::shared_ptr<const gko::Executor> exec)
400 : ResidualNormBase<ValueType>(exec)
403 explicit RelativeResidualNorm(const Factory* factory,
404 const CriterionArgs& args)
405 : ResidualNormBase<ValueType>(factory->get_executor(), args,
406 factory->get_parameters().tolerance,
408 parameters_{factory->get_parameters()}
430 template <typename ValueType = default_precision>
431 class GKO_DEPRECATED(
432 "Please use the
class ResidualNorm with the factory parameter baseline =
"
433 "mode::absolute
") AbsoluteResidualNorm
434 : public ResidualNormBase<ValueType> {
436 using NormVector = matrix::Dense<remove_complex<ValueType>>;
437 using Vector = matrix::Dense<ValueType>;
439 GKO_CREATE_FACTORY_PARAMETERS(parameters, Factory)
444 remove_complex<ValueType> tolerance{
445 5 * std ::numeric_limits<remove_complex<ValueType>>::epsilon()};
447 parameters_type& with_tolerance(remove_complex<ValueType> value)
449 this->tolerance = value;
453 GKO_ENABLE_CRITERION_FACTORY(AbsoluteResidualNorm<ValueType>, parameters,
455 GKO_ENABLE_BUILD_METHOD(Factory);
458 explicit AbsoluteResidualNorm(std::shared_ptr<const gko::Executor> exec)
459 : ResidualNormBase<ValueType>(exec)
462 explicit AbsoluteResidualNorm(const Factory* factory,
463 const CriterionArgs& args)
464 : ResidualNormBase<ValueType>(factory->get_executor(), args,
465 factory->get_parameters().tolerance,
467 parameters_{factory->get_parameters()}
472 GKO_END_DISABLE_DEPRECATION_WARNINGS
479 #endif // GKO_PUBLIC_CORE_STOP_RESIDUAL_NORM_HPP_
This struct is used to pass parameters to the EnableDefaultCriterionFactoryCriterionFactory::generate...
Definition: criterion.hpp:205
std::uint8_t uint8
8-bit unsigned integral type.
Definition: types.hpp:119
Dense is a matrix format which explicitly stores all values of the matrix.
Definition: dense_cache.hpp:28
deferred_factory_parameter< CriterionFactory > initial_residual_norm(double tolerance)
Creates the precursor to a ResidualNorm stopping criterion factory, to be used in conjunction with ....
deferred_factory_parameter< CriterionFactory > absolute_residual_norm(double tolerance)
Creates the precursor to a ResidualNorm stopping criterion factory, to be used in conjunction with ....
deferred_factory_parameter< CriterionFactory > absolute_implicit_residual_norm(double tolerance)
Creates the precursor to a ResidualNorm stopping criterion factory, to be used in conjunction with ....
deferred_factory_parameter< CriterionFactory > relative_residual_norm(double tolerance)
Creates the precursor to a ResidualNorm stopping criterion factory, to be used in conjunction with ....
#define GKO_FACTORY_PARAMETER_SCALAR(_name, _default)
Creates a scalar factory parameter in the factory parameters structure.
Definition: abstract_factory.hpp:445
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
The ResidualNorm class is a stopping criterion which stops the iteration process when the actual resi...
Definition: residual_norm.hpp:113
Definition: residual_norm.hpp:202
deferred_factory_parameter< CriterionFactory > initial_implicit_residual_norm(double tolerance)
Creates the precursor to a ResidualNorm stopping criterion factory, to be used in conjunction with ....
The Criterion class is a base class for all stopping criteria.
Definition: criterion.hpp:36
mode
The mode for the residual norm criterion.
Definition: residual_norm.hpp:37
Definition: residual_norm.hpp:139
The Updater class serves for convenient argument passing to the Criterion's check function.
Definition: criterion.hpp:55
Definition: residual_norm.hpp:119
Definition: residual_norm.hpp:181
#define GKO_ENABLE_BUILD_METHOD(_factory_name)
Defines a build method for the factory, simplifying its construction by removing the repetitive typin...
Definition: abstract_factory.hpp:394
#define GKO_CREATE_FACTORY_PARAMETERS(_parameters_name, _factory_name)
This Macro will generate a new type containing the parameters for the factory _factory_name.
Definition: abstract_factory.hpp:280
The ImplicitResidualNorm class is a stopping criterion which stops the iteration process when the imp...
Definition: residual_norm.hpp:175
The ResidualNormBase class provides a framework for stopping criteria related to the residual norm.
Definition: residual_norm.hpp:50
typename detail::remove_complex_s< T >::type remove_complex
Obtain the type which removed the complex of complex/scalar type or the template parameter of class b...
Definition: math.hpp:264
deferred_factory_parameter< CriterionFactory > relative_implicit_residual_norm(double tolerance)
Creates the precursor to a ResidualNorm stopping criterion factory, to be used in conjunction with ....
This mixin inherits from (a subclass of) PolymorphicObject and provides a base implementation of a ne...
Definition: polymorphic_object.hpp:667