Ginkgo  Generated from pipelines/2662685947 branch based on develop. Ginkgo version 2.0.0
A numerical linear algebra library targeting many-core architectures
gauss_seidel.hpp
1 // SPDX-FileCopyrightText: 2017 - 2026 The Ginkgo authors
2 //
3 // SPDX-License-Identifier: BSD-3-Clause
4 
5 #ifndef GKO_PUBLIC_CORE_PRECONDITIONER_GAUSS_SEIDEL_HPP_
6 #define GKO_PUBLIC_CORE_PRECONDITIONER_GAUSS_SEIDEL_HPP_
7 
8 
9 #include <vector>
10 
11 #include <ginkgo/core/base/abstract_factory.hpp>
12 #include <ginkgo/core/base/composition.hpp>
13 #include <ginkgo/core/base/lin_op.hpp>
14 #include <ginkgo/core/base/polymorphic_object.hpp>
15 #include <ginkgo/core/config/config.hpp>
16 
17 
18 namespace gko {
19 namespace preconditioner {
20 
21 
32 template <typename ValueType = default_precision, typename IndexType = int32>
33 class GaussSeidel : public LinOpFactory,
34  public EnableCloneable<GaussSeidel<ValueType, IndexType>> {
35  friend class EnableCloneable<GaussSeidel>;
36  GKO_ASSERT_SUPPORTED_VALUE_AND_INDEX_TYPE;
37 
38 public:
39  struct parameters_type;
41 
42  using value_type = ValueType;
43  using index_type = IndexType;
45 
47  : public enable_parameters_type<parameters_type, GaussSeidel> {
48  // skip sorting of input matrix
49  bool GKO_FACTORY_PARAMETER_SCALAR(skip_sorting, false);
50 
51  // determines if Gauss-Seidel or symmetric Gauss-Seidel should be used
52  bool GKO_FACTORY_PARAMETER_SCALAR(symmetric, false);
53 
54  // factory for the lower triangular factor solver, defaults to LowerTrs
55  std::shared_ptr<const LinOpFactory> GKO_DEFERRED_FACTORY_PARAMETER(
56  l_solver);
57 
58  // factory for the upper triangular factor solver, unused if symmetric
59  // is false, defaults to UpperTrs
60  std::shared_ptr<const LinOpFactory> GKO_DEFERRED_FACTORY_PARAMETER(
61  u_solver);
62  };
63 
69  const parameters_type& get_parameters() { return parameters_; }
70 
74  const parameters_type& get_parameters() const { return parameters_; }
75 
83  std::unique_ptr<composition_type> generate(
84  std::shared_ptr<const LinOp> system_matrix) const;
85 
87  static parameters_type build() { return {}; }
88 
89  static parameters_type parse(
90  const config::pnode& config, const config::registry& context,
91  const config::type_descriptor& td_for_child =
92  config::make_type_descriptor<ValueType, IndexType>());
93 
94 protected:
95  explicit GaussSeidel(std::shared_ptr<const Executor> exec,
96  const parameters_type& params = {})
97  : LinOpFactory(exec), parameters_(params)
98  {}
99 
100  std::unique_ptr<LinOp> generate_impl(
101  std::shared_ptr<const LinOp> system_matrix) const override;
102 
103 private:
104  parameters_type parameters_;
105 };
106 
107 
108 } // namespace preconditioner
109 } // namespace gko
110 
111 
112 #endif // GKO_PUBLIC_CORE_PRECONDITIONER_GAUSS_SEIDEL_HPP_
gko::preconditioner::GaussSeidel
This class generates the Gauss-Seidel preconditioner.
Definition: gauss_seidel.hpp:33
gko::preconditioner::GaussSeidel::generate
std::unique_ptr< composition_type > generate(std::shared_ptr< const LinOp > system_matrix) const
gko::config::pnode
pnode describes a tree of properties.
Definition: property_tree.hpp:28
gko::preconditioner::GaussSeidel::parameters_type
Definition: gauss_seidel.hpp:46
gko::preconditioner::GaussSeidel::get_parameters
const parameters_type & get_parameters() const
Returns the parameters used to construct the factory.
Definition: gauss_seidel.hpp:74
GKO_FACTORY_PARAMETER_SCALAR
#define GKO_FACTORY_PARAMETER_SCALAR(_name, _default)
Creates a scalar factory parameter in the factory parameters structure.
Definition: abstract_factory.hpp:437
gko::config::type_descriptor
This class describes the value and index types to be used when building a Ginkgo type from a configur...
Definition: type_descriptor.hpp:39
gko::preconditioner::GaussSeidel::build
static parameters_type build()
Creates a new parameter_type to set up the factory.
Definition: gauss_seidel.hpp:87
gko
The Ginkgo namespace.
Definition: abstract_factory.hpp:20
gko::Composition
The Composition class can be used to compose linear operators op1, op2, ..., opn and obtain the opera...
Definition: composition.hpp:39
gko::preconditioner::GaussSeidel::get_parameters
const parameters_type & get_parameters()
Returns the parameters used to construct the factory.
Definition: gauss_seidel.hpp:69
gko::EnableCloneable
This mixin is used to enable a default Cloneable::clone() implementation and similar for objects that...
Definition: polymorphic_object.hpp:369
gko::config::registry
This class stores additional context for creating Ginkgo objects from configuration files.
Definition: registry.hpp:167
gko::LinOpFactory
A LinOpFactory represents a higher order mapping which transforms one linear operator into another.
Definition: lin_op.hpp:343
gko::enable_parameters_type
The enable_parameters_type mixin is used to create a base implementation of the factory parameters st...
Definition: abstract_factory.hpp:203