ginkgo/core/factorization/factorization.hpp Source File

ginkgo/core/factorization/factorization.hpp Source File#

Reference API: ginkgo/core/factorization/factorization.hpp Source File
Reference API
factorization.hpp
1// SPDX-FileCopyrightText: 2017 - 2025 The Ginkgo authors
2//
3// SPDX-License-Identifier: BSD-3-Clause
4
5#ifndef GKO_PUBLIC_CORE_FACTORIZATION_FACTORIZATION_HPP_
6#define GKO_PUBLIC_CORE_FACTORIZATION_FACTORIZATION_HPP_
7
8
9#include <ginkgo/core/base/composition.hpp>
10#include <ginkgo/core/base/lin_op.hpp>
11#include <ginkgo/core/base/types.hpp>
12#include <ginkgo/core/matrix/csr.hpp>
13#include <ginkgo/core/matrix/diagonal.hpp>
14
15
16namespace gko {
17namespace experimental {
18namespace factorization {
19
20
25enum class storage_type {
27 empty,
32 composition,
33 /*
34 * The two factors are stored as a single matrix containing L + U - I, where
35 * L has an implicit unit diagonal.
36 */
37 combined_lu,
38 /*
39 * The factorization L * D * U is stored as L + D + U - 2I, where
40 * L and U have implicit unit diagonals.
41 */
42 combined_ldu,
47 symm_composition,
48 /*
49 * The factorization L * L^H is symmetric and stored as a single matrix
50 * containing L + L^H - diag(L).
51 */
52 symm_combined_cholesky,
53 /*
54 * The factorization is symmetric and stored as a single matrix containing
55 * L + D + L^H - 2 * diag(L), where L and L^H have an implicit unit
56 * diagonal.
57 */
58 symm_combined_ldl,
59};
60
61
77template <typename ValueType, typename IndexType>
78class Factorization : public EnableLinOp<Factorization<ValueType, IndexType>> {
80
81public:
82 using value_type = ValueType;
83 using index_type = IndexType;
87
96 std::unique_ptr<Factorization> unpack() const;
97
99 storage_type get_storage_type() const;
100
105 std::shared_ptr<const matrix_type> get_lower_factor() const;
106
111 std::shared_ptr<const diag_type> get_diagonal() const;
112
117 std::shared_ptr<const matrix_type> get_upper_factor() const;
118
123 std::shared_ptr<const matrix_type> get_combined() const;
124
127
130
131 Factorization& operator=(const Factorization&);
132
133 Factorization& operator=(Factorization&&);
134
144 static std::unique_ptr<Factorization> create_from_composition(
145 std::unique_ptr<composition_type> composition);
146
157 static std::unique_ptr<Factorization> create_from_symm_composition(
158 std::unique_ptr<composition_type> composition);
159
171 static std::unique_ptr<Factorization> create_from_combined_lu(
172 std::unique_ptr<matrix_type> matrix);
173
174 static std::unique_ptr<Factorization> create_from_combined_ldu(
175 std::unique_ptr<matrix_type> matrix);
176
177 static std::unique_ptr<Factorization> create_from_combined_cholesky(
178 std::unique_ptr<matrix_type> matrix);
179
180 static std::unique_ptr<Factorization> create_from_combined_ldl(
181 std::unique_ptr<matrix_type> matrix);
182
183protected:
184 explicit Factorization(std::shared_ptr<const Executor> exec);
185
186 Factorization(std::unique_ptr<Composition<ValueType>> factors,
187 storage_type type);
188
189 void apply_impl(const LinOp* b, LinOp* x) const override;
190
191 void apply_impl(const LinOp* alpha, const LinOp* b, const LinOp* beta,
192 LinOp* x) const override;
193
194private:
195 storage_type storage_type_;
196 std::unique_ptr<Composition<ValueType>> factors_;
197};
198
199
200} // namespace factorization
201} // namespace experimental
202} // namespace gko
203
204#endif // GKO_PUBLIC_CORE_FACTORIZATION_FACTORIZATION_HPP_
Definition composition.hpp:41
Definition lin_op.hpp:878
Definition polymorphic_object.hpp:668
Definition lin_op.hpp:117
std::shared_ptr< const matrix_type > get_lower_factor() const
std::shared_ptr< const diag_type > get_diagonal() const
static std::unique_ptr< Factorization > create_from_composition(std::unique_ptr< composition_type > composition)
std::shared_ptr< const matrix_type > get_upper_factor() const
static std::unique_ptr< Factorization > create_from_symm_composition(std::unique_ptr< composition_type > composition)
std::shared_ptr< const matrix_type > get_combined() const
std::unique_ptr< Factorization > unpack() const
static std::unique_ptr< Factorization > create_from_combined_lu(std::unique_ptr< matrix_type > matrix)
Definition csr.hpp:123
Definition diagonal.hpp:52
The Ginkgo namespace.
Definition abstract_factory.hpp:20