14#include "splines_linear_problem.hpp"
15#include "splines_linear_problem_2x2_blocks.hpp"
16#include "splines_linear_problem_3x3_blocks.hpp"
17#include "splines_linear_problem_band.hpp"
18#include "splines_linear_problem_dense.hpp"
19#include "splines_linear_problem_pds_band.hpp"
20#include "splines_linear_problem_pds_tridiag.hpp"
21#include "splines_linear_problem_sparse.hpp"
23namespace ddc::detail {
26
27
28class SplinesLinearProblemMaker
32
33
34
35
36
37
38
39 template <
typename ExecSpace>
40 static std::unique_ptr<SplinesLinearProblem<ExecSpace>> make_new_dense(
int const n)
42 return std::make_unique<SplinesLinearProblemDense<ExecSpace>>(n);
46
47
48
49
50
51
52
53
54
55
56 template <
typename ExecSpace>
57 static std::unique_ptr<SplinesLinearProblem<ExecSpace>> make_new_band(
63 if (kl == ku && kl == 1 && pds) {
64 return std::make_unique<SplinesLinearProblemPDSTridiag<ExecSpace>>(n);
67 if (kl == ku && pds) {
68 return std::make_unique<SplinesLinearProblemPDSBand<ExecSpace>>(n, kl);
71 if (2 * kl + ku + 1 >= n) {
72 return std::make_unique<SplinesLinearProblemDense<ExecSpace>>(n);
75 return std::make_unique<SplinesLinearProblemBand<ExecSpace>>(n, kl, ku);
79
80
81
82
83
84
85
86
87
88
89
90
91
92 template <
typename ExecSpace>
93 static std::unique_ptr<SplinesLinearProblem<ExecSpace>>
94 make_new_block_matrix_with_band_main_block(
99 int const bottom_right_size,
100 int const top_left_size = 0)
102 int const main_size = n - top_left_size - bottom_right_size;
103 std::unique_ptr<SplinesLinearProblem<ExecSpace>> main_block
104 = make_new_band<ExecSpace>(main_size, kl, ku, pds);
105 if (top_left_size == 0) {
106 return std::make_unique<
107 SplinesLinearProblem2x2Blocks<ExecSpace>>(n, std::move(main_block));
109 return std::make_unique<
110 SplinesLinearProblem3x3Blocks<ExecSpace>>(n, top_left_size, std::move(main_block));
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129 template <
typename ExecSpace>
130 static std::unique_ptr<SplinesLinearProblem<ExecSpace>> make_new_periodic_band_matrix(
138 int const bottom_size = std::max(kl, ku);
139 int const top_size = n - bottom_size;
141 if (bottom_size * (n + top_size) + (2 * kl + ku + 1) * top_size >= n * n) {
142 return std::make_unique<SplinesLinearProblemDense<ExecSpace>>(n);
145 return make_new_block_matrix_with_band_main_block<ExecSpace>(n, kl, ku, pds, bottom_size);
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164 template <
typename ExecSpace>
165 static std::unique_ptr<SplinesLinearProblem<ExecSpace>> make_new_sparse(
167 std::optional<std::size_t> cols_per_chunk = std::nullopt,
168 std::optional<
unsigned int> preconditioner_max_block_size = std::nullopt)
170 return std::make_unique<SplinesLinearProblemSparse<
171 ExecSpace>>(n, cols_per_chunk, preconditioner_max_block_size);
The top-level namespace of DDC.