Ginkgo Generated from develop branch based on develop. Ginkgo version 1.8.0
A numerical linear algebra library targeting many-core architectures
Loading...
Searching...
No Matches
direct.hpp
1// SPDX-FileCopyrightText: 2017 - 2024 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/factorization/factorization.hpp>
11#include <ginkgo/core/solver/solver_base.hpp>
12#include <ginkgo/core/solver/triangular.hpp>
13
14
15namespace gko {
16namespace experimental {
17namespace solver {
18
19
30template <typename ValueType, typename IndexType>
31class Direct : public EnableLinOp<Direct<ValueType, IndexType>>,
33 Direct<ValueType, IndexType>,
34 factorization::Factorization<ValueType, IndexType>>,
35 public Transposable {
37
38public:
39 using value_type = ValueType;
40 using index_type = IndexType;
41 using factorization_type =
43 using transposed_type = Direct;
44
45 std::unique_ptr<LinOp> transpose() const override;
46
47 std::unique_ptr<LinOp> conj_transpose() const override;
48
49 class Factory;
50
51 struct parameters_type : enable_parameters_type<parameters_type, Factory> {
60
62 std::shared_ptr<const LinOpFactory> GKO_DEFERRED_FACTORY_PARAMETER(
64 };
67
69 Direct(const Direct&);
70
73
74 Direct& operator=(const Direct&);
75
76 Direct& operator=(Direct&&);
77
78protected:
79 explicit Direct(std::shared_ptr<const Executor> exec);
80
81 Direct(const Factory* factory, std::shared_ptr<const LinOp> system_matrix);
82
83 void apply_impl(const LinOp* b, LinOp* x) const override;
84
85 void apply_impl(const LinOp* alpha, const LinOp* b, const LinOp* beta,
86 LinOp* x) const override;
87
88private:
91
92 std::unique_ptr<lower_type> lower_solver_;
93 std::unique_ptr<upper_type> upper_solver_;
94};
95
96
97} // namespace solver
98} // namespace experimental
99
100
101namespace solver {
102
103
104template <typename ValueType, typename IndexType>
106 gko::experimental::solver::Direct<ValueType, IndexType>> {
108 // number of vectors used by this workspace
109 static int num_vectors(const Solver&);
110 // number of arrays used by this workspace
111 static int num_arrays(const Solver&);
112 // array containing the num_vectors names for the workspace vectors
113 static std::vector<std::string> op_names(const Solver&);
114 // array containing the num_arrays names for the workspace vectors
115 static std::vector<std::string> array_names(const Solver&);
116 // array containing all varying scalar vectors (independent of problem size)
117 static std::vector<int> scalars(const Solver&);
118 // array containing all varying vectors (dependent on problem size)
119 static std::vector<int> vectors(const Solver&);
120
121 // intermediate vector
122 constexpr static int intermediate = 0;
123};
124
125
126} // namespace solver
127} // namespace gko
128
129#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:880
This mixin inherits from (a subclass of) PolymorphicObject and provides a base implementation of a ne...
Definition polymorphic_object.hpp:663
Definition lin_op.hpp:118
Linear operators which support transposition should implement the Transposable interface.
Definition lin_op.hpp:434
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:35
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.
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:542
LowerTrs is the triangular solver which solves the system L x = b, when L is a lower triangular matri...
Definition triangular.hpp:67
UpperTrs is the triangular solver which solves the system U x = b, when U is an upper triangular matr...
Definition triangular.hpp:217
#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:1018
The Ginkgo namespace.
Definition abstract_factory.hpp:20
constexpr T one()
Returns the multiplicative identity for T.
Definition math.hpp:775
std::size_t size_type
Integral type used for allocation quantities.
Definition types.hpp:92
std::shared_ptr< const LinOpFactory > factorization
The factorization factory to use for generating the factors.
Definition direct.hpp:63
gko::size_type num_rhs
Number of right hand sides.
Definition direct.hpp:59
Traits class providing information on the type and location of workspace vectors inside a solver.
Definition solver_base.hpp:239