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
direct.hpp
1// SPDX-FileCopyrightText: 2017 - 2025 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
17namespace gko {
18namespace experimental {
19namespace solver {
20
21
32template <typename ValueType, typename IndexType>
33class Direct : public EnableLinOp<Direct<ValueType, IndexType>>,
35 Direct<ValueType, IndexType>,
36 factorization::Factorization<ValueType, IndexType>>,
37 public Transposable {
39 GKO_ASSERT_SUPPORTED_VALUE_AND_INDEX_TYPE;
40
41public:
42 using value_type = ValueType;
43 using index_type = IndexType;
44 using factorization_type =
46 using transposed_type = Direct;
47
48 std::unique_ptr<LinOp> transpose() const override;
49
50 std::unique_ptr<LinOp> conj_transpose() const override;
51
52 class Factory;
53
54 struct parameters_type : enable_parameters_type<parameters_type, Factory> {
63
65 std::shared_ptr<const LinOpFactory> GKO_DEFERRED_FACTORY_PARAMETER(
67 };
68 GKO_ENABLE_LIN_OP_FACTORY(Direct, parameters, Factory);
70
85 const config::pnode& config, const config::registry& context,
86 const config::type_descriptor& td_for_child =
87 config::make_type_descriptor<ValueType, IndexType>());
88
90 Direct(const Direct&);
91
94
95 Direct& operator=(const Direct&);
96
97 Direct& operator=(Direct&&);
98
99protected:
100 explicit Direct(std::shared_ptr<const Executor> exec);
101
102 Direct(const Factory* factory, std::shared_ptr<const LinOp> system_matrix);
103
104 void apply_impl(const LinOp* b, LinOp* x) const override;
105
106 void apply_impl(const LinOp* alpha, const LinOp* b, const LinOp* beta,
107 LinOp* x) const override;
108
109private:
112
113 std::unique_ptr<lower_type> lower_solver_;
114 std::unique_ptr<upper_type> upper_solver_;
115};
116
117
118} // namespace solver
119} // namespace experimental
120
121
122namespace solver {
123
124
125template <typename ValueType, typename IndexType>
127 gko::experimental::solver::Direct<ValueType, IndexType>> {
129 // number of vectors used by this workspace
130 static int num_vectors(const Solver&);
131 // number of arrays used by this workspace
132 static int num_arrays(const Solver&);
133 // array containing the num_vectors names for the workspace vectors
134 static std::vector<std::string> op_names(const Solver&);
135 // array containing the num_arrays names for the workspace vectors
136 static std::vector<std::string> array_names(const Solver&);
137 // array containing all varying scalar vectors (independent of problem size)
138 static std::vector<int> scalars(const Solver&);
139 // array containing all varying vectors (dependent on problem size)
140 static std::vector<int> vectors(const Solver&);
141
142 // intermediate vector
143 constexpr static int intermediate = 0;
144};
145
146
147} // namespace solver
148} // namespace gko
149
150#endif // GKO_PUBLIC_CORE_SOLVER_DIRECT_HPP_
The EnableLinOp mixin can be used to provide sensible default implementations of the majority of the ...
Definition lin_op.hpp:879
This mixin inherits from (a subclass of) PolymorphicObject and provides a base implementation of a ne...
Definition polymorphic_object.hpp:668
Definition lin_op.hpp:117
Linear operators which support transposition should implement the Transposable interface.
Definition lin_op.hpp:433
pnode describes a tree of properties.
Definition property_tree.hpp:28
This class stores additional context for creating Ginkgo objects from configuration files.
Definition registry.hpp:167
This class describes the value and index types to be used when building a Ginkgo type from a configur...
Definition type_descriptor.hpp:39
The enable_parameters_type mixin is used to create a base implementation of the factory parameters st...
Definition abstract_factory.hpp:211
Represents a generic factorization consisting of two triangular factors (upper and lower) and an opti...
Definition factorization.hpp:76
A direct solver based on a factorization into lower and upper triangular factors (with an optional di...
Definition direct.hpp:37
Direct(const Direct &)
Creates a copy of the solver.
std::unique_ptr< LinOp > conj_transpose() const override
Returns a LinOp representing the conjugate transpose of the Transposable object.
std::unique_ptr< LinOp > transpose() const override
Returns a LinOp representing the transpose of the Transposable object.
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.
Direct(Direct &&)
Moves from the given solver, leaving it empty.
A LinOp deriving from this CRTP class stores a system matrix.
Definition solver_base.hpp:556
LowerTrs is the triangular solver which solves the system L x = b, when L is a lower triangular matri...
Definition triangular.hpp:68
UpperTrs is the triangular solver which solves the system U x = b, when U is an upper triangular matr...
Definition triangular.hpp:237
#define GKO_FACTORY_PARAMETER_SCALAR(_name, _default)
Creates a scalar factory parameter in the factory parameters structure.
Definition abstract_factory.hpp:445
#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:394
#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:1017
The ginkgo Solve namespace.
Definition bicg.hpp:28
The Ginkgo namespace.
Definition abstract_factory.hpp:20
std::size_t size_type
Integral type used for allocation quantities.
Definition types.hpp:90
std::shared_ptr< const LinOpFactory > factorization
The factorization factory to use for generating the factors.
Definition direct.hpp:66
gko::size_type num_rhs
Number of right hand sides.
Definition direct.hpp:62
Traits class providing information on the type and location of workspace vectors inside a solver.
Definition solver_base.hpp:238