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