Ginkgo: ginkgo/core/preconditioner/gauss_seidel.hpp Source File

| Ginkgo Generated from branch based on main. Ginkgo version 1.11.0 A numerical linear algebra library targeting many-core architectures

Loading...
Searching...
No Matches
gauss_seidel.hpp
1// SPDX-FileCopyrightText: 2017 - 2025 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
18namespace gko {
19 namespace preconditioner {
20
21
32template <typename ValueType = default_precision, typename IndexType = int32>
33 class GaussSeidel
34 : public EnablePolymorphicObject<GaussSeidel<ValueType, IndexType>,
35 LinOpFactory>,
36 public EnablePolymorphicAssignment<GaussSeidel<ValueType, IndexType>> {
37 friend class EnablePolymorphicObject<GaussSeidel, LinOpFactory>;
38 GKO_ASSERT_SUPPORTED_VALUE_AND_INDEX_TYPE;
39
40public:
41 struct parameters_type;
42 friend class enable_parameters_type<parameters_type, GaussSeidel>;
43
44 using value_type = ValueType;
45 using index_type = IndexType;
46 using composition_type = Composition<ValueType>;
47
48 struct parameters_type
49 : public enable_parameters_type<parameters_type, GaussSeidel> {
50 // skip sorting of input matrix
51 bool GKO_FACTORY_PARAMETER_SCALAR(skip_sorting, false);
52
53 // determines if Gauss-Seidel or symmetric Gauss-Seidel should be used
54 bool GKO_FACTORY_PARAMETER_SCALAR(symmetric, false);
55
56 // factory for the lower triangular factor solver, defaults to LowerTrs
57 std::shared_ptr<const LinOpFactory> GKO_DEFERRED_FACTORY_PARAMETER(
58 l_solver);
59
60 // factory for the upper triangular factor solver, unused if symmetric
61 // is false, defaults to UpperTrs
62 std::shared_ptr<const LinOpFactory> GKO_DEFERRED_FACTORY_PARAMETER(
63 u_solver);
64 };
65
71 const parameters_type& get_parameters() { return parameters_; }
72
76 const parameters_type& get_parameters() const { return parameters_; }
77
85 std::unique_ptr<composition_type> generate(
86 std::shared_ptr<const LinOp> system_matrix) const;
87
89 static parameters_type build() { return {}; }
90
91 static parameters_type parse(
92 const config::pnode& config, const config::registry& context,
93 const config::type_descriptor& td_for_child =
94 config::make_type_descriptor<ValueType, IndexType>());
95
96protected:
97 explicit GaussSeidel(std::shared_ptr<const Executor> exec,
98 const parameters_type& params = {})
99 : EnablePolymorphicObject<GaussSeidel, LinOpFactory>(exec),
100 parameters_(params)
101 {}
102
103 std::unique_ptr<LinOp> generate_impl(
104 std::shared_ptr<const LinOp> system_matrix) const override;
105
106private:
107 parameters_type parameters_;
108};
109
110
111} // namespace preconditioner
112} // namespace gko
113
114
115#endif // GKO_PUBLIC_CORE_PRECONDITIONER_GAUSS_SEIDEL_HPP_
gko::Composition
The Composition class can be used to compose linear operators op1, op2, ..., opn and obtain the opera...
Definition composition.hpp:41
gko::EnablePolymorphicAssignment
This mixin is used to enable a default PolymorphicObject::copy_from() implementation for objects that...
Definition polymorphic_object.hpp:743
gko::EnablePolymorphicObject
This mixin inherits from (a subclass of) PolymorphicObject and provides a base implementation of a ne...
Definition polymorphic_object.hpp:668
gko::LinOpFactory
A LinOpFactory represents a higher order mapping which transforms one linear operator into another.
Definition lin_op.hpp:385
gko::config::pnode
pnode describes a tree of properties.
Definition property_tree.hpp:28
gko::config::registry
This class stores additional context for creating Ginkgo objects from configuration files.
Definition registry.hpp:167
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::enable_parameters_type
The enable_parameters_type mixin is used to create a base implementation of the factory parameters st...
Definition abstract_factory.hpp:211
gko::preconditioner::GaussSeidel
This class generates the Gauss-Seidel preconditioner.
Definition gauss_seidel.hpp:36
gko::preconditioner::GaussSeidel::get_parameters
const parameters_type & get_parameters()
Returns the parameters used to construct the factory.
Definition gauss_seidel.hpp:71
gko::preconditioner::GaussSeidel::build
static parameters_type build()
Creates a new parameter_type to set up the factory.
Definition gauss_seidel.hpp:89
gko::preconditioner::GaussSeidel::generate
std::unique_ptr< composition_type > generate(std::shared_ptr< const LinOp > system_matrix) const
Creates a new product from the given components.
gko::preconditioner::GaussSeidel::get_parameters
const parameters_type & get_parameters() const
Returns the parameters used to construct the factory.
Definition gauss_seidel.hpp:76
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:445
gko::preconditioner
The Preconditioner namespace.
Definition gauss_seidel.hpp:19
gko
The Ginkgo namespace.
Definition abstract_factory.hpp:20
gko::preconditioner::GaussSeidel::parameters_type
Definition gauss_seidel.hpp:49