Ginkgo  Generated from pipelines/3136675824 branch based on develop. Ginkgo version 2.0.0
A numerical linear algebra library targeting many-core architectures
direct.hpp
1 // SPDX-FileCopyrightText: 2017 - 2026 The Ginkgo authors
2 //
3 // SPDX-License-Identifier: BSD-3-Clause
4 
5 #ifndef GKO_PUBLIC_CORE_SOLVER_DIRECT_HPP_
6 #define GKO_PUBLIC_CORE_SOLVER_DIRECT_HPP_
7 
8 
9 #include <ginkgo/core/base/lin_op.hpp>
10 #include <ginkgo/core/config/config.hpp>
11 #include <ginkgo/core/config/registry.hpp>
12 #include <ginkgo/core/factorization/factorization.hpp>
13 #include <ginkgo/core/solver/solver_base.hpp>
14 #include <ginkgo/core/solver/triangular.hpp>
15 
16 
17 namespace gko {
18 namespace experimental {
19 namespace solver {
20 
21 
32 template <typename ValueType, typename IndexType>
33 class Direct : public LinOp,
35  Direct<ValueType, IndexType>,
36  factorization::Factorization<ValueType, IndexType>>,
37  public Transposable {
38  GKO_ASSERT_SUPPORTED_VALUE_AND_INDEX_TYPE;
39 
40 public:
41  using value_type = ValueType;
42  using index_type = IndexType;
43  using factorization_type =
45  using transposed_type = Direct;
46 
47  std::unique_ptr<LinOp> transpose() const override;
48 
49  std::unique_ptr<LinOp> conj_transpose() const override;
50 
51  class Factory;
52 
53  struct parameters_type : enable_parameters_type<parameters_type, Factory> {
62 
64  std::shared_ptr<const LinOpFactory> GKO_DEFERRED_FACTORY_PARAMETER(
66  };
69 
83  static parameters_type parse(
84  const config::pnode& config, const config::registry& context,
85  const config::type_descriptor& td_for_child =
86  config::make_type_descriptor<ValueType, IndexType>());
87 
89  Direct(const Direct&);
90 
92  Direct(Direct&&);
93 
94  Direct& operator=(const Direct&);
95 
96  Direct& operator=(Direct&&);
97 
98 protected:
99  explicit Direct(std::shared_ptr<const Executor> exec);
100 
101  Direct(const Factory* factory, std::shared_ptr<const LinOp> system_matrix);
102 
103  void apply_impl(const AbstractMultiVector* b,
104  AbstractMultiVector* x) const override;
105 
106  void apply_impl(const AbstractMultiVector* alpha,
107  const AbstractMultiVector* b,
108  const AbstractMultiVector* beta,
109  AbstractMultiVector* x) const override;
110 
111 private:
114 
115  std::unique_ptr<lower_type> lower_solver_;
116  std::unique_ptr<upper_type> upper_solver_;
117 };
118 
119 
120 } // namespace solver
121 } // namespace experimental
122 
123 
124 namespace solver {
125 
126 
127 template <typename ValueType, typename IndexType>
129  gko::experimental::solver::Direct<ValueType, IndexType>> {
131  // number of vectors used by this workspace
132  static int num_vectors(const Solver&);
133  // number of arrays used by this workspace
134  static int num_arrays(const Solver&);
135  // array containing the num_vectors names for the workspace vectors
136  static std::vector<std::string> op_names(const Solver&);
137  // array containing the num_arrays names for the workspace vectors
138  static std::vector<std::string> array_names(const Solver&);
139  // array containing all varying scalar vectors (independent of problem size)
140  static std::vector<int> scalars(const Solver&);
141  // array containing all varying vectors (dependent on problem size)
142  static std::vector<int> vectors(const Solver&);
143 
144  // intermediate vector
145  constexpr static int intermediate = 0;
146 };
147 
148 
149 } // namespace solver
150 } // namespace gko
151 
152 #endif // GKO_PUBLIC_CORE_SOLVER_DIRECT_HPP_
gko::experimental::factorization::Factorization
Represents a generic factorization consisting of two triangular factors (upper and lower) and an opti...
Definition: factorization.hpp:76
gko::experimental::solver::Direct
A direct solver based on a factorization into lower and upper triangular factors (with an optional di...
Definition: direct.hpp:33
gko::config::pnode
pnode describes a tree of properties.
Definition: property_tree.hpp:28
gko::log::profile_event_category::solver
Solver events.
gko::LinOp
Definition: lin_op.hpp:163
gko::Transposable
Linear operators which support transposition should implement the Transposable interface.
Definition: lin_op.hpp:596
gko::size_type
std::size_t size_type
Integral type used for allocation quantities.
Definition: types.hpp:102
gko::experimental::solver::Direct::parameters_type::factorization
std::shared_ptr< const LinOpFactory > factorization
The factorization factory to use for generating the factors.
Definition: direct.hpp:65
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:469
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::solver::LowerTrs
LowerTrs is the triangular solver which solves the system L x = b, when L is a lower triangular matri...
Definition: triangular.hpp:65
gko::experimental::solver::Direct::parameters_type::num_rhs
gko::size_type num_rhs
Number of right hand sides.
Definition: direct.hpp:61
gko::experimental::solver::Direct::Factory
Definition: direct.hpp:67
gko
The Ginkgo namespace.
Definition: abstract_factory.hpp:19
gko::experimental::solver::Direct::Direct
Direct(const Direct &)
Creates a copy of the solver.
gko::experimental::solver::Direct::parameters_type
Definition: direct.hpp:53
GKO_ENABLE_LIN_OP_FACTORY
#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:1192
gko::solver::EnableSolverBase
A LinOp deriving from this CRTP class stores a system matrix.
Definition: solver_base.hpp:564
gko::config::registry
This class stores additional context for creating Ginkgo objects from configuration files.
Definition: registry.hpp:167
GKO_ENABLE_BUILD_METHOD
#define GKO_ENABLE_BUILD_METHOD(_factory_name)
Defines a build method for the factory, simplifying its construction by removing the repetitive typin...
Definition: abstract_factory.hpp:418
gko::experimental::solver::Direct::transpose
std::unique_ptr< LinOp > transpose() const override
Returns a LinOp representing the transpose of the Transposable object.
gko::AbstractMultiVector
Abstract interface class for (multi-)vector types.
Definition: multivector.hpp:81
gko::experimental::solver::Direct::parse
static parameters_type parse(const config::pnode &config, const config::registry &context, const config::type_descriptor &td_for_child=config::make_type_descriptor< ValueType, IndexType >())
Create the parameters from the property_tree.
gko::solver::workspace_traits
Traits class providing information on the type and location of workspace vectors inside a solver.
Definition: solver_base.hpp:258
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:235
gko::solver::UpperTrs
UpperTrs is the triangular solver which solves the system U x = b, when U is an upper triangular matr...
Definition: triangular.hpp:44
gko::experimental::solver::Direct::conj_transpose
std::unique_ptr< LinOp > conj_transpose() const override
Returns a LinOp representing the conjugate transpose of the Transposable object.