33 #ifndef GKO_CORE_SOLVER_CGS_HPP_ 34 #define GKO_CORE_SOLVER_CGS_HPP_ 40 #include <ginkgo/core/base/array.hpp> 41 #include <ginkgo/core/base/lin_op.hpp> 42 #include <ginkgo/core/base/math.hpp> 43 #include <ginkgo/core/base/types.hpp> 44 #include <ginkgo/core/log/logger.hpp> 45 #include <ginkgo/core/matrix/identity.hpp> 46 #include <ginkgo/core/stop/combined.hpp> 47 #include <ginkgo/core/stop/criterion.hpp> 67 template <
typename ValueType = default_precision>
73 using value_type = ValueType;
82 return system_matrix_;
92 return preconditioner_;
100 std::vector<std::shared_ptr<const stop::CriterionFactory>>
107 preconditioner,
nullptr);
113 void apply_impl(
const LinOp *b, LinOp *x)
const override;
115 void apply_impl(
const LinOp *alpha,
const LinOp *b,
const LinOp *beta,
116 LinOp *x)
const override;
118 explicit Cgs(std::shared_ptr<const Executor> exec)
122 explicit Cgs(
const Factory *factory,
123 std::shared_ptr<const LinOp> system_matrix)
127 system_matrix_{std::move(system_matrix)}
136 stop_criterion_factory_ =
141 std::shared_ptr<const LinOp> system_matrix_{};
142 std::shared_ptr<const LinOp> preconditioner_{};
143 std::shared_ptr<const stop::CriterionFactory> stop_criterion_factory_{};
151 #endif // GKO_CORE_SOLVER_CGS_HPP std::shared_ptr< const LinOp > get_preconditioner() const override
Returns the preconditioner operator used by the solver.
Definition: cgs.hpp:90
std::shared_ptr< const LinOpFactory > preconditioner
Preconditioner factory.
Definition: cgs.hpp:107
const parameters_type & get_parameters() const noexcept
Returns the parameters of the factory.
Definition: abstract_factory.hpp:175
This mixin inherits from (a subclass of) PolymorphicObject and provides a base implementation of a ne...
Definition: polymorphic_object.hpp:505
#define GKO_FACTORY_PARAMETER(_name,...)
Creates a factory parameter in the factory parameters structure.
Definition: lin_op.hpp:751
std::vector< std::shared_ptr< const stop::CriterionFactory > > criteria
Criterion factories.
Definition: cgs.hpp:101
CGS or the conjugate gradient square method is an iterative type Krylov subspace method which is suit...
Definition: cgs.hpp:68
The Ginkgo namespace.
Definition: abstract_factory.hpp:45
The EnableLinOp mixin can be used to provide sensible default implementations of the majority of the ...
Definition: lin_op.hpp:509
const dim< 2 > & get_size() const noexcept
Returns the size of the operator.
Definition: lin_op.hpp:221
A LinOp implementing this interface can be preconditioned.
Definition: lin_op.hpp:465
std::shared_ptr< const Executor > get_executor() const noexcept
Returns the Executor of the object.
Definition: polymorphic_object.hpp:201
#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: lin_op.hpp:611
This class is a utility which efficiently implements the identity matrix (a linear operator which map...
Definition: identity.hpp:63
std::shared_ptr< const CriterionFactory > combine(FactoryContainer &&factories)
Combines multiple criterion factories into a single combined criterion factory.
Definition: combined.hpp:116
std::shared_ptr< const LinOp > get_system_matrix() const
Gets the system operator (matrix) of the linear system.
Definition: cgs.hpp:80
#define GKO_ENABLE_LIN_OP_FACTORY(_lin_op, _parameters_name, _factory_name)
This macro will generate a default implementation of a LinOpFactory for the LinOp subclass it is defi...
Definition: lin_op.hpp:691
#define GKO_ENABLE_BUILD_METHOD(_factory_name)
Defines a build method for the factory, simplifying its construction by removing the repetitive typin...
Definition: lin_op.hpp:730
constexpr dim< 2, DimensionType > transpose(const dim< 2, DimensionType > &dimensions) noexcept
Returns a dim<2> object with its dimensions swapped.
Definition: dim.hpp:234