 |
Ginkgo
Generated from pipelines/238965899 branch based on develop. Ginkgo version 1.3.0
A numerical linear algebra library targeting many-core architectures
|
33 #ifndef GKO_PUBLIC_CORE_SOLVER_IR_HPP_
34 #define GKO_PUBLIC_CORE_SOLVER_IR_HPP_
40 #include <ginkgo/core/base/exception_helpers.hpp>
41 #include <ginkgo/core/base/lin_op.hpp>
42 #include <ginkgo/core/base/types.hpp>
43 #include <ginkgo/core/matrix/dense.hpp>
44 #include <ginkgo/core/matrix/identity.hpp>
45 #include <ginkgo/core/stop/combined.hpp>
46 #include <ginkgo/core/stop/criterion.hpp>
105 template <
typename ValueType = default_precision>
111 using value_type = ValueType;
121 return system_matrix_;
124 std::unique_ptr<LinOp>
transpose()
const override;
140 std::shared_ptr<const LinOp>
get_solver()
const {
return solver_; }
149 GKO_ASSERT_EQUAL_DIMENSIONS(new_solver,
this);
150 solver_ = new_solver;
161 return stop_criterion_factory_;
170 std::shared_ptr<const stop::CriterionFactory> other)
172 stop_criterion_factory_ = std::move(other);
180 std::vector<std::shared_ptr<const stop::CriterionFactory>>
194 generated_solver,
nullptr);
206 void apply_impl(
const LinOp *b,
LinOp *x)
const override;
209 LinOp *x)
const override;
211 explicit Ir(std::shared_ptr<const Executor> exec)
216 std::shared_ptr<const LinOp> system_matrix)
220 system_matrix_{std::move(system_matrix)}
222 GKO_ASSERT_IS_SQUARE_MATRIX(system_matrix_);
225 GKO_ASSERT_EQUAL_DIMENSIONS(solver_,
this);
226 }
else if (parameters_.
solver) {
227 solver_ = parameters_.
solver->generate(system_matrix_);
229 solver_ = matrix::Identity<ValueType>::create(this->
get_executor(),
232 relaxation_factor_ = gko::initialize<matrix::Dense<ValueType>>(
234 stop_criterion_factory_ =
239 std::shared_ptr<const LinOp> system_matrix_{};
240 std::shared_ptr<const LinOp> solver_{};
241 std::shared_ptr<const stop::CriterionFactory> stop_criterion_factory_{};
242 std::shared_ptr<const matrix::Dense<ValueType>> relaxation_factor_{};
246 template <
typename ValueType = default_precision>
247 using Richardson = Ir<ValueType>;
254 #endif // GKO_PUBLIC_CORE_SOLVER_IR_HPP_
Definition: lin_op.hpp:145
Iterative refinement (IR) is an iterative method that uses another coarse method to approximate the e...
Definition: ir.hpp:106
std::shared_ptr< const LinOp > generated_solver
Already generated solver.
Definition: ir.hpp:194
Linear operators which support transposition should implement the Transposable interface.
Definition: lin_op.hpp:418
std::unique_ptr< LinOp > transpose() const override
Returns a LinOp representing the transpose of the Transposable object.
const parameters_type & get_parameters() const noexcept
Returns the parameters of the factory.
Definition: abstract_factory.hpp:175
std::shared_ptr< const LinOp > get_solver() const
Returns the solver operator used as the inner solver.
Definition: ir.hpp:140
#define GKO_FACTORY_PARAMETER_SCALAR(_name, _default)
Creates a scalar factory parameter in the factory parameters structure.
Definition: lin_op.hpp:1048
The Ginkgo namespace.
Definition: abstract_factory.hpp:45
std::unique_ptr< LinOp > conj_transpose() const override
Returns a LinOp representing the conjugate transpose of the Transposable object.
#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:950
std::shared_ptr< const CriterionFactory > combine(FactoryContainer &&factories)
Combines multiple criterion factories into a single combined criterion factory.
Definition: combined.hpp:123
std::shared_ptr< const stop::CriterionFactory > get_stop_criterion_factory() const
Gets the stopping criterion factory of the solver.
Definition: ir.hpp:158
void set_solver(std::shared_ptr< const LinOp > new_solver)
Sets the solver operator used as the inner solver.
Definition: ir.hpp:147
std::vector< std::shared_ptr< const stop::CriterionFactory > > criteria
Criterion factories.
Definition: ir.hpp:181
void set_stop_criterion_factory(std::shared_ptr< const stop::CriterionFactory > other)
Sets the stopping criterion of the solver.
Definition: ir.hpp:169
bool apply_uses_initial_guess() const override
Return true as iterative solvers use the data in x as an initial guess.
Definition: ir.hpp:133
#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:997
#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:867
#define GKO_FACTORY_PARAMETER_VECTOR(_name,...)
Creates a vector factory parameter in the factory parameters structure.
Definition: lin_op.hpp:1064
ValueType relaxation_factor
Relaxation factor for Richardson iteration.
Definition: ir.hpp:200
std::shared_ptr< const LinOp > get_system_matrix() const
Returns the system operator (matrix) of the linear system.
Definition: ir.hpp:119
std::shared_ptr< const LinOpFactory > solver
Inner solver factory.
Definition: ir.hpp:187
std::shared_ptr< const Executor > get_executor() const noexcept
Returns the Executor of the object.
Definition: polymorphic_object.hpp:205
const dim< 2 > & get_size() const noexcept
Returns the size of the operator.
Definition: lin_op.hpp:232
The EnableLinOp mixin can be used to provide sensible default implementations of the majority of the ...
Definition: lin_op.hpp:765
This mixin inherits from (a subclass of) PolymorphicObject and provides a base implementation of a ne...
Definition: polymorphic_object.hpp:570