5#ifndef GKO_PUBLIC_CORE_SOLVER_IR_HPP_
6#define GKO_PUBLIC_CORE_SOLVER_IR_HPP_
11#include <ginkgo/core/base/exception_helpers.hpp>
12#include <ginkgo/core/base/lin_op.hpp>
13#include <ginkgo/core/base/types.hpp>
14#include <ginkgo/core/config/config.hpp>
15#include <ginkgo/core/config/registry.hpp>
16#include <ginkgo/core/matrix/dense.hpp>
17#include <ginkgo/core/matrix/identity.hpp>
18#include <ginkgo/core/solver/solver_base.hpp>
19#include <ginkgo/core/stop/combined.hpp>
20#include <ginkgo/core/stop/criterion.hpp>
21#include <ginkgo/core/stop/iteration.hpp>
79template <
typename ValueType = default_precision>
90 using value_type = ValueType;
113 std::shared_ptr<const LinOp>
get_solver()
const {
return solver_; }
159 std::shared_ptr<const LinOpFactory> GKO_DEFERRED_FACTORY_PARAMETER(
201 config::make_type_descriptor<ValueType>());
204 void apply_impl(
const LinOp* b,
LinOp* x)
const override;
206 template <
typename VectorType>
207 void apply_dense_impl(
const VectorType* b, VectorType* x,
211 LinOp* x)
const override;
220 void set_relaxation_factor(
223 explicit Ir(std::shared_ptr<const Executor> exec)
227 explicit Ir(
const Factory* factory,
228 std::shared_ptr<const LinOp> system_matrix)
232 EnableIterativeBase<Ir>{
234 parameters_{factory->get_parameters()}
238 }
else if (parameters_.
solver) {
240 parameters_.
solver->generate(this->get_system_matrix()));
246 relaxation_factor_ = gko::initialize<matrix::Dense<ValueType>>(
251 std::shared_ptr<const LinOp> solver_{};
252 std::shared_ptr<const matrix::Dense<ValueType>> relaxation_factor_{};
256template <
typename ValueType = default_precision>
257using Richardson = Ir<ValueType>;
260template <
typename ValueType>
264 static int num_vectors(
const Solver&);
266 static int num_arrays(
const Solver&);
268 static std::vector<std::string> op_names(
const Solver&);
270 static std::vector<std::string> array_names(
const Solver&);
272 static std::vector<int> scalars(
const Solver&);
274 static std::vector<int> vectors(
const Solver&);
277 constexpr static int residual = 0;
279 constexpr static int inner_solution = 1;
281 constexpr static int one = 2;
283 constexpr static int minus_one = 3;
286 constexpr static int stop = 0;
300template <
typename ValueType>
302 size_type iteration = 1, ValueType relaxation_factor = 0.9)
304 auto exec = factory->get_executor();
306 .with_solver(factory)
307 .with_relaxation_factor(relaxation_factor)
308 .with_criteria(gko::stop::Iteration::build().with_max_iters(iteration))
324template <
typename ValueType>
326 size_type iteration = 1, ValueType relaxation_factor = 0.9)
328 auto exec = solver->get_executor();
330 .with_generated_solver(solver)
331 .with_relaxation_factor(relaxation_factor)
332 .with_criteria(gko::stop::Iteration::build().with_max_iters(iteration))
Definition lin_op.hpp:878
Definition polymorphic_object.hpp:668
Definition lin_op.hpp:117
std::shared_ptr< const Executor > get_executor() const noexcept
Definition polymorphic_object.hpp:243
Definition lin_op.hpp:433
Definition property_tree.hpp:28
Definition registry.hpp:167
Definition type_descriptor.hpp:39
static std::unique_ptr< Identity > create(std::shared_ptr< const Executor > exec, dim< 2 > size)
void set_default_initial_guess(initial_guess_mode guess)
Definition solver_base.hpp:141
initial_guess_mode get_default_initial_guess() const
Definition solver_base.hpp:123
Definition solver_base.hpp:161
Definition solver_base.hpp:699
Definition solver_base.hpp:539
std::unique_ptr< LinOp > conj_transpose() const override
void set_solver(std::shared_ptr< const LinOp > new_solver)
std::unique_ptr< LinOp > transpose() const override
void apply_with_initial_guess_impl(const LinOp *b, LinOp *x, initial_guess_mode guess) const override
static parameters_type parse(const config::pnode &config, const config::registry &context, const config::type_descriptor &td_for_child=config::make_type_descriptor< ValueType >())
void apply_with_initial_guess_impl(const LinOp *alpha, const LinOp *b, const LinOp *beta, LinOp *x, initial_guess_mode guess) const override
std::shared_ptr< const LinOp > get_solver() const
Definition ir.hpp:113
bool apply_uses_initial_guess() const override
Definition ir.hpp:102
Ir & operator=(const Ir &)
#define GKO_FACTORY_PARAMETER_SCALAR(_name, _default)
Definition abstract_factory.hpp:445
#define GKO_ENABLE_BUILD_METHOD(_factory_name)
Definition abstract_factory.hpp:394
#define GKO_ENABLE_LIN_OP_FACTORY(_lin_op, _parameters_name, _factory_name)
Definition lin_op.hpp:1016
std::shared_ptr< const CriterionFactory > combine(FactoryContainer &&factories)
Definition combined.hpp:109
initial_guess_mode
Definition solver_base.hpp:33
auto build_smoother(std::shared_ptr< const LinOpFactory > factory, size_type iteration=1, ValueType relaxation_factor=0.9)
Definition ir.hpp:301
The Ginkgo namespace.
Definition abstract_factory.hpp:20
constexpr T one()
Definition math.hpp:630
std::size_t size_type
Definition types.hpp:89
initial_guess_mode default_initial_guess
Definition ir.hpp:180
std::shared_ptr< const LinOpFactory > solver
Definition ir.hpp:160
std::shared_ptr< const LinOp > generated_solver
Definition ir.hpp:167
ValueType relaxation_factor
Definition ir.hpp:173
Definition solver_base.hpp:824
Definition solver_base.hpp:238