Ginkgo Generated from branch based on master. Ginkgo version 1.7.0
A numerical linear algebra library targeting many-core architectures
Loading...
Searching...
No Matches
direct.hpp
1/*******************************<GINKGO LICENSE>******************************
2Copyright (c) 2017-2023, the Ginkgo authors
3All rights reserved.
4
5Redistribution and use in source and binary forms, with or without
6modification, are permitted provided that the following conditions
7are met:
8
91. Redistributions of source code must retain the above copyright
10notice, this list of conditions and the following disclaimer.
11
122. Redistributions in binary form must reproduce the above copyright
13notice, this list of conditions and the following disclaimer in the
14documentation and/or other materials provided with the distribution.
15
163. Neither the name of the copyright holder nor the names of its
17contributors may be used to endorse or promote products derived from
18this software without specific prior written permission.
19
20THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
21IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
23PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31******************************<GINKGO LICENSE>*******************************/
32
33#ifndef GKO_PUBLIC_CORE_SOLVER_DIRECT_HPP_
34#define GKO_PUBLIC_CORE_SOLVER_DIRECT_HPP_
35
36
37#include <ginkgo/core/base/lin_op.hpp>
38#include <ginkgo/core/factorization/factorization.hpp>
39#include <ginkgo/core/solver/solver_base.hpp>
40#include <ginkgo/core/solver/triangular.hpp>
41
42
43namespace gko {
44namespace experimental {
45namespace solver {
46
47
58template <typename ValueType, typename IndexType>
59class Direct : public EnableLinOp<Direct<ValueType, IndexType>>,
61 Direct<ValueType, IndexType>,
62 factorization::Factorization<ValueType, IndexType>>,
63 public Transposable {
65
66public:
67 using value_type = ValueType;
68 using index_type = IndexType;
69 using factorization_type =
71 using transposed_type = Direct;
72
73 std::unique_ptr<LinOp> transpose() const override;
74
75 std::unique_ptr<LinOp> conj_transpose() const override;
76
77 class Factory;
78
79 struct parameters_type : enable_parameters_type<parameters_type, Factory> {
88
90 std::shared_ptr<const LinOpFactory> GKO_DEFERRED_FACTORY_PARAMETER(
92 };
95
97 Direct(const Direct&);
98
101
102 Direct& operator=(const Direct&);
103
104 Direct& operator=(Direct&&);
105
106protected:
107 explicit Direct(std::shared_ptr<const Executor> exec);
108
109 Direct(const Factory* factory, std::shared_ptr<const LinOp> system_matrix);
110
111 void apply_impl(const LinOp* b, LinOp* x) const override;
112
113 void apply_impl(const LinOp* alpha, const LinOp* b, const LinOp* beta,
114 LinOp* x) const override;
115
116private:
119
120 std::unique_ptr<lower_type> lower_solver_;
121 std::unique_ptr<upper_type> upper_solver_;
122};
123
124
125} // namespace solver
126} // namespace experimental
127
128
129namespace solver {
130
131
132template <typename ValueType, typename IndexType>
134 gko::experimental::solver::Direct<ValueType, IndexType>> {
136 // number of vectors used by this workspace
137 static int num_vectors(const Solver&);
138 // number of arrays used by this workspace
139 static int num_arrays(const Solver&);
140 // array containing the num_vectors names for the workspace vectors
141 static std::vector<std::string> op_names(const Solver&);
142 // array containing the num_arrays names for the workspace vectors
143 static std::vector<std::string> array_names(const Solver&);
144 // array containing all varying scalar vectors (independent of problem size)
145 static std::vector<int> scalars(const Solver&);
146 // array containing all varying vectors (dependent on problem size)
147 static std::vector<int> vectors(const Solver&);
148
149 // intermediate vector
150 constexpr static int intermediate = 0;
151};
152
153
154} // namespace solver
155} // namespace gko
156
157#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:908
This mixin inherits from (a subclass of) PolymorphicObject and provides a base implementation of a ne...
Definition polymorphic_object.hpp:691
Definition lin_op.hpp:146
Linear operators which support transposition should implement the Transposable interface.
Definition lin_op.hpp:462
The enable_parameters_type mixin is used to create a base implementation of the factory parameters st...
Definition abstract_factory.hpp:239
Represents a generic factorization consisting of two triangular factors (upper and lower) and an opti...
Definition factorization.hpp:104
A direct solver based on a factorization into lower and upper triangular factors (with an optional di...
Definition direct.hpp:63
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:570
LowerTrs is the triangular solver which solves the system L x = b, when L is a lower triangular matri...
Definition triangular.hpp:95
UpperTrs is the triangular solver which solves the system U x = b, when U is an upper triangular matr...
Definition triangular.hpp:245
#define GKO_FACTORY_PARAMETER_SCALAR(_name, _default)
Creates a scalar factory parameter in the factory parameters structure.
Definition abstract_factory.hpp:473
#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:422
#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:1046
The Ginkgo namespace.
Definition abstract_factory.hpp:48
constexpr T one()
Returns the multiplicative identity for T.
Definition math.hpp:803
std::size_t size_type
Integral type used for allocation quantities.
Definition types.hpp:120
std::shared_ptr< const LinOpFactory > factorization
The factorization factory to use for generating the factors.
Definition direct.hpp:91
gko::size_type num_rhs
Number of right hand sides.
Definition direct.hpp:87
Traits class providing information on the type and location of workspace vectors inside a solver.
Definition solver_base.hpp:267