26 template<
class T, u32 low_order, u32 high_order>
27 inline shammath::SymTensorCollection<T, low_order, high_order> offset_dM_mat_delta(
28 const shammath::SymTensorCollection<T, low_order, high_order> &dM,
29 const sycl::vec<T, 3> &offset) {
31 using namespace shammath;
33 static constexpr T inv_factorial_0 = 1. / 1;
34 static constexpr T inv_factorial_1 = 1. / 1;
35 static constexpr T inv_factorial_2 = 1. / 2;
36 static constexpr T inv_factorial_3 = 1. / 6;
37 static constexpr T inv_factorial_4 = 1. / 24;
38 static constexpr T inv_factorial_5 = 1. / 120;
40 if constexpr (low_order == 0 && high_order == 5) {
42 SymTensorCollection<T, 0, 5> h = SymTensorCollection<T, 0, 5>::from_vec(offset);
58 shammath::SymTensorCollection<T, 0, 5> dM_ret;
60 auto &dM_ret_0 = dM_ret.t0;
61 auto &dM_ret_1 = dM_ret.t1;
62 auto &dM_ret_2 = dM_ret.t2;
63 auto &dM_ret_3 = dM_ret.t3;
64 auto &dM_ret_4 = dM_ret.t4;
65 auto &dM_ret_5 = dM_ret.t5;
69 dM_ret_0 = inv_factorial_0 * h_0 * dM_0 + inv_factorial_1 * h_1 * dM_1
70 + inv_factorial_2 * h_2 * dM_2 + inv_factorial_3 * h_3 * dM_3
71 + inv_factorial_4 * h_4 * dM_4 + inv_factorial_5 * h_5 * dM_5;
73 dM_ret_1 = inv_factorial_0 * h_0 * dM_1 + inv_factorial_1 * h_1 * dM_2
74 + inv_factorial_2 * h_2 * dM_3 + inv_factorial_3 * h_3 * dM_4
75 + inv_factorial_4 * h_4 * dM_5;
77 dM_ret_2 = inv_factorial_0 * h_0 * dM_2 + inv_factorial_1 * h_1 * dM_3
78 + inv_factorial_2 * h_2 * dM_4 + inv_factorial_3 * h_3 * dM_5;
80 dM_ret_3 = inv_factorial_0 * h_0 * dM_3 + inv_factorial_1 * h_1 * dM_4
81 + inv_factorial_2 * h_2 * dM_5;
83 dM_ret_4 = inv_factorial_0 * h_0 * dM_4 + inv_factorial_1 * h_1 * dM_5;
84 dM_ret_5 = inv_factorial_0 * h_0 * dM_5;
87 }
else if constexpr (low_order == 1 && high_order == 5) {
89 SymTensorCollection<T, 0, 5> h = SymTensorCollection<T, 0, 5>::from_vec(offset);
104 shammath::SymTensorCollection<T, 1, 5> dM_ret;
106 auto &dM_ret_1 = dM_ret.t1;
107 auto &dM_ret_2 = dM_ret.t2;
108 auto &dM_ret_3 = dM_ret.t3;
109 auto &dM_ret_4 = dM_ret.t4;
110 auto &dM_ret_5 = dM_ret.t5;
114 dM_ret_1 = inv_factorial_0 * h_0 * dM_1 + inv_factorial_1 * h_1 * dM_2
115 + inv_factorial_2 * h_2 * dM_3 + inv_factorial_3 * h_3 * dM_4
116 + inv_factorial_4 * h_4 * dM_5;
118 dM_ret_2 = inv_factorial_0 * h_0 * dM_2 + inv_factorial_1 * h_1 * dM_3
119 + inv_factorial_2 * h_2 * dM_4 + inv_factorial_3 * h_3 * dM_5;
121 dM_ret_3 = inv_factorial_0 * h_0 * dM_3 + inv_factorial_1 * h_1 * dM_4
122 + inv_factorial_2 * h_2 * dM_5;
124 dM_ret_4 = inv_factorial_0 * h_0 * dM_4 + inv_factorial_1 * h_1 * dM_5;
125 dM_ret_5 = inv_factorial_0 * h_0 * dM_5;
128 }
else if constexpr (low_order == 1 && high_order == 4) {
130 SymTensorCollection<T, 0, 4> h = SymTensorCollection<T, 0, 4>::from_vec(offset);
143 shammath::SymTensorCollection<T, 1, 4> dM_ret;
145 auto &dM_ret_1 = dM_ret.t1;
146 auto &dM_ret_2 = dM_ret.t2;
147 auto &dM_ret_3 = dM_ret.t3;
148 auto &dM_ret_4 = dM_ret.t4;
152 dM_ret_1 = inv_factorial_0 * h_0 * dM_1 + inv_factorial_1 * h_1 * dM_2
153 + inv_factorial_2 * h_2 * dM_3 + inv_factorial_3 * h_3 * dM_4;
155 dM_ret_2 = inv_factorial_0 * h_0 * dM_2 + inv_factorial_1 * h_1 * dM_3
156 + inv_factorial_2 * h_2 * dM_4;
158 dM_ret_3 = inv_factorial_0 * h_0 * dM_3 + inv_factorial_1 * h_1 * dM_4;
160 dM_ret_4 = inv_factorial_0 * h_0 * dM_4;
163 }
else if constexpr (low_order == 1 && high_order == 3) {
165 SymTensorCollection<T, 0, 3> h = SymTensorCollection<T, 0, 3>::from_vec(offset);
176 shammath::SymTensorCollection<T, 1, 3> dM_ret;
178 auto &dM_ret_1 = dM_ret.t1;
179 auto &dM_ret_2 = dM_ret.t2;
180 auto &dM_ret_3 = dM_ret.t3;
184 dM_ret_1 = inv_factorial_0 * h_0 * dM_1 + inv_factorial_1 * h_1 * dM_2
185 + inv_factorial_2 * h_2 * dM_3;
187 dM_ret_2 = inv_factorial_0 * h_0 * dM_2 + inv_factorial_1 * h_1 * dM_3;
189 dM_ret_3 = inv_factorial_0 * h_0 * dM_3;
192 }
else if constexpr (low_order == 1 && high_order == 2) {
194 SymTensorCollection<T, 0, 1> h = SymTensorCollection<T, 0, 1>::from_vec(offset);
202 shammath::SymTensorCollection<T, 1, 2> dM_ret;
204 auto &dM_ret_1 = dM_ret.t1;
205 auto &dM_ret_2 = dM_ret.t2;
209 dM_ret_1 = inv_factorial_0 * h_0 * dM_1 + inv_factorial_1 * h_1 * dM_2;
211 dM_ret_2 = inv_factorial_0 * h_0 * dM_2;
214 }
else if constexpr (low_order == 1 && high_order == 1) {
219 shammath::SymTensorCollection<T, 1, 1> dM_ret;
221 auto &dM_ret_1 = dM_ret.t1;
225 dM_ret_1 = inv_factorial_0 * h_0 * dM_1;
234 template<
class T, u32 low_order, u32 high_order>
235 inline shammath::SymTensorCollection<T, low_order, high_order> offset_dM_mat(
236 const shammath::SymTensorCollection<T, low_order, high_order> &dM,
237 const sycl::vec<T, 3> &from,
238 const sycl::vec<T, 3> &to) {
239 return offset_dM_mat_delta(dM, to - from);
constexpr bool always_false_v
Helper variable template that is always false. Especially useful to perform static asserts based on t...