Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
sphkernels.hpp
Go to the documentation of this file.
1// -------------------------------------------------------//
2//
3// SHAMROCK code for hydrodynamics
4// Copyright (c) 2021-2026 Timothée David--Cléris <tim.shamrock@proton.me>
5// SPDX-License-Identifier: CeCILL Free Software License Agreement v2.1
6// Shamrock is licensed under the CeCILL 2.1 License, see LICENSE for more information
7//
8// -------------------------------------------------------//
9
10#pragma once
11
19//%Impl status : Good
20
23#include "shambackends/math.hpp"
25
26namespace shammath::details {
27
28 template<class Tscal>
30 public:
31 inline static constexpr Tscal Rkern = 2;
33 inline static constexpr Tscal hfactd = 1.2;
34
36 inline static constexpr Tscal norm_1d = 2. / 3.;
38 inline static constexpr Tscal norm_2d = 10. / (7. * shambase::constants::pi<Tscal>);
40 inline static constexpr Tscal norm_3d = 1 / shambase::constants::pi<Tscal>;
41
42 inline static Tscal f(Tscal q) {
43
44 Tscal t1 = 2 - q;
45 Tscal t2 = 1 - q;
46
47 t1 = t1 * t1 * t1;
48 t2 = t2 * t2 * t2;
49
50 constexpr Tscal div1_4 = (1. / 4.);
51 t1 *= div1_4;
52 t2 *= -1;
53
54 if (q < 1) {
55 return t1 + t2;
56 } else if (q < 2) {
57 return t1;
58 } else
59 return 0;
60 }
61
62 inline static Tscal df(Tscal q) {
63
64 constexpr Tscal div9_4 = (9. / 4.);
65 constexpr Tscal div3_4 = (3. / 4.);
66
67 if (q < 1) {
68 return -3 * q + div9_4 * q * q;
69 } else if (q < 2) {
70 return -3 + 3 * q - div3_4 * q * q;
71 } else
72 return 0;
73 }
74
75 inline static Tscal ddf(Tscal q) {
76 if (q < 1) {
77 return (9.0 / 2.0) * q - 3;
78 } else if (q < 2) {
79 return 3 - (3.0 / 2.0) * q;
80 } else
81 return 0;
82 }
83
84 inline static Tscal phi_tilde_3d(Tscal q) {
85 Tscal t1 = sham::pow_constexpr<2>(q);
86 Tscal t2 = sham::pow_constexpr<3>(q);
87 Tscal t3 = sham::pow_constexpr<4>(q);
88 Tscal t4 = sham::pow_constexpr<5>(q);
89 Tscal t5 = sham::pow_constexpr<6>(q);
90 if (q < 1) {
91 return (1.0 / 30.0) * shambase::constants::pi<Tscal>
92 * (t1 * (3 * t2 - 9 * t1 + 20) - 42);
93 } else if (q < 2) {
94 return (1.0 / 30.0) * shambase::constants::pi<Tscal>
95 * (-t5 + 9 * t4 - 30 * t3 + 40 * t2 - 48 * q + 2) / q;
96 } else
97 return -shambase::constants::pi<Tscal> / q;
98 }
99
100 inline static Tscal phi_tilde_3d_prime(Tscal q) {
101 Tscal t1 = sham::pow_constexpr<2>(q);
102 Tscal t2 = sham::pow_constexpr<3>(q);
103 Tscal t3 = sham::pow_constexpr<4>(q);
104 Tscal t4 = sham::pow_constexpr<5>(q);
105 Tscal t5 = sham::pow_constexpr<6>(q);
106 if (q < 1) {
107 return (1.0 / 30.0) * shambase::constants::pi<Tscal>
108 * (t1 * (9 * t1 - 18 * q) + 2 * q * (3 * t2 - 9 * t1 + 20));
109 } else if (q < 2) {
110 return (1.0 / 30.0) * shambase::constants::pi<Tscal>
111 * (-6 * t4 + 45 * t3 - 120 * t2 + 120 * t1 - 48) / q
112 - (1.0 / 30.0) * shambase::constants::pi<Tscal>
113 * (-t5 + 9 * t4 - 30 * t3 + 40 * t2 - 48 * q + 2) / t1;
114 } else
115 return shambase::constants::pi<Tscal> / t1;
116 }
117 };
118
119 template<class Tscal>
121 public:
122 inline static constexpr Tscal Rkern = 5. / 2.;
124 inline static constexpr Tscal hfactd = 1.2;
125
127 inline static constexpr Tscal norm_1d = 1. / 24.;
129 inline static constexpr Tscal norm_2d = 96. / (1199 * shambase::constants::pi<Tscal>);
131 inline static constexpr Tscal norm_3d = 1 / (20 * shambase::constants::pi<Tscal>);
132
133 inline static Tscal f(Tscal q) {
134
135 constexpr Tscal div5_2 = (5. / 2.);
136 constexpr Tscal div3_2 = (3. / 2.);
137 constexpr Tscal div1_2 = (1. / 2.);
138
139 Tscal t1 = div5_2 - q;
140 Tscal t2 = div3_2 - q;
141 Tscal t3 = div1_2 - q;
142
143 Tscal t1_2 = t1 * t1;
144 Tscal t2_2 = t2 * t2;
145 Tscal t3_2 = t3 * t3;
146
147 t1 = t1_2 * t1_2;
148 t2 = t2_2 * t2_2;
149 t3 = t3_2 * t3_2;
150
151 t1 *= 1;
152 t2 *= -5;
153 t3 *= 10;
154
155 if (q < div1_2) {
156 return t1 + t2 + t3;
157 } else if (q < div3_2) {
158 return t1 + t2;
159 } else if (q < div5_2) {
160 return t1;
161 } else
162 return 0;
163 }
164
165 inline static Tscal df(Tscal q) {
166
167 constexpr Tscal div5_2 = (5. / 2.);
168 constexpr Tscal div3_2 = (3. / 2.);
169 constexpr Tscal div1_2 = (1. / 2.);
170
171 Tscal t1 = div5_2 - q;
172 Tscal t2 = div3_2 - q;
173 Tscal t3 = div1_2 - q;
174
175 Tscal t1_2 = t1 * t1;
176 Tscal t2_2 = t2 * t2;
177 Tscal t3_2 = t3 * t3;
178
179 t1 = t1 * t1_2;
180 t2 = t2 * t2_2;
181 t3 = t3 * t3_2;
182
183 t1 *= (1) * (-4);
184 t2 *= (-5) * (-4);
185 t3 *= (10) * (-4);
186
187 if (q < div1_2) {
188 return t1 + t2 + t3;
189 } else if (q < div3_2) {
190 return t1 + t2;
191 } else if (q < div5_2) {
192 return t1;
193 } else
194 return 0;
195 }
196
197 inline static Tscal ddf(Tscal q) {
198 Tscal t1 = sham::pow_constexpr<2>(1.0 / 2.0 - q);
199 Tscal t2 = sham::pow_constexpr<2>(3.0 / 2.0 - q);
200 Tscal t3 = sham::pow_constexpr<2>(5.0 / 2.0 - q);
201 if (q < 1.0 / 2.0) {
202 return 120 * t1 - 60 * t2 + 12 * t3;
203 } else if (q < 3.0 / 2.0) {
204 return -60 * t2 + 12 * t3;
205 } else if (q < 5.0 / 2.0) {
206 return 12 * t3;
207 } else
208 return 0;
209 }
210
211 inline static Tscal phi_tilde_3d(Tscal q) {
212 Tscal t1 = sham::pow_constexpr<2>(q);
213 Tscal t2 = sham::pow_constexpr<3>(q);
214 Tscal t3 = sham::pow_constexpr<4>(q);
215 Tscal t4 = sham::pow_constexpr<5>(q);
216 Tscal t5 = sham::pow_constexpr<6>(q);
217 Tscal t6 = sham::pow_constexpr<7>(q);
218 if (q < 1.0 / 2.0) {
219 return (1.0 / 336.0) * shambase::constants::pi<Tscal>
220 * (192 * t5 - 1008 * t3 + 3220 * t1 - 8393);
221 } else if (q < 3.0 / 2.0) {
222 return (1.0 / 336.0) * shambase::constants::pi<Tscal>
223 * (-128 * t6 + 896 * t5 - 2016 * t4 + 560 * t3 + 3080 * t2 - 8386 * q - 1)
224 / q;
225 } else if (q < 5.0 / 2.0) {
226 return (1.0 / 672.0) * shambase::constants::pi<Tscal>
227 * (64 * t6 - 896 * t5 + 5040 * t4 - 14000 * t3 + 17500 * t2 - 21875 * q
228 + 2185)
229 / q;
230 } else
231 return -20 * shambase::constants::pi<Tscal> / q;
232 }
233
234 inline static Tscal phi_tilde_3d_prime(Tscal q) {
235 Tscal t1 = sham::pow_constexpr<2>(q);
236 Tscal t2 = sham::pow_constexpr<3>(q);
237 Tscal t3 = sham::pow_constexpr<4>(q);
238 Tscal t4 = sham::pow_constexpr<5>(q);
239 Tscal t5 = sham::pow_constexpr<6>(q);
240 Tscal t6 = sham::pow_constexpr<7>(q);
241 if (q < 1.0 / 2.0) {
242 return (1.0 / 336.0) * shambase::constants::pi<Tscal>
243 * (1152 * t4 - 4032 * t2 + 6440 * q);
244 } else if (q < 3.0 / 2.0) {
245 return (1.0 / 336.0) * shambase::constants::pi<Tscal>
246 * (-896 * t5 + 5376 * t4 - 10080 * t3 + 2240 * t2 + 9240 * t1 - 8386) / q
247 - (1.0 / 336.0) * shambase::constants::pi<Tscal>
248 * (-128 * t6 + 896 * t5 - 2016 * t4 + 560 * t3 + 3080 * t2 - 8386 * q
249 - 1)
250 / t1;
251 } else if (q < 5.0 / 2.0) {
252 return (1.0 / 672.0) * shambase::constants::pi<Tscal>
253 * (448 * t5 - 5376 * t4 + 25200 * t3 - 56000 * t2 + 52500 * t1 - 21875)
254 / q
255 - (1.0 / 672.0) * shambase::constants::pi<Tscal>
256 * (64 * t6 - 896 * t5 + 5040 * t4 - 14000 * t3 + 17500 * t2 - 21875 * q
257 + 2185)
258 / t1;
259 } else
260 return 20 * shambase::constants::pi<Tscal> / t1;
261 }
262 };
263
264 template<class Tscal>
266 public:
267 inline static constexpr Tscal Rkern = 3;
269 inline static constexpr Tscal hfactd = 1.0;
270
272 inline static constexpr Tscal norm_1d = 1. / 120.;
274 inline static constexpr Tscal norm_2d = 7. / (478 * shambase::constants::pi<Tscal>);
276 inline static constexpr Tscal norm_3d = 1 / (120 * shambase::constants::pi<Tscal>);
277
278 inline static Tscal f(Tscal q) {
279
280 Tscal t1 = 3 - q;
281 Tscal t2 = 2 - q;
282 Tscal t3 = 1 - q;
283
284 Tscal t1_2 = t1 * t1;
285 Tscal t2_2 = t2 * t2;
286 Tscal t3_2 = t3 * t3;
287
288 t1 = t1 * t1_2 * t1_2;
289 t2 = t2 * t2_2 * t2_2;
290 t3 = t3 * t3_2 * t3_2;
291
292 t1 *= 1;
293 t2 *= -6;
294 t3 *= 15;
295
296 if (q < 1.) {
297 return t1 + t2 + t3;
298 } else if (q < 2.) {
299 return t1 + t2;
300 } else if (q < 3.) {
301 return t1;
302 } else
303 return 0;
304 }
305
306 inline static Tscal df(Tscal q) {
307
308 Tscal t1 = 3 - q;
309 Tscal t2 = 2 - q;
310 Tscal t3 = 1 - q;
311
312 Tscal t1_2 = t1 * t1;
313 Tscal t2_2 = t2 * t2;
314 Tscal t3_2 = t3 * t3;
315
316 t1 = t1_2 * t1_2;
317 t2 = t2_2 * t2_2;
318 t3 = t3_2 * t3_2;
319
320 t1 *= (1) * (-5);
321 t2 *= (-6) * (-5);
322 t3 *= (15) * (-5);
323
324 if (q < 1.) {
325 return t1 + t2 + t3;
326 } else if (q < 2.) {
327 return t1 + t2;
328 } else if (q < 3.) {
329 return t1;
330 } else
331 return 0;
332 }
333
334 inline static Tscal ddf(Tscal q) {
335 Tscal t1 = sham::pow_constexpr<3>(1 - q);
336 Tscal t2 = sham::pow_constexpr<3>(2 - q);
337 Tscal t3 = sham::pow_constexpr<3>(3 - q);
338 if (q < 1) {
339 return 300 * t1 - 120 * t2 + 20 * t3;
340 } else if (q < 2) {
341 return -120 * t2 + 20 * t3;
342 } else if (q < 3) {
343 return 20 * t3;
344 } else
345 return 0;
346 }
347
348 inline static Tscal phi_tilde_3d(Tscal q) {
349 Tscal t1 = sham::pow_constexpr<2>(q);
350 Tscal t2 = sham::pow_constexpr<3>(q);
351 Tscal t3 = sham::pow_constexpr<4>(q);
352 Tscal t4 = sham::pow_constexpr<5>(q);
353 Tscal t5 = sham::pow_constexpr<6>(q);
354 Tscal t6 = sham::pow_constexpr<7>(q);
355 Tscal t7 = sham::pow_constexpr<8>(q);
356 if (q < 1) {
357 return (1.0 / 7.0) * shambase::constants::pi<Tscal>
358 * (-5 * t6 + 20 * t5 - 84 * t3 + 308 * t1 - 956);
359 } else if (q < 2) {
360 return (1.0 / 14.0) * shambase::constants::pi<Tscal>
361 * (5 * t7 - 60 * t6 + 280 * t5 - 588 * t4 + 350 * t3 + 476 * t2 - 1892 * q
362 - 5)
363 / q;
364 } else if (q < 3) {
365 return (1.0 / 14.0) * shambase::constants::pi<Tscal>
366 * (-t7 + 20 * t6 - 168 * t5 + 756 * t4 - 1890 * t3 + 2268 * t2 - 2916 * q
367 + 507)
368 / q;
369 } else
370 return -120 * shambase::constants::pi<Tscal> / q;
371 }
372
373 inline static Tscal phi_tilde_3d_prime(Tscal q) {
374 Tscal t1 = sham::pow_constexpr<2>(q);
375 Tscal t2 = sham::pow_constexpr<3>(q);
376 Tscal t3 = sham::pow_constexpr<4>(q);
377 Tscal t4 = sham::pow_constexpr<5>(q);
378 Tscal t5 = sham::pow_constexpr<6>(q);
379 Tscal t6 = sham::pow_constexpr<7>(q);
380 Tscal t7 = sham::pow_constexpr<8>(q);
381 if (q < 1) {
382 return (1.0 / 7.0) * shambase::constants::pi<Tscal>
383 * (-35 * t5 + 120 * t4 - 336 * t2 + 616 * q);
384 } else if (q < 2) {
385 return (1.0 / 14.0) * shambase::constants::pi<Tscal>
386 * (40 * t6 - 420 * t5 + 1680 * t4 - 2940 * t3 + 1400 * t2 + 1428 * t1
387 - 1892)
388 / q
389 - (1.0 / 14.0) * shambase::constants::pi<Tscal>
390 * (5 * t7 - 60 * t6 + 280 * t5 - 588 * t4 + 350 * t3 + 476 * t2
391 - 1892 * q - 5)
392 / t1;
393 } else if (q < 3) {
394 return (1.0 / 14.0) * shambase::constants::pi<Tscal>
395 * (-8 * t6 + 140 * t5 - 1008 * t4 + 3780 * t3 - 7560 * t2 + 6804 * t1
396 - 2916)
397 / q
398 - (1.0 / 14.0) * shambase::constants::pi<Tscal>
399 * (-t7 + 20 * t6 - 168 * t5 + 756 * t4 - 1890 * t3 + 2268 * t2
400 - 2916 * q + 507)
401 / t1;
402 } else
403 return 120 * shambase::constants::pi<Tscal> / t1;
404 }
405 };
406
407 template<class Tscal>
409 public:
410 inline static constexpr Tscal Rkern = 3.5;
412 inline static constexpr Tscal hfactd = 1.0;
413
415 inline static constexpr Tscal norm_1d = 1. / 720;
417 inline static constexpr Tscal norm_2d = 256. / (113149 * shambase::constants::pi<Tscal>);
419 inline static constexpr Tscal norm_3d = 6. / (5040. * shambase::constants::pi<Tscal>);
420
421 inline static Tscal f(Tscal q) {
422
423 constexpr Tscal div7_2 = (7. / 2.);
424 constexpr Tscal div5_2 = (5. / 2.);
425 constexpr Tscal div3_2 = (3. / 2.);
426 constexpr Tscal div1_2 = (1. / 2.);
427
428 Tscal t1 = div7_2 - q;
429 Tscal t2 = div5_2 - q;
430 Tscal t3 = div3_2 - q;
431 Tscal t4 = div1_2 - q;
432
433 // up to order 6
434 t1 = sham::pow_constexpr<6>(t1);
435 t2 = sham::pow_constexpr<6>(t2);
436 t3 = sham::pow_constexpr<6>(t3);
437 t4 = sham::pow_constexpr<6>(t4);
438
439 t1 *= 1.;
440 t2 *= -7.;
441 t3 *= 21.;
442 t4 *= -35.;
443
444 if (q < div1_2) {
445 return t1 + t2 + t3 + t4;
446 } else if (q < div3_2) {
447 return t1 + t2 + t3;
448 } else if (q < div5_2) {
449 return t1 + t2;
450 } else if (q < div7_2) {
451 return t1;
452 } else
453 return 0;
454 }
455
456 inline static Tscal df(Tscal q) {
457
458 constexpr Tscal div7_2 = (7. / 2.);
459 constexpr Tscal div5_2 = (5. / 2.);
460 constexpr Tscal div3_2 = (3. / 2.);
461 constexpr Tscal div1_2 = (1. / 2.);
462
463 Tscal t1 = div7_2 - q;
464 Tscal t2 = div5_2 - q;
465 Tscal t3 = div3_2 - q;
466 Tscal t4 = div1_2 - q;
467
468 // up to order 6
469 t1 = sham::pow_constexpr<5>(t1);
470 t2 = sham::pow_constexpr<5>(t2);
471 t3 = sham::pow_constexpr<5>(t3);
472 t4 = sham::pow_constexpr<5>(t4);
473
474 t1 *= (-6.) * (1.);
475 t2 *= (-6.) * (-7.);
476 t3 *= (-6.) * (21.);
477 t4 *= (-6.) * (-35.);
478
479 if (q < div1_2) {
480 return t1 + t2 + t3 + t4;
481 } else if (q < div3_2) {
482 return t1 + t2 + t3;
483 } else if (q < div5_2) {
484 return t1 + t2;
485 } else if (q < div7_2) {
486 return t1;
487 } else
488 return 0;
489 }
490
491 inline static Tscal ddf(Tscal q) {
492 Tscal t1 = sham::pow_constexpr<4>(1.0 / 2.0 - q);
493 Tscal t2 = sham::pow_constexpr<4>(3.0 / 2.0 - q);
494 Tscal t3 = sham::pow_constexpr<4>(5.0 / 2.0 - q);
495 Tscal t4 = sham::pow_constexpr<4>(7.0 / 2.0 - q);
496 if (q < 1.0 / 2.0) {
497 return -1050 * t1 + 630 * t2 - 210 * t3 + 30 * t4;
498 } else if (q < 3.0 / 2.0) {
499 return 630 * t2 - 210 * t3 + 30 * t4;
500 } else if (q < 5.0 / 2.0) {
501 return -210 * t3 + 30 * t4;
502 } else if (q < 7.0 / 2.0) {
503 return 30 * t4;
504 } else
505 return 0;
506 }
507
508 inline static Tscal phi_tilde_3d(Tscal q) {
509 Tscal t1 = sham::pow_constexpr<2>(q);
510 Tscal t2 = sham::pow_constexpr<3>(q);
511 Tscal t3 = sham::pow_constexpr<4>(q);
512 Tscal t4 = sham::pow_constexpr<5>(q);
513 Tscal t5 = sham::pow_constexpr<6>(q);
514 Tscal t6 = sham::pow_constexpr<7>(q);
515 Tscal t7 = sham::pow_constexpr<8>(q);
516 Tscal t8 = sham::pow_constexpr<9>(q);
517 if (q < 1.0 / 2.0) {
518 return (1.0 / 1152.0) * shambase::constants::pi<Tscal>
519 * (-1280 * t7 + 11520 * t5 - 66528 * t3 + 282576 * t1 - 1018341);
520 } else if (q < 3.0 / 2.0) {
521 return (1.0 / 4608.0) * shambase::constants::pi<Tscal>
522 * (3840 * t8 - 34560 * t7 + 103680 * t6 - 53760 * t5 - 235872 * t4
523 - 10080 * t3 + 1131984 * t2 - 4073409 * q + 5)
524 / q;
525 } else if (q < 5.0 / 2.0) {
526 return (1.0 / 2304.0) * shambase::constants::pi<Tscal>
527 * (-768 * t8 + 13824 * t7 - 103680 * t6 + 408576 * t5 - 852768 * t4
528 + 729792 * t3 + 198576 * t2 - 1948131 * q - 29522)
529 / q;
530 } else if (q < 7.0 / 2.0) {
531 return (1.0 / 4608.0) * shambase::constants::pi<Tscal>
532 * (256 * t8 - 6912 * t7 + 80640 * t6 - 526848 * t5 + 2074464 * t4
533 - 4840416 * t3 + 5647152 * t2 - 7411887 * q + 1894081)
534 / q;
535 } else
536 return -840 * shambase::constants::pi<Tscal> / q;
537 }
538
539 inline static Tscal phi_tilde_3d_prime(Tscal q) {
540 Tscal t1 = sham::pow_constexpr<2>(q);
541 Tscal t2 = sham::pow_constexpr<3>(q);
542 Tscal t3 = sham::pow_constexpr<4>(q);
543 Tscal t4 = sham::pow_constexpr<5>(q);
544 Tscal t5 = sham::pow_constexpr<6>(q);
545 Tscal t6 = sham::pow_constexpr<7>(q);
546 Tscal t7 = sham::pow_constexpr<8>(q);
547 Tscal t8 = sham::pow_constexpr<9>(q);
548 if (q < 1.0 / 2.0) {
549 return (1.0 / 1152.0) * shambase::constants::pi<Tscal>
550 * (-10240 * t6 + 69120 * t4 - 266112 * t2 + 565152 * q);
551 } else if (q < 3.0 / 2.0) {
552 return (1.0 / 4608.0) * shambase::constants::pi<Tscal>
553 * (34560 * t7 - 276480 * t6 + 725760 * t5 - 322560 * t4 - 1179360 * t3
554 - 40320 * t2 + 3395952 * t1 - 4073409)
555 / q
556 - (1.0 / 4608.0) * shambase::constants::pi<Tscal>
557 * (3840 * t8 - 34560 * t7 + 103680 * t6 - 53760 * t5 - 235872 * t4
558 - 10080 * t3 + 1131984 * t2 - 4073409 * q + 5)
559 / t1;
560 } else if (q < 5.0 / 2.0) {
561 return (1.0 / 2304.0) * shambase::constants::pi<Tscal>
562 * (-6912 * t7 + 110592 * t6 - 725760 * t5 + 2451456 * t4 - 4263840 * t3
563 + 2919168 * t2 + 595728 * t1 - 1948131)
564 / q
565 - (1.0 / 2304.0) * shambase::constants::pi<Tscal>
566 * (-768 * t8 + 13824 * t7 - 103680 * t6 + 408576 * t5 - 852768 * t4
567 + 729792 * t3 + 198576 * t2 - 1948131 * q - 29522)
568 / t1;
569 } else if (q < 7.0 / 2.0) {
570 return (1.0 / 4608.0) * shambase::constants::pi<Tscal>
571 * (2304 * t7 - 55296 * t6 + 564480 * t5 - 3161088 * t4 + 10372320 * t3
572 - 19361664 * t2 + 16941456 * t1 - 7411887)
573 / q
574 - (1.0 / 4608.0) * shambase::constants::pi<Tscal>
575 * (256 * t8 - 6912 * t7 + 80640 * t6 - 526848 * t5 + 2074464 * t4
576 - 4840416 * t3 + 5647152 * t2 - 7411887 * q + 1894081)
577 / t1;
578 } else
579 return 840 * shambase::constants::pi<Tscal> / t1;
580 }
581 };
582
583 template<class Tscal>
585 public:
586 inline static constexpr Tscal Rkern = 4.0;
588 inline static constexpr Tscal hfactd = 1.0;
589
591 inline static constexpr Tscal norm_1d = 1.0 / 5040.0;
593 inline static constexpr Tscal norm_2d = (9.0 / 29740.0) / shambase::constants::pi<Tscal>;
595 inline static constexpr Tscal norm_3d = (1.0 / 6720.0) / shambase::constants::pi<Tscal>;
596
597 inline static Tscal f(Tscal q) {
598
599 Tscal t1 = 4 - q;
600 Tscal t2 = 3 - q;
601 Tscal t3 = 2 - q;
602 Tscal t4 = 1 - q;
603
604 t1 = sham::pow_constexpr<7>(t1);
605 t2 = sham::pow_constexpr<7>(t2);
606 t3 = sham::pow_constexpr<7>(t3);
607 t4 = sham::pow_constexpr<7>(t4);
608
609 t1 *= 1.;
610 t2 *= -8.;
611 t3 *= 28.;
612 t4 *= -56.;
613
614 if (q < 1) {
615 return t1 + t2 + t3 + t4;
616 } else if (q < 2) {
617 return t1 + t2 + t3;
618 } else if (q < 3) {
619 return t1 + t2;
620 } else if (q < 4) {
621 return t1;
622 } else
623 return 0;
624 }
625
626 inline static Tscal df(Tscal q) {
627
628 Tscal t1 = 4 - q;
629 Tscal t2 = 3 - q;
630 Tscal t3 = 2 - q;
631 Tscal t4 = 1 - q;
632
633 t1 = sham::pow_constexpr<6>(t1);
634 t2 = sham::pow_constexpr<6>(t2);
635 t3 = sham::pow_constexpr<6>(t3);
636 t4 = sham::pow_constexpr<6>(t4);
637
638 t1 *= (-7.) * (1.);
639 t2 *= (-7.) * (-8.);
640 t3 *= (-7.) * (28.);
641 t4 *= (-7.) * (-56.);
642
643 if (q < 1) {
644 return t1 + t2 + t3 + t4;
645 } else if (q < 2) {
646 return t1 + t2 + t3;
647 } else if (q < 3) {
648 return t1 + t2;
649 } else if (q < 4) {
650 return t1;
651 } else
652 return 0;
653 }
654
655 inline static Tscal ddf(Tscal q) {
656 Tscal t1 = sham::pow_constexpr<5>(1 - q);
657 Tscal t2 = sham::pow_constexpr<5>(2 - q);
658 Tscal t3 = sham::pow_constexpr<5>(3 - q);
659 Tscal t4 = sham::pow_constexpr<5>(4 - q);
660 if (q < 1) {
661 return -2352 * t1 + 1176 * t2 - 336 * t3 + 42 * t4;
662 } else if (q < 2) {
663 return 1176 * t2 - 336 * t3 + 42 * t4;
664 } else if (q < 3) {
665 return -336 * t3 + 42 * t4;
666 } else if (q < 4) {
667 return 42 * t4;
668 } else
669 return 0;
670 }
671
672 inline static Tscal phi_tilde_3d(Tscal q) {
673 Tscal t1 = sham::pow_constexpr<10>(q);
674 Tscal t2 = sham::pow_constexpr<2>(q);
675 Tscal t3 = sham::pow_constexpr<3>(q);
676 Tscal t4 = sham::pow_constexpr<4>(q);
677 Tscal t5 = sham::pow_constexpr<5>(q);
678 Tscal t6 = sham::pow_constexpr<6>(q);
679 Tscal t7 = sham::pow_constexpr<7>(q);
680 Tscal t8 = sham::pow_constexpr<8>(q);
681 Tscal t9 = sham::pow_constexpr<9>(q);
682 if (q < 1) {
683 return (2.0 / 9.0) * shambase::constants::pi<Tscal>
684 * (t2 * (7 * t7 - 35 * t6 + 240 * t4 - 1512 * t2 + 7248) - 29740);
685 } else if (q < 2) {
686 return (2.0 / 45.0) * shambase::constants::pi<Tscal>
687 * (-21 * t1 + 315 * t9 - 1890 * t8 + 5400 * t7 - 5880 * t6 - 2268 * t5
688 - 2940 * t4 + 37080 * t3 - 148770 * q + 14)
689 / q;
690 } else if (q < 3) {
691 return (2.0 / 45.0) * shambase::constants::pi<Tscal>
692 * (7 * t1 - 175 * t9 + 1890 * t8 - 11400 * t7 + 41160 * t6 - 86940 * t5
693 + 91140 * t4 - 16680 * t3 - 130850 * q - 7154)
694 / q;
695 } else if (q < 4) {
696 return (2.0 / 45.0) * shambase::constants::pi<Tscal>
697 * (-t1 + 35 * t9 - 540 * t8 + 4800 * t7 - 26880 * t6 + 96768 * t5
698 - 215040 * t4 + 245760 * t3 - 327680 * q + 110944)
699 / q;
700 } else
701 return -6720 * shambase::constants::pi<Tscal> / q;
702 }
703
704 inline static Tscal phi_tilde_3d_prime(Tscal q) {
705 Tscal t1 = sham::pow_constexpr<10>(q);
706 Tscal t2 = sham::pow_constexpr<2>(q);
707 Tscal t3 = sham::pow_constexpr<3>(q);
708 Tscal t4 = sham::pow_constexpr<4>(q);
709 Tscal t5 = sham::pow_constexpr<5>(q);
710 Tscal t6 = sham::pow_constexpr<6>(q);
711 Tscal t7 = sham::pow_constexpr<7>(q);
712 Tscal t8 = sham::pow_constexpr<8>(q);
713 Tscal t9 = sham::pow_constexpr<9>(q);
714 if (q < 1) {
715 return (2.0 / 9.0) * shambase::constants::pi<Tscal>
716 * (t2 * (49 * t6 - 210 * t5 + 960 * t3 - 3024 * q)
717 + 2 * q * (7 * t7 - 35 * t6 + 240 * t4 - 1512 * t2 + 7248));
718 } else if (q < 2) {
719 return (2.0 / 45.0) * shambase::constants::pi<Tscal>
720 * (-210 * t9 + 2835 * t8 - 15120 * t7 + 37800 * t6 - 35280 * t5
721 - 11340 * t4 - 11760 * t3 + 111240 * t2 - 148770)
722 / q
723 - (2.0 / 45.0) * shambase::constants::pi<Tscal>
724 * (-21 * t1 + 315 * t9 - 1890 * t8 + 5400 * t7 - 5880 * t6 - 2268 * t5
725 - 2940 * t4 + 37080 * t3 - 148770 * q + 14)
726 / t2;
727 } else if (q < 3) {
728 return (2.0 / 45.0) * shambase::constants::pi<Tscal>
729 * (70 * t9 - 1575 * t8 + 15120 * t7 - 79800 * t6 + 246960 * t5
730 - 434700 * t4 + 364560 * t3 - 50040 * t2 - 130850)
731 / q
732 - (2.0 / 45.0) * shambase::constants::pi<Tscal>
733 * (7 * t1 - 175 * t9 + 1890 * t8 - 11400 * t7 + 41160 * t6 - 86940 * t5
734 + 91140 * t4 - 16680 * t3 - 130850 * q - 7154)
735 / t2;
736 } else if (q < 4) {
737 return (2.0 / 45.0) * shambase::constants::pi<Tscal>
738 * (-10 * t9 + 315 * t8 - 4320 * t7 + 33600 * t6 - 161280 * t5
739 + 483840 * t4 - 860160 * t3 + 737280 * t2 - 327680)
740 / q
741 - (2.0 / 45.0) * shambase::constants::pi<Tscal>
742 * (-t1 + 35 * t9 - 540 * t8 + 4800 * t7 - 26880 * t6 + 96768 * t5
743 - 215040 * t4 + 245760 * t3 - 327680 * q + 110944)
744 / t2;
745 } else
746 return 6720 * shambase::constants::pi<Tscal> / t2;
747 }
748 };
749
750 template<class Tscal>
752 public:
753 inline static constexpr Tscal Rkern = 4.5;
755 inline static constexpr Tscal hfactd = 1.0;
756
758 inline static constexpr Tscal norm_1d = 1. / 40320;
760 inline static constexpr Tscal norm_2d = 512. / (14345663 * shambase::constants::pi<Tscal>);
762 inline static constexpr Tscal norm_3d = 6. / (362880. * shambase::constants::pi<Tscal>);
763
764 inline static Tscal f(Tscal q) {
765
766 constexpr Tscal div9_2 = (9. / 2.);
767 constexpr Tscal div7_2 = (7. / 2.);
768 constexpr Tscal div5_2 = (5. / 2.);
769 constexpr Tscal div3_2 = (3. / 2.);
770 constexpr Tscal div1_2 = (1. / 2.);
771
772 Tscal t1 = div9_2 - q;
773 Tscal t2 = div7_2 - q;
774 Tscal t3 = div5_2 - q;
775 Tscal t4 = div3_2 - q;
776 Tscal t5 = div1_2 - q;
777
778 t1 = sham::pow_constexpr<8>(t1);
779 t2 = sham::pow_constexpr<8>(t2);
780 t3 = sham::pow_constexpr<8>(t3);
781 t4 = sham::pow_constexpr<8>(t4);
782 t5 = sham::pow_constexpr<8>(t5);
783
784 t1 *= 1.;
785 t2 *= -9.;
786 t3 *= 36.;
787 t4 *= -84.;
788 t5 *= 126.;
789
790 if (q < div1_2) {
791 return t1 + t2 + t3 + t4 + t5;
792 } else if (q < div3_2) {
793 return t1 + t2 + t3 + t4;
794 } else if (q < div5_2) {
795 return t1 + t2 + t3;
796 } else if (q < div7_2) {
797 return t1 + t2;
798 } else if (q < div9_2) {
799 return t1;
800 } else
801 return 0;
802 }
803
804 inline static Tscal df(Tscal q) {
805
806 constexpr Tscal div9_2 = (9. / 2.);
807 constexpr Tscal div7_2 = (7. / 2.);
808 constexpr Tscal div5_2 = (5. / 2.);
809 constexpr Tscal div3_2 = (3. / 2.);
810 constexpr Tscal div1_2 = (1. / 2.);
811
812 Tscal t1 = div9_2 - q;
813 Tscal t2 = div7_2 - q;
814 Tscal t3 = div5_2 - q;
815 Tscal t4 = div3_2 - q;
816 Tscal t5 = div1_2 - q;
817
818 t1 = sham::pow_constexpr<7>(t1);
819 t2 = sham::pow_constexpr<7>(t2);
820 t3 = sham::pow_constexpr<7>(t3);
821 t4 = sham::pow_constexpr<7>(t4);
822 t5 = sham::pow_constexpr<7>(t5);
823
824 t1 *= (-8.) * (1.);
825 t2 *= (-8.) * (-9.);
826 t3 *= (-8.) * (36.);
827 t4 *= (-8.) * (-84.);
828 t5 *= (-8.) * (126.);
829
830 if (q < div1_2) {
831 return t1 + t2 + t3 + t4 + t5;
832 } else if (q < div3_2) {
833 return t1 + t2 + t3 + t4;
834 } else if (q < div5_2) {
835 return t1 + t2 + t3;
836 } else if (q < div7_2) {
837 return t1 + t2;
838 } else if (q < div9_2) {
839 return t1;
840 } else
841 return 0;
842 }
843
844 inline static Tscal ddf(Tscal q) {
845 Tscal t1 = sham::pow_constexpr<6>(1.0 / 2.0 - q);
846 Tscal t2 = sham::pow_constexpr<6>(3.0 / 2.0 - q);
847 Tscal t3 = sham::pow_constexpr<6>(5.0 / 2.0 - q);
848 Tscal t4 = sham::pow_constexpr<6>(7.0 / 2.0 - q);
849 Tscal t5 = sham::pow_constexpr<6>(9.0 / 2.0 - q);
850 if (q < 1.0 / 2.0) {
851 return 7056 * t1 - 4704 * t2 + 2016 * t3 - 504 * t4 + 56 * t5;
852 } else if (q < 3.0 / 2.0) {
853 return -4704 * t2 + 2016 * t3 - 504 * t4 + 56 * t5;
854 } else if (q < 5.0 / 2.0) {
855 return 2016 * t3 - 504 * t4 + 56 * t5;
856 } else if (q < 7.0 / 2.0) {
857 return -504 * t4 + 56 * t5;
858 } else if (q < 9.0 / 2.0) {
859 return 56 * t5;
860 } else
861 return 0;
862 }
863
864 inline static Tscal phi_tilde_3d(Tscal q) {
865 Tscal t1 = sham::pow_constexpr<10>(q);
866 Tscal t2 = sham::pow_constexpr<11>(q);
867 Tscal t3 = sham::pow_constexpr<2>(q);
868 Tscal t4 = sham::pow_constexpr<3>(q);
869 Tscal t5 = sham::pow_constexpr<4>(q);
870 Tscal t6 = sham::pow_constexpr<5>(q);
871 Tscal t7 = sham::pow_constexpr<6>(q);
872 Tscal t8 = sham::pow_constexpr<7>(q);
873 Tscal t9 = sham::pow_constexpr<8>(q);
874 Tscal t10 = sham::pow_constexpr<9>(q);
875 if (q < 1.0 / 2.0) {
876 return (1.0 / 2816.0) * shambase::constants::pi<Tscal>
877 * (7168 * t1 - 98560 * t9 + 908160 * t7 - 6408864 * t5 + 34283436 * t3
878 - 157802293);
879 } else if (q < 3.0 / 2.0) {
880 return (1.0 / 14080.0) * shambase::constants::pi<Tscal>
881 * (-28672 * t2 + 315392 * t1 - 1182720 * t10 + 887040 * t9 + 3801600 * t8
882 + 413952 * t7 - 32199552 * t6 + 36960 * t5 + 171412560 * t4
883 - 789011388 * q - 7)
884 / q;
885 } else if (q < 5.0 / 2.0) {
886 return (1.0 / 14080.0) * shambase::constants::pi<Tscal>
887 * (14336 * t2 - 315392 * t1 + 2956800 * t10 - 15079680 * t9 + 43718400 * t8
888 - 66646272 * t7 + 43243200 * t6 - 53850720 * t5 + 191620440 * t4
889 - 792042570 * q + 826679)
890 / q;
891 } else if (q < 7.0 / 2.0) {
892 return (1.0 / 14080.0) * shambase::constants::pi<Tscal>
893 * (-4096 * t2 + 135168 * t1 - 1971200 * t10 + 16600320 * t9 - 88281600 * t8
894 + 302953728 * t7 - 649756800 * t6 + 771149280 * t5 - 324004560 * t4
895 - 577198820 * q - 96829571)
896 / q;
897 } else if (q < 9.0 / 2.0) {
898 return (1.0 / 28160.0) * shambase::constants::pi<Tscal>
899 * (1024 * t2 - 45056 * t1 + 887040 * t10 - 10264320 * t9 + 76982400 * t8
900 - 387991296 * t7 + 1309470624 * t6 - 2806008480 * t5 + 3156759540 * t4
901 - 4261625379 * q + 1783667601)
902 / q;
903 } else
904 return -60480 * shambase::constants::pi<Tscal> / q;
905 }
906
907 inline static Tscal phi_tilde_3d_prime(Tscal q) {
908 Tscal t1 = sham::pow_constexpr<10>(q);
909 Tscal t2 = sham::pow_constexpr<11>(q);
910 Tscal t3 = sham::pow_constexpr<2>(q);
911 Tscal t4 = sham::pow_constexpr<3>(q);
912 Tscal t5 = sham::pow_constexpr<4>(q);
913 Tscal t6 = sham::pow_constexpr<5>(q);
914 Tscal t7 = sham::pow_constexpr<6>(q);
915 Tscal t8 = sham::pow_constexpr<7>(q);
916 Tscal t9 = sham::pow_constexpr<8>(q);
917 Tscal t10 = sham::pow_constexpr<9>(q);
918 if (q < 1.0 / 2.0) {
919 return (1.0 / 2816.0) * shambase::constants::pi<Tscal>
920 * (71680 * t10 - 788480 * t8 + 5448960 * t6 - 25635456 * t4 + 68566872 * q);
921 } else if (q < 3.0 / 2.0) {
922 return (1.0 / 14080.0) * shambase::constants::pi<Tscal>
923 * (-315392 * t1 + 3153920 * t10 - 10644480 * t9 + 7096320 * t8
924 + 26611200 * t7 + 2483712 * t6 - 160997760 * t5 + 147840 * t4
925 + 514237680 * t3 - 789011388)
926 / q
927 - (1.0 / 14080.0) * shambase::constants::pi<Tscal>
928 * (-28672 * t2 + 315392 * t1 - 1182720 * t10 + 887040 * t9
929 + 3801600 * t8 + 413952 * t7 - 32199552 * t6 + 36960 * t5
930 + 171412560 * t4 - 789011388 * q - 7)
931 / t3;
932 } else if (q < 5.0 / 2.0) {
933 return (1.0 / 14080.0) * shambase::constants::pi<Tscal>
934 * (157696 * t1 - 3153920 * t10 + 26611200 * t9 - 120637440 * t8
935 + 306028800 * t7 - 399877632 * t6 + 216216000 * t5 - 215402880 * t4
936 + 574861320 * t3 - 792042570)
937 / q
938 - (1.0 / 14080.0) * shambase::constants::pi<Tscal>
939 * (14336 * t2 - 315392 * t1 + 2956800 * t10 - 15079680 * t9
940 + 43718400 * t8 - 66646272 * t7 + 43243200 * t6 - 53850720 * t5
941 + 191620440 * t4 - 792042570 * q + 826679)
942 / t3;
943 } else if (q < 7.0 / 2.0) {
944 return (1.0 / 14080.0) * shambase::constants::pi<Tscal>
945 * (-45056 * t1 + 1351680 * t10 - 17740800 * t9 + 132802560 * t8
946 - 617971200 * t7 + 1817722368 * t6 - 3248784000 * t5 + 3084597120 * t4
947 - 972013680 * t3 - 577198820)
948 / q
949 - (1.0 / 14080.0) * shambase::constants::pi<Tscal>
950 * (-4096 * t2 + 135168 * t1 - 1971200 * t10 + 16600320 * t9
951 - 88281600 * t8 + 302953728 * t7 - 649756800 * t6 + 771149280 * t5
952 - 324004560 * t4 - 577198820 * q - 96829571)
953 / t3;
954 } else if (q < 9.0 / 2.0) {
955 return (1.0 / 28160.0) * shambase::constants::pi<Tscal>
956 * (11264 * t1 - 450560 * t10 + 7983360 * t9 - 82114560 * t8
957 + 538876800 * t7 - 2327947776 * t6 + 6547353120 * t5
958 - 11224033920 * t4 + 9470278620 * t3 - 4261625379)
959 / q
960 - (1.0 / 28160.0) * shambase::constants::pi<Tscal>
961 * (1024 * t2 - 45056 * t1 + 887040 * t10 - 10264320 * t9
962 + 76982400 * t8 - 387991296 * t7 + 1309470624 * t6 - 2806008480 * t5
963 + 3156759540 * t4 - 4261625379 * q + 1783667601)
964 / t3;
965 } else
966 return 60480 * shambase::constants::pi<Tscal> / t3;
967 }
968 };
969
970 template<class Tscal>
972 public:
973 inline static constexpr Tscal Rkern = 5;
975 inline static constexpr Tscal hfactd = 1.0;
976
978 inline static constexpr Tscal norm_1d = 1. / 362880;
980 inline static constexpr Tscal norm_2d = 11. / (2922230 * shambase::constants::pi<Tscal>);
982 inline static constexpr Tscal norm_3d = 6. / (3628800. * shambase::constants::pi<Tscal>);
983
984 inline static Tscal f(Tscal q) {
985
986 Tscal t1 = 5 - q;
987 Tscal t2 = 4 - q;
988 Tscal t3 = 3 - q;
989 Tscal t4 = 2 - q;
990 Tscal t5 = 1 - q;
991
992 t1 = sham::pow_constexpr<9>(t1);
993 t2 = sham::pow_constexpr<9>(t2);
994 t3 = sham::pow_constexpr<9>(t3);
995 t4 = sham::pow_constexpr<9>(t4);
996 t5 = sham::pow_constexpr<9>(t5);
997
998 t1 *= 1.;
999 t2 *= -10.;
1000 t3 *= 45.;
1001 t4 *= -120.;
1002 t5 *= 210.;
1003
1004 if (q < 1) {
1005 return t1 + t2 + t3 + t4 + t5;
1006 } else if (q < 2) {
1007 return t1 + t2 + t3 + t4;
1008 } else if (q < 3) {
1009 return t1 + t2 + t3;
1010 } else if (q < 4) {
1011 return t1 + t2;
1012 } else if (q < 5) {
1013 return t1;
1014 } else
1015 return 0;
1016 }
1017
1018 inline static Tscal df(Tscal q) {
1019
1020 Tscal t1 = 5 - q;
1021 Tscal t2 = 4 - q;
1022 Tscal t3 = 3 - q;
1023 Tscal t4 = 2 - q;
1024 Tscal t5 = 1 - q;
1025
1026 t1 = sham::pow_constexpr<8>(t1);
1027 t2 = sham::pow_constexpr<8>(t2);
1028 t3 = sham::pow_constexpr<8>(t3);
1029 t4 = sham::pow_constexpr<8>(t4);
1030 t5 = sham::pow_constexpr<8>(t5);
1031
1032 t1 *= (-9.) * (1.);
1033 t2 *= (-9.) * (-10.);
1034 t3 *= (-9.) * (45.);
1035 t4 *= (-9.) * (-120.);
1036 t5 *= (-9.) * (210.);
1037
1038 if (q < 1) {
1039 return t1 + t2 + t3 + t4 + t5;
1040 } else if (q < 2) {
1041 return t1 + t2 + t3 + t4;
1042 } else if (q < 3) {
1043 return t1 + t2 + t3;
1044 } else if (q < 4) {
1045 return t1 + t2;
1046 } else if (q < 5) {
1047 return t1;
1048 } else
1049 return 0;
1050 }
1051
1052 inline static Tscal ddf(Tscal q) {
1053 Tscal t1 = sham::pow_constexpr<7>(1 - q);
1054 Tscal t2 = sham::pow_constexpr<7>(2 - q);
1055 Tscal t3 = sham::pow_constexpr<7>(3 - q);
1056 Tscal t4 = sham::pow_constexpr<7>(4 - q);
1057 Tscal t5 = sham::pow_constexpr<7>(5 - q);
1058 if (q < 1) {
1059 return 15120 * t1 - 8640 * t2 + 3240 * t3 - 720 * t4 + 72 * t5;
1060 } else if (q < 2) {
1061 return -8640 * t2 + 3240 * t3 - 720 * t4 + 72 * t5;
1062 } else if (q < 3) {
1063 return 3240 * t3 - 720 * t4 + 72 * t5;
1064 } else if (q < 4) {
1065 return -720 * t4 + 72 * t5;
1066 } else if (q < 5) {
1067 return 72 * t5;
1068 } else
1069 return 0;
1070 }
1071
1072 inline static Tscal phi_tilde_3d(Tscal q) {
1073 Tscal t1 = sham::pow_constexpr<10>(q);
1074 Tscal t2 = sham::pow_constexpr<11>(q);
1075 Tscal t3 = sham::pow_constexpr<12>(q);
1076 Tscal t4 = sham::pow_constexpr<2>(q);
1077 Tscal t5 = sham::pow_constexpr<3>(q);
1078 Tscal t6 = sham::pow_constexpr<4>(q);
1079 Tscal t7 = sham::pow_constexpr<5>(q);
1080 Tscal t8 = sham::pow_constexpr<6>(q);
1081 Tscal t9 = sham::pow_constexpr<7>(q);
1082 Tscal t10 = sham::pow_constexpr<8>(q);
1083 Tscal t11 = sham::pow_constexpr<9>(q);
1084 if (q < 1) {
1085 return (2.0 / 33.0) * shambase::constants::pi<Tscal>
1086 * (-63 * t2 + 378 * t1 - 3850 * t10 + 37620 * t8 - 291060 * t6 + 1718090 * t4
1087 - 8766690);
1088 } else if (q < 2) {
1089 return (2.0 / 33.0) * shambase::constants::pi<Tscal>
1090 * (42 * t3 - 756 * t2 + 5544 * t1 - 20020 * t11 + 31185 * t10 - 3960 * t9
1091 + 38808 * t8 - 316008 * t7 + 10395 * t6 + 1715780 * t5 - 8766564 * q - 21)
1092 / q;
1093 } else if (q < 3) {
1094 return (2.0 / 33.0) * shambase::constants::pi<Tscal>
1095 * (-18 * t3 + 540 * t2 - 7128 * t1 + 53900 * t11 - 253935 * t10 + 756360 * t9
1096 - 1380456 * t8 + 1508760 * t7 - 1510245 * t6 + 2391620 * t5 - 8914020 * q
1097 + 49131)
1098 / q;
1099 } else if (q < 4) {
1100 return (1.0 / 33.0) * shambase::constants::pi<Tscal>
1101 * (9 * t3 - 378 * t2 + 7128 * t1 - 79310 * t11 + 574695 * t10 - 2817540 * t9
1102 + 9363816 * t8 - 20365884 * t7 + 26208765 * t6 - 14702930 * t5
1103 - 8262102 * q - 4684707)
1104 / q;
1105 } else if (q < 5) {
1106 return (1.0 / 33.0) * shambase::constants::pi<Tscal>
1107 * (-t3 + 54 * t2 - 1320 * t1 + 19250 * t11 - 185625 * t10 + 1237500 * t9
1108 - 5775000 * t8 + 18562500 * t7 - 38671875 * t6 + 42968750 * t5
1109 - 58593750 * q + 28869725)
1110 / q;
1111 } else
1112 return -604800 * shambase::constants::pi<Tscal> / q;
1113 }
1114
1115 inline static Tscal phi_tilde_3d_prime(Tscal q) {
1116 Tscal t1 = sham::pow_constexpr<10>(q);
1117 Tscal t2 = sham::pow_constexpr<11>(q);
1118 Tscal t3 = sham::pow_constexpr<12>(q);
1119 Tscal t4 = sham::pow_constexpr<2>(q);
1120 Tscal t5 = sham::pow_constexpr<3>(q);
1121 Tscal t6 = sham::pow_constexpr<4>(q);
1122 Tscal t7 = sham::pow_constexpr<5>(q);
1123 Tscal t8 = sham::pow_constexpr<6>(q);
1124 Tscal t9 = sham::pow_constexpr<7>(q);
1125 Tscal t10 = sham::pow_constexpr<8>(q);
1126 Tscal t11 = sham::pow_constexpr<9>(q);
1127 if (q < 1) {
1128 return (2.0 / 33.0) * shambase::constants::pi<Tscal>
1129 * (-693 * t1 + 3780 * t11 - 30800 * t9 + 225720 * t7 - 1164240 * t5
1130 + 3436180 * q);
1131 } else if (q < 2) {
1132 return (2.0 / 33.0) * shambase::constants::pi<Tscal>
1133 * (504 * t2 - 8316 * t1 + 55440 * t11 - 180180 * t10 + 249480 * t9
1134 - 27720 * t8 + 232848 * t7 - 1580040 * t6 + 41580 * t5 + 5147340 * t4
1135 - 8766564)
1136 / q
1137 - (2.0 / 33.0) * shambase::constants::pi<Tscal>
1138 * (42 * t3 - 756 * t2 + 5544 * t1 - 20020 * t11 + 31185 * t10
1139 - 3960 * t9 + 38808 * t8 - 316008 * t7 + 10395 * t6 + 1715780 * t5
1140 - 8766564 * q - 21)
1141 / t4;
1142 } else if (q < 3) {
1143 return (2.0 / 33.0) * shambase::constants::pi<Tscal>
1144 * (-216 * t2 + 5940 * t1 - 71280 * t11 + 485100 * t10 - 2031480 * t9
1145 + 5294520 * t8 - 8282736 * t7 + 7543800 * t6 - 6040980 * t5
1146 + 7174860 * t4 - 8914020)
1147 / q
1148 - (2.0 / 33.0) * shambase::constants::pi<Tscal>
1149 * (-18 * t3 + 540 * t2 - 7128 * t1 + 53900 * t11 - 253935 * t10
1150 + 756360 * t9 - 1380456 * t8 + 1508760 * t7 - 1510245 * t6
1151 + 2391620 * t5 - 8914020 * q + 49131)
1152 / t4;
1153 } else if (q < 4) {
1154 return (1.0 / 33.0) * shambase::constants::pi<Tscal>
1155 * (108 * t2 - 4158 * t1 + 71280 * t11 - 713790 * t10 + 4597560 * t9
1156 - 19722780 * t8 + 56182896 * t7 - 101829420 * t6 + 104835060 * t5
1157 - 44108790 * t4 - 8262102)
1158 / q
1159 - (1.0 / 33.0) * shambase::constants::pi<Tscal>
1160 * (9 * t3 - 378 * t2 + 7128 * t1 - 79310 * t11 + 574695 * t10
1161 - 2817540 * t9 + 9363816 * t8 - 20365884 * t7 + 26208765 * t6
1162 - 14702930 * t5 - 8262102 * q - 4684707)
1163 / t4;
1164 } else if (q < 5) {
1165 return (1.0 / 33.0) * shambase::constants::pi<Tscal>
1166 * (-12 * t2 + 594 * t1 - 13200 * t11 + 173250 * t10 - 1485000 * t9
1167 + 8662500 * t8 - 34650000 * t7 + 92812500 * t6 - 154687500 * t5
1168 + 128906250 * t4 - 58593750)
1169 / q
1170 - (1.0 / 33.0) * shambase::constants::pi<Tscal>
1171 * (-t3 + 54 * t2 - 1320 * t1 + 19250 * t11 - 185625 * t10
1172 + 1237500 * t9 - 5775000 * t8 + 18562500 * t7 - 38671875 * t6
1173 + 42968750 * t5 - 58593750 * q + 28869725)
1174 / t4;
1175 } else
1176 return 604800 * shambase::constants::pi<Tscal> / t4;
1177 }
1178 };
1179
1180 template<class Tscal>
1182 public:
1183 inline static constexpr Tscal Rkern = 2;
1185 inline static constexpr Tscal hfactd = 1.4;
1186
1188 inline static constexpr Tscal norm_1d = 3. / 4.;
1190 inline static constexpr Tscal norm_2d = 7. / (4 * shambase::constants::pi<Tscal>);
1192 inline static constexpr Tscal norm_3d = 21 / (16 * shambase::constants::pi<Tscal>);
1193
1194 inline static Tscal f(Tscal q) {
1195
1196 constexpr Tscal div1_2 = (1. / 2.);
1197
1198 Tscal p1 = (1 - q * div1_2);
1199 Tscal p2 = (1 + q * 2);
1200
1201 p1 *= p1;
1202 p1 *= p1;
1203
1204 if (q < 2.) {
1205 return p1 * p2;
1206 } else
1207 return 0;
1208 }
1209
1210 inline static Tscal df(Tscal q) {
1211
1212 constexpr Tscal div1_2 = (1. / 2.);
1213 constexpr Tscal div1_8 = (1. / 8.);
1214 constexpr Tscal div1_4 = (1. / 4.);
1215
1216 Tscal p1 = (1 - q * div1_2);
1217 Tscal p2 = (1 + q * 2);
1218
1219 Tscal p3 = p1 * p1 * p1;
1220
1221 if (q < 2.) {
1222 return 2 * (p3 * p1 - p3 * p2);
1223 } else
1224 return 0;
1225 }
1226
1227 inline static Tscal ddf(Tscal q) {
1228 Tscal t1 = sham::pow_constexpr<2>(1 - (1.0 / 2.0) * q);
1229 Tscal t2 = sham::pow_constexpr<3>(1 - (1.0 / 2.0) * q);
1230 if (q < 2) {
1231 return -8 * t2 + 3 * t1 * (2 * q + 1);
1232 } else
1233 return 0;
1234 }
1235
1236 inline static Tscal phi_tilde_3d(Tscal q) {
1237 Tscal t1 = sham::pow_constexpr<2>(q);
1238 Tscal t2 = sham::pow_constexpr<3>(q);
1239 Tscal t3 = sham::pow_constexpr<4>(q);
1240 Tscal t4 = sham::pow_constexpr<5>(q);
1241 if (q < 2) {
1242 return (1.0 / 336.0) * shambase::constants::pi<Tscal>
1243 * (t1 * (3 * t4 - 30 * t3 + 112 * t2 - 168 * t1 + 224) - 384);
1244 } else
1245 return -(16.0 / 21.0) * shambase::constants::pi<Tscal> / q;
1246 }
1247
1248 inline static Tscal phi_tilde_3d_prime(Tscal q) {
1249 Tscal t1 = sham::pow_constexpr<2>(q);
1250 Tscal t2 = sham::pow_constexpr<3>(q);
1251 Tscal t3 = sham::pow_constexpr<4>(q);
1252 Tscal t4 = sham::pow_constexpr<5>(q);
1253 if (q < 2) {
1254 return (1.0 / 336.0) * shambase::constants::pi<Tscal>
1255 * (t1 * (15 * t3 - 120 * t2 + 336 * t1 - 336 * q)
1256 + 2 * q * (3 * t4 - 30 * t3 + 112 * t2 - 168 * t1 + 224));
1257 } else
1258 return (16.0 / 21.0) * shambase::constants::pi<Tscal> / t1;
1259 }
1260 };
1261
1262 template<class Tscal>
1264 public:
1265 inline static constexpr Tscal Rkern = 2;
1267 inline static constexpr Tscal hfactd = 1.6;
1268
1270 inline static constexpr Tscal norm_1d = 27. / 32.;
1272 inline static constexpr Tscal norm_2d = 9. / (4 * shambase::constants::pi<Tscal>);
1274 inline static constexpr Tscal norm_3d = 495. / (256. * shambase::constants::pi<Tscal>);
1275
1276 inline static Tscal f(Tscal q) {
1277
1278 constexpr Tscal div1_2 = (1. / 2.);
1279 constexpr Tscal div35_12 = (35. / 12.);
1280
1281 Tscal p1 = (1 - q * div1_2);
1282 Tscal p2 = (1 + q * 3 + div35_12 * q * q);
1283
1284 p1 *= p1;
1285 p1 = p1 * p1 * p1;
1286
1287 if (q < 2.) {
1288 return p1 * p2;
1289 } else
1290 return 0;
1291 }
1292
1293 inline static Tscal df(Tscal q) {
1294
1295 constexpr Tscal div7_96 = (7. / 96.);
1296
1297 Tscal p1 = (-2 + q);
1298 Tscal p2 = (2 + 5 * q);
1299
1300 Tscal p14 = p1 * p1;
1301 p14 *= p14;
1302
1303 if (q < 2.) {
1304 return div7_96 * p14 * p1 * q * p2;
1305 } else
1306 return 0;
1307 }
1308
1309 inline static Tscal ddf(Tscal q) {
1310 Tscal t1 = sham::pow_constexpr<2>(q);
1311 Tscal t2 = sham::pow_constexpr<4>(1 - (1.0 / 2.0) * q);
1312 Tscal t3 = sham::pow_constexpr<5>(1 - (1.0 / 2.0) * q);
1313 Tscal t4 = sham::pow_constexpr<6>(1 - (1.0 / 2.0) * q);
1314 if (q < 2) {
1315 return (35.0 / 6.0) * t4 - 6 * t3 * ((35.0 / 6.0) * q + 3)
1316 + (15.0 / 2.0) * t2 * ((35.0 / 12.0) * t1 + 3 * q + 1);
1317 } else
1318 return 0;
1319 }
1320
1321 inline static Tscal phi_tilde_3d(Tscal q) {
1322 Tscal t1 = sham::pow_constexpr<2>(q);
1323 Tscal t2 = sham::pow_constexpr<4>(q);
1324 Tscal t3 = sham::pow_constexpr<5>(q);
1325 Tscal t4 = sham::pow_constexpr<6>(q);
1326 Tscal t5 = sham::pow_constexpr<7>(q);
1327 Tscal t6 = sham::pow_constexpr<8>(q);
1328 if (q < 2) {
1329 return (1.0 / 63360.0) * shambase::constants::pi<Tscal>
1330 * (t1
1331 * (105 * t6 - 1408 * t5 + 7700 * t4 - 21120 * t3 + 26400 * t2
1332 - 29568 * t1 + 42240)
1333 - 56320);
1334 } else
1335 return -(256.0 / 495.0) * shambase::constants::pi<Tscal> / q;
1336 }
1337
1338 inline static Tscal phi_tilde_3d_prime(Tscal q) {
1339 Tscal t1 = sham::pow_constexpr<2>(q);
1340 Tscal t2 = sham::pow_constexpr<3>(q);
1341 Tscal t3 = sham::pow_constexpr<4>(q);
1342 Tscal t4 = sham::pow_constexpr<5>(q);
1343 Tscal t5 = sham::pow_constexpr<6>(q);
1344 Tscal t6 = sham::pow_constexpr<7>(q);
1345 Tscal t7 = sham::pow_constexpr<8>(q);
1346 if (q < 2) {
1347 return (1.0 / 63360.0) * shambase::constants::pi<Tscal>
1348 * (t1
1349 * (840 * t6 - 9856 * t5 + 46200 * t4 - 105600 * t3 + 105600 * t2
1350 - 59136 * q)
1351 + 2 * q
1352 * (105 * t7 - 1408 * t6 + 7700 * t5 - 21120 * t4 + 26400 * t3
1353 - 29568 * t1 + 42240));
1354 } else
1355 return (256.0 / 495.0) * shambase::constants::pi<Tscal> / t1;
1356 }
1357 };
1358
1359 template<class Tscal>
1361 public:
1362 inline static constexpr Tscal Rkern = 2;
1364 inline static constexpr Tscal hfactd = 2.2;
1365
1367 inline static constexpr Tscal norm_1d = 15. / 16.;
1369 inline static constexpr Tscal norm_2d = 39. / (14. * shambase::constants::pi<Tscal>);
1371 inline static constexpr Tscal norm_3d = 1365. / (512. * shambase::constants::pi<Tscal>);
1372
1373 inline static Tscal f(Tscal q) {
1374
1375 constexpr Tscal div1_2 = (1. / 2.);
1376 constexpr Tscal div25_4 = (25. / 4.);
1377
1378 Tscal p1 = (1 - q * div1_2);
1379 Tscal p2 = (1 + q * 4 + div25_4 * q * q + 4 * q * q * q);
1380
1381 p1 *= p1;
1382 p1 *= p1;
1383 p1 *= p1;
1384
1385 if (q < 2.) {
1386 return p1 * p2;
1387 } else
1388 return 0;
1389 }
1390
1391 inline static Tscal df(Tscal q) {
1392
1393 constexpr Tscal div11_512 = (11. / 512.);
1394
1395 Tscal p1 = (-2 + q);
1396 Tscal p2 = 2 + 7 * q + 8 * q * q;
1397
1398 Tscal p12 = p1 * p1;
1399 Tscal p14 = p12 * p12;
1400 Tscal p17 = p12 * p14 * p1;
1401
1402 if (q < 2.) {
1403 return div11_512 * p17 * q * p2;
1404 } else
1405 return 0;
1406 }
1407
1408 inline static Tscal ddf(Tscal q) {
1409 Tscal t1 = sham::pow_constexpr<2>(q);
1410 Tscal t2 = sham::pow_constexpr<3>(q);
1411 Tscal t3 = sham::pow_constexpr<6>(1 - (1.0 / 2.0) * q);
1412 Tscal t4 = sham::pow_constexpr<7>(1 - (1.0 / 2.0) * q);
1413 Tscal t5 = sham::pow_constexpr<8>(1 - (1.0 / 2.0) * q);
1414 if (q < 2) {
1415 return t5 * (24 * q + 25.0 / 2.0) - 8 * t4 * (12 * t1 + (25.0 / 2.0) * q + 4)
1416 + 14 * t3 * (4 * t2 + (25.0 / 4.0) * t1 + 4 * q + 1);
1417 } else
1418 return 0;
1419 }
1420
1421 inline static Tscal phi_tilde_3d(Tscal q) {
1422 Tscal t1 = sham::pow_constexpr<10>(q);
1423 Tscal t2 = sham::pow_constexpr<11>(q);
1424 Tscal t3 = sham::pow_constexpr<2>(q);
1425 Tscal t4 = sham::pow_constexpr<4>(q);
1426 Tscal t5 = sham::pow_constexpr<6>(q);
1427 Tscal t6 = sham::pow_constexpr<7>(q);
1428 Tscal t7 = sham::pow_constexpr<8>(q);
1429 Tscal t8 = sham::pow_constexpr<9>(q);
1430 if (q < 2) {
1431 return (1.0 / 1397760.0) * shambase::constants::pi<Tscal>
1432 * (t3
1433 * (480 * t2 - 8085 * t1 + 58240 * t8 - 229320 * t7 + 512512 * t6
1434 - 560560 * t5 + 549120 * t4 - 768768 * t3 + 931840)
1435 - 1003520);
1436 } else
1437 return -(512.0 / 1365.0) * shambase::constants::pi<Tscal> / q;
1438 }
1439
1440 inline static Tscal phi_tilde_3d_prime(Tscal q) {
1441 Tscal t1 = sham::pow_constexpr<10>(q);
1442 Tscal t2 = sham::pow_constexpr<11>(q);
1443 Tscal t3 = sham::pow_constexpr<2>(q);
1444 Tscal t4 = sham::pow_constexpr<3>(q);
1445 Tscal t5 = sham::pow_constexpr<4>(q);
1446 Tscal t6 = sham::pow_constexpr<5>(q);
1447 Tscal t7 = sham::pow_constexpr<6>(q);
1448 Tscal t8 = sham::pow_constexpr<7>(q);
1449 Tscal t9 = sham::pow_constexpr<8>(q);
1450 Tscal t10 = sham::pow_constexpr<9>(q);
1451 if (q < 2) {
1452 return (1.0 / 1397760.0) * shambase::constants::pi<Tscal>
1453 * (t3
1454 * (5280 * t1 - 80850 * t10 + 524160 * t9 - 1834560 * t8 + 3587584 * t7
1455 - 3363360 * t6 + 2196480 * t4 - 1537536 * q)
1456 + 2 * q
1457 * (480 * t2 - 8085 * t1 + 58240 * t10 - 229320 * t9 + 512512 * t8
1458 - 560560 * t7 + 549120 * t5 - 768768 * t3 + 931840));
1459 } else
1460 return (512.0 / 1365.0) * shambase::constants::pi<Tscal> / t3;
1461 }
1462 };
1463
1472 template<class Tscal>
1474 public:
1475 inline static constexpr Tscal Rkern = 3;
1476 inline static constexpr Tscal hfactd = 1.5;
1477
1479 inline static constexpr Tscal norm_1d = 0.564202047051383;
1481 inline static constexpr Tscal norm_2d = 0.318349173592935;
1483 inline static constexpr Tscal norm_3d = 0.179666148218087;
1484
1485 inline static Tscal f(Tscal q) {
1486 Tscal t1 = sham::pow_constexpr<2>(q);
1487 if (q < 3) {
1488 return sycl::exp(-t1);
1489 } else
1490 return 0;
1491 }
1492
1493 inline static Tscal df(Tscal q) {
1494 Tscal t1 = sham::pow_constexpr<2>(q);
1495 if (q < 3) {
1496 return -2 * q * sycl::exp(-t1);
1497 } else
1498 return 0;
1499 }
1500
1501 inline static Tscal ddf(Tscal q) {
1502 Tscal t1 = sham::pow_constexpr<2>(q);
1503 if (q < 3) {
1504 return (4 * t1 - 2) * sycl::exp(-t1);
1505 } else
1506 return 0;
1507 }
1508
1509 inline static Tscal phi_tilde_3d(Tscal q) {
1510 if (q == 0) {
1511 return -6.282409900511787;
1512 } else if (q < 3) {
1513 return 2 * shambase::constants::pi<Tscal> * sycl::exp(Tscal{-9})
1514 - sycl::pow(shambase::constants::pi<Tscal>, 3.0 / 2.0) * sycl::erf(q) / q;
1515 } else
1516 return (-sycl::pow(shambase::constants::pi<Tscal>, 3.0 / 2.0) * sycl::erf(Tscal{3})
1517 + 6 * shambase::constants::pi<Tscal> * sycl::exp(Tscal{-9}))
1518 / q;
1519 }
1520
1521 inline static Tscal phi_tilde_3d_prime(Tscal q) {
1522 Tscal t1 = sham::pow_constexpr<2>(q);
1523 if (q == 0) {
1524 return 0;
1525 } else if (q < 3) {
1526 return -2 * shambase::constants::pi<Tscal> * sycl::exp(-t1) / q
1527 + sycl::pow(shambase::constants::pi<Tscal>, 3.0 / 2.0) * sycl::erf(q) / t1;
1528 } else
1529 return -(-sycl::pow(shambase::constants::pi<Tscal>, 3.0 / 2.0) * sycl::erf(Tscal{3})
1530 + 6 * shambase::constants::pi<Tscal> * sycl::exp(Tscal{-9}))
1531 / t1;
1532 }
1533 };
1534
1543 template<class Tscal>
1545 public:
1546 inline static constexpr Tscal Rkern = 5;
1547 inline static constexpr Tscal hfactd = 1.5;
1548
1550 inline static constexpr Tscal norm_1d = 0.564189583548624;
1552 inline static constexpr Tscal norm_2d = 0.318309886188211;
1554 inline static constexpr Tscal norm_3d = 0.179587122139514;
1555
1556 inline static Tscal f(Tscal q) {
1557 Tscal t1 = sham::pow_constexpr<2>(q);
1558 if (q < 5) {
1559 return sycl::exp(-t1);
1560 } else
1561 return 0;
1562 }
1563
1564 inline static Tscal df(Tscal q) {
1565 Tscal t1 = sham::pow_constexpr<2>(q);
1566 if (q < 5) {
1567 return -2 * q * sycl::exp(-t1);
1568 } else
1569 return 0;
1570 }
1571
1572 inline static Tscal ddf(Tscal q) {
1573 Tscal t1 = sham::pow_constexpr<2>(q);
1574 if (q < 5) {
1575 return (4 * t1 - 2) * sycl::exp(-t1);
1576 } else
1577 return 0;
1578 }
1579
1580 inline static Tscal phi_tilde_3d(Tscal q) {
1581 if (q == 0) {
1582 return -6.283185307092326;
1583 } else if (q < 5) {
1584 return 2 * shambase::constants::pi<Tscal> * sycl::exp(Tscal{-25})
1585 - sycl::pow(shambase::constants::pi<Tscal>, 3.0 / 2.0) * sycl::erf(q) / q;
1586 } else
1587 return (-sycl::pow(shambase::constants::pi<Tscal>, 3.0 / 2.0) * sycl::erf(Tscal{5})
1588 + 10 * shambase::constants::pi<Tscal> * sycl::exp(Tscal{-25}))
1589 / q;
1590 }
1591
1592 inline static Tscal phi_tilde_3d_prime(Tscal q) {
1593 Tscal t1 = sham::pow_constexpr<2>(q);
1594 if (q == 0) {
1595 return 0;
1596 } else if (q < 5) {
1597 return -2 * shambase::constants::pi<Tscal> * sycl::exp(-t1) / q
1598 + sycl::pow(shambase::constants::pi<Tscal>, 3.0 / 2.0) * sycl::erf(q) / t1;
1599 } else
1600 return -(-sycl::pow(shambase::constants::pi<Tscal>, 3.0 / 2.0) * sycl::erf(Tscal{5})
1601 + 10 * shambase::constants::pi<Tscal> * sycl::exp(Tscal{-25}))
1602 / t1;
1603 }
1604 };
1605
1606 template<class Tscal>
1608 public:
1609 inline static constexpr Tscal Rkern = 2;
1611 inline static constexpr Tscal hfactd = 1.2;
1612
1614 inline static constexpr Tscal norm_1d = 2.;
1616 inline static constexpr Tscal norm_2d
1617 = (49. / 31.) * 10. / (7. * shambase::constants::pi<Tscal>);
1619 inline static constexpr Tscal norm_3d = (10. / 9.) * 1 / shambase::constants::pi<Tscal>;
1620
1621 inline static Tscal f(Tscal q) { return KernelDefM4<Tscal>::f(q) * q * q; }
1622
1623 inline static Tscal df(Tscal q) {
1624 return KernelDefM4<Tscal>::df(q) * q * q + 2 * KernelDefM4<Tscal>::f(q) * q;
1625 }
1626
1627 inline static Tscal ddf(Tscal q) {
1628 Tscal t1 = sham::pow_constexpr<2>(1 - q);
1629 Tscal t2 = sham::pow_constexpr<2>(2 - q);
1630 Tscal t3 = sham::pow_constexpr<2>(q);
1631 Tscal t4 = sham::pow_constexpr<3>(1 - q);
1632 Tscal t5 = sham::pow_constexpr<3>(2 - q);
1633 if (q < 1) {
1634 return t3 * ((9.0 / 2.0) * q - 3) + 4 * q * (3 * t1 - (3.0 / 4.0) * t2) - 2 * t4
1635 + (1.0 / 2.0) * t5;
1636 } else if (q < 2) {
1637 return -(3.0 / 4.0) * t3 * (2 * q - 4) - 3 * q * t2 + (1.0 / 2.0) * t5;
1638 } else
1639 return 0;
1640 }
1641
1642 inline static Tscal phi_tilde_3d(Tscal q) {
1643 Tscal t1 = sham::pow_constexpr<2>(q);
1644 Tscal t2 = sham::pow_constexpr<3>(q);
1645 Tscal t3 = sham::pow_constexpr<4>(q);
1646 Tscal t4 = sham::pow_constexpr<5>(q);
1647 Tscal t5 = sham::pow_constexpr<6>(q);
1648 Tscal t6 = sham::pow_constexpr<7>(q);
1649 Tscal t7 = sham::pow_constexpr<8>(q);
1650 if (q < 1) {
1651 return (1.0 / 280.0) * shambase::constants::pi<Tscal>
1652 * (t3 * (15 * t2 - 40 * t1 + 56) - 248);
1653 } else if (q < 2) {
1654 return (1.0 / 280.0) * shambase::constants::pi<Tscal>
1655 * (-5 * t7 + 40 * t6 - 112 * t5 + 112 * t4 - 256 * q + 4) / q;
1656 } else
1657 return -(9.0 / 10.0) * shambase::constants::pi<Tscal> / q;
1658 }
1659
1660 inline static Tscal phi_tilde_3d_prime(Tscal q) {
1661 Tscal t1 = sham::pow_constexpr<2>(q);
1662 Tscal t2 = sham::pow_constexpr<3>(q);
1663 Tscal t3 = sham::pow_constexpr<4>(q);
1664 Tscal t4 = sham::pow_constexpr<5>(q);
1665 Tscal t5 = sham::pow_constexpr<6>(q);
1666 Tscal t6 = sham::pow_constexpr<7>(q);
1667 Tscal t7 = sham::pow_constexpr<8>(q);
1668 if (q < 1) {
1669 return (1.0 / 280.0) * shambase::constants::pi<Tscal>
1670 * (t3 * (45 * t1 - 80 * q) + 4 * t2 * (15 * t2 - 40 * t1 + 56));
1671 } else if (q < 2) {
1672 return (1.0 / 280.0) * shambase::constants::pi<Tscal>
1673 * (-40 * t6 + 280 * t5 - 672 * t4 + 560 * t3 - 256) / q
1674 - (1.0 / 280.0) * shambase::constants::pi<Tscal>
1675 * (-5 * t7 + 40 * t6 - 112 * t5 + 112 * t4 - 256 * q + 4) / t1;
1676 } else
1677 return (9.0 / 10.0) * shambase::constants::pi<Tscal> / t1;
1678 }
1679 };
1680
1681 template<class Tscal>
1683 public:
1684 inline static constexpr Tscal Rkern = 2;
1686 inline static constexpr Tscal hfactd = 1.2;
1687
1689 inline static constexpr Tscal norm_1d = (105. / 31.) * 2. / 3.;
1691 inline static constexpr Tscal norm_2d
1692 = (14. / 9.) * 10. / (7. * shambase::constants::pi<Tscal>);
1694 inline static constexpr Tscal norm_3d = (126. / 127.) * 1 / shambase::constants::pi<Tscal>;
1695
1696 inline static Tscal f(Tscal q) { return KernelDefM4<Tscal>::f(q) * q * q * q; }
1697
1698 inline static Tscal df(Tscal q) {
1699 return KernelDefM4<Tscal>::df(q) * q * q * q + 3 * KernelDefM4<Tscal>::f(q) * q * q;
1700 }
1701
1702 inline static Tscal ddf(Tscal q) {
1703 Tscal t1 = sham::pow_constexpr<2>(1 - q);
1704 Tscal t2 = sham::pow_constexpr<2>(2 - q);
1705 Tscal t3 = sham::pow_constexpr<2>(q);
1706 Tscal t4 = sham::pow_constexpr<3>(1 - q);
1707 Tscal t5 = sham::pow_constexpr<3>(2 - q);
1708 Tscal t6 = sham::pow_constexpr<3>(q);
1709 if (q < 1) {
1710 return t6 * ((9.0 / 2.0) * q - 3) + 6 * t3 * (3 * t1 - (3.0 / 4.0) * t2)
1711 + 6 * q * (-t4 + (1.0 / 4.0) * t5);
1712 } else if (q < 2) {
1713 return -(3.0 / 4.0) * t6 * (2 * q - 4) - (9.0 / 2.0) * t3 * t2
1714 + (3.0 / 2.0) * q * t5;
1715 } else
1716 return 0;
1717 }
1718
1719 inline static Tscal phi_tilde_3d(Tscal q) {
1720 Tscal t1 = sham::pow_constexpr<2>(q);
1721 Tscal t2 = sham::pow_constexpr<3>(q);
1722 Tscal t3 = sham::pow_constexpr<5>(q);
1723 Tscal t4 = sham::pow_constexpr<6>(q);
1724 Tscal t5 = sham::pow_constexpr<7>(q);
1725 Tscal t6 = sham::pow_constexpr<8>(q);
1726 Tscal t7 = sham::pow_constexpr<9>(q);
1727 if (q < 1) {
1728 return (1.0 / 840.0) * shambase::constants::pi<Tscal>
1729 * (t3 * (35 * t2 - 90 * t1 + 112) - 756);
1730 } else if (q < 2) {
1731 return (1.0 / 2520.0) * shambase::constants::pi<Tscal>
1732 * (-35 * t7 + 270 * t6 - 720 * t5 + 672 * t4 - 2304 * q + 20) / q;
1733 } else
1734 return -(127.0 / 126.0) * shambase::constants::pi<Tscal> / q;
1735 }
1736
1737 inline static Tscal phi_tilde_3d_prime(Tscal q) {
1738 Tscal t1 = sham::pow_constexpr<2>(q);
1739 Tscal t2 = sham::pow_constexpr<3>(q);
1740 Tscal t3 = sham::pow_constexpr<4>(q);
1741 Tscal t4 = sham::pow_constexpr<5>(q);
1742 Tscal t5 = sham::pow_constexpr<6>(q);
1743 Tscal t6 = sham::pow_constexpr<7>(q);
1744 Tscal t7 = sham::pow_constexpr<8>(q);
1745 Tscal t8 = sham::pow_constexpr<9>(q);
1746 if (q < 1) {
1747 return (1.0 / 840.0) * shambase::constants::pi<Tscal>
1748 * (t4 * (105 * t1 - 180 * q) + 5 * t3 * (35 * t2 - 90 * t1 + 112));
1749 } else if (q < 2) {
1750 return (1.0 / 2520.0) * shambase::constants::pi<Tscal>
1751 * (-315 * t7 + 2160 * t6 - 5040 * t5 + 4032 * t4 - 2304) / q
1752 - (1.0 / 2520.0) * shambase::constants::pi<Tscal>
1753 * (-35 * t8 + 270 * t7 - 720 * t6 + 672 * t5 - 2304 * q + 20) / t1;
1754 } else
1755 return (127.0 / 126.0) * shambase::constants::pi<Tscal> / t1;
1756 }
1757 };
1758
1759 template<class Tscal>
1761 public:
1762 inline static constexpr Tscal Rkern = 2;
1764 inline static constexpr Tscal hfactd = 1.2;
1765
1767 inline static constexpr Tscal norm_1d = 252.0 / 127.0;
1769 inline static constexpr Tscal norm_2d = (28.0 / 17.0) / shambase::constants::pi<Tscal>;
1771 inline static constexpr Tscal norm_3d = (330.0 / 511.0) / shambase::constants::pi<Tscal>;
1772
1773 inline static Tscal f(Tscal q) {
1774 return KernelDefM4<Tscal>::f(q) * sham::pow_constexpr<5>(q);
1775 }
1776
1777 inline static Tscal df(Tscal q) {
1778 return KernelDefM4<Tscal>::df(q) * sham::pow_constexpr<5>(q)
1779 + 5 * KernelDefM4<Tscal>::f(q) * sham::pow_constexpr<4>(q);
1780 }
1781
1782 inline static Tscal ddf(Tscal q) {
1783 Tscal t1 = sham::pow_constexpr<2>(1 - q);
1784 Tscal t2 = sham::pow_constexpr<2>(2 - q);
1785 Tscal t3 = sham::pow_constexpr<3>(1 - q);
1786 Tscal t4 = sham::pow_constexpr<3>(2 - q);
1787 Tscal t5 = sham::pow_constexpr<3>(q);
1788 Tscal t6 = sham::pow_constexpr<4>(q);
1789 Tscal t7 = sham::pow_constexpr<5>(q);
1790 if (q < 1) {
1791 return t7 * ((9.0 / 2.0) * q - 3) + 10 * t6 * (3 * t1 - (3.0 / 4.0) * t2)
1792 + 20 * t5 * (-t3 + (1.0 / 4.0) * t4);
1793 } else if (q < 2) {
1794 return -(3.0 / 4.0) * t7 * (2 * q - 4) - (15.0 / 2.0) * t6 * t2 + 5 * t5 * t4;
1795 } else
1796 return 0;
1797 }
1798
1799 inline static Tscal phi_tilde_3d(Tscal q) {
1800 Tscal t1 = sham::pow_constexpr<10>(q);
1801 Tscal t2 = sham::pow_constexpr<11>(q);
1802 Tscal t3 = sham::pow_constexpr<2>(q);
1803 Tscal t4 = sham::pow_constexpr<3>(q);
1804 Tscal t5 = sham::pow_constexpr<7>(q);
1805 Tscal t6 = sham::pow_constexpr<8>(q);
1806 Tscal t7 = sham::pow_constexpr<9>(q);
1807 if (q < 1) {
1808 return (1.0 / 2310.0) * shambase::constants::pi<Tscal>
1809 * (t5 * (63 * t4 - 154 * t3 + 165) - 2805);
1810 } else if (q < 2) {
1811 return (1.0 / 2310.0) * shambase::constants::pi<Tscal>
1812 * (-21 * t2 + 154 * t1 - 385 * t7 + 330 * t6 - 2816 * q + 7) / q;
1813 } else
1814 return -(511.0 / 330.0) * shambase::constants::pi<Tscal> / q;
1815 }
1816
1817 inline static Tscal phi_tilde_3d_prime(Tscal q) {
1818 Tscal t1 = sham::pow_constexpr<10>(q);
1819 Tscal t2 = sham::pow_constexpr<11>(q);
1820 Tscal t3 = sham::pow_constexpr<2>(q);
1821 Tscal t4 = sham::pow_constexpr<3>(q);
1822 Tscal t5 = sham::pow_constexpr<6>(q);
1823 Tscal t6 = sham::pow_constexpr<7>(q);
1824 Tscal t7 = sham::pow_constexpr<8>(q);
1825 Tscal t8 = sham::pow_constexpr<9>(q);
1826 if (q < 1) {
1827 return (1.0 / 2310.0) * shambase::constants::pi<Tscal>
1828 * (t6 * (189 * t3 - 308 * q) + 7 * t5 * (63 * t4 - 154 * t3 + 165));
1829 } else if (q < 2) {
1830 return (1.0 / 2310.0) * shambase::constants::pi<Tscal>
1831 * (-231 * t1 + 1540 * t8 - 3465 * t7 + 2640 * t6 - 2816) / q
1832 - (1.0 / 2310.0) * shambase::constants::pi<Tscal>
1833 * (-21 * t2 + 154 * t1 - 385 * t8 + 330 * t7 - 2816 * q + 7) / t3;
1834 } else
1835 return (511.0 / 330.0) * shambase::constants::pi<Tscal> / t3;
1836 }
1837 };
1838
1839 template<class Tscal>
1841 public:
1842 inline static constexpr Tscal Rkern = 2;
1844 inline static constexpr Tscal hfactd = 1.2;
1845
1847 inline static constexpr Tscal norm_1d = 660.0 / 511.0;
1849 inline static constexpr Tscal norm_2d = (30.0 / 31.0) / shambase::constants::pi<Tscal>;
1851 inline static constexpr Tscal norm_3d = (715.0 / 2047.0) / shambase::constants::pi<Tscal>;
1852
1853 inline static Tscal f(Tscal q) {
1854 return KernelDefM4<Tscal>::f(q) * sham::pow_constexpr<7>(q);
1855 }
1856
1857 inline static Tscal df(Tscal q) {
1858 return KernelDefM4<Tscal>::df(q) * sham::pow_constexpr<7>(q)
1859 + 7 * KernelDefM4<Tscal>::f(q) * sham::pow_constexpr<6>(q);
1860 }
1861
1862 inline static Tscal ddf(Tscal q) {
1863 Tscal t1 = sham::pow_constexpr<2>(1 - q);
1864 Tscal t2 = sham::pow_constexpr<2>(2 - q);
1865 Tscal t3 = sham::pow_constexpr<3>(1 - q);
1866 Tscal t4 = sham::pow_constexpr<3>(2 - q);
1867 Tscal t5 = sham::pow_constexpr<5>(q);
1868 Tscal t6 = sham::pow_constexpr<6>(q);
1869 Tscal t7 = sham::pow_constexpr<7>(q);
1870 if (q < 1) {
1871 return t7 * ((9.0 / 2.0) * q - 3) + 14 * t6 * (3 * t1 - (3.0 / 4.0) * t2)
1872 + 42 * t5 * (-t3 + (1.0 / 4.0) * t4);
1873 } else if (q < 2) {
1874 return -(3.0 / 4.0) * t7 * (2 * q - 4) - (21.0 / 2.0) * t6 * t2
1875 + (21.0 / 2.0) * t5 * t4;
1876 } else
1877 return 0;
1878 }
1879
1880 inline static Tscal phi_tilde_3d(Tscal q) {
1881 Tscal t1 = sham::pow_constexpr<10>(q);
1882 Tscal t2 = sham::pow_constexpr<11>(q);
1883 Tscal t3 = sham::pow_constexpr<12>(q);
1884 Tscal t4 = sham::pow_constexpr<13>(q);
1885 Tscal t5 = sham::pow_constexpr<2>(q);
1886 Tscal t6 = sham::pow_constexpr<3>(q);
1887 Tscal t7 = sham::pow_constexpr<9>(q);
1888 if (q < 1) {
1889 return (1.0 / 25740.0) * shambase::constants::pi<Tscal>
1890 * (t7 * (495 * t6 - 1170 * t5 + 1144) - 53196);
1891 } else if (q < 2) {
1892 return (1.0 / 25740.0) * shambase::constants::pi<Tscal>
1893 * (-165 * t4 + 1170 * t3 - 2808 * t2 + 2288 * t1 - 53248 * q + 36) / q;
1894 } else
1895 return -(2047.0 / 715.0) * shambase::constants::pi<Tscal> / q;
1896 }
1897
1898 inline static Tscal phi_tilde_3d_prime(Tscal q) {
1899 Tscal t1 = sham::pow_constexpr<10>(q);
1900 Tscal t2 = sham::pow_constexpr<11>(q);
1901 Tscal t3 = sham::pow_constexpr<12>(q);
1902 Tscal t4 = sham::pow_constexpr<13>(q);
1903 Tscal t5 = sham::pow_constexpr<2>(q);
1904 Tscal t6 = sham::pow_constexpr<3>(q);
1905 Tscal t7 = sham::pow_constexpr<8>(q);
1906 Tscal t8 = sham::pow_constexpr<9>(q);
1907 if (q < 1) {
1908 return (1.0 / 25740.0) * shambase::constants::pi<Tscal>
1909 * (t8 * (1485 * t5 - 2340 * q) + 9 * t7 * (495 * t6 - 1170 * t5 + 1144));
1910 } else if (q < 2) {
1911 return (1.0 / 25740.0) * shambase::constants::pi<Tscal>
1912 * (-2145 * t3 + 14040 * t2 - 30888 * t1 + 22880 * t8 - 53248) / q
1913 - (1.0 / 25740.0) * shambase::constants::pi<Tscal>
1914 * (-165 * t4 + 1170 * t3 - 2808 * t2 + 2288 * t1 - 53248 * q + 36)
1915 / t5;
1916 } else
1917 return (2047.0 / 715.0) * shambase::constants::pi<Tscal> / t5;
1918 }
1919 };
1920
1921 template<class Tscal>
1923 public:
1924 inline static constexpr Tscal Rkern = 2;
1926 inline static constexpr Tscal hfactd = 1.2;
1927
1929 inline static constexpr Tscal norm_1d = 4.0 / 11.0;
1931 inline static constexpr Tscal norm_2d = (40.0 / 77.0) / shambase::constants::pi<Tscal>;
1933 inline static constexpr Tscal norm_3d = (120.0 / 439.0) / shambase::constants::pi<Tscal>;
1934
1935 inline static Tscal f(Tscal q) {
1936 if (q < 1.) {
1937 return 1.;
1938 } else {
1939 return KernelDefM4<Tscal>::f((q - 1) * 2);
1940 }
1941 }
1942
1943 inline static Tscal df(Tscal q) {
1944 if (q < 1.) {
1945 return 0.;
1946 } else {
1947 return 2 * KernelDefM4<Tscal>::df((q - 1) * 2);
1948 }
1949 }
1950
1951 inline static Tscal ddf(Tscal q) {
1952 if (q < 1.) {
1953 return 0.;
1954 } else {
1955 return 4 * KernelDefM4<Tscal>::ddf((q - 1) * 2);
1956 }
1957 }
1958
1959 inline static Tscal phi_tilde_3d(Tscal q) {
1960 Tscal t1 = sham::pow_constexpr<2>(q);
1961 Tscal t2 = sham::pow_constexpr<3>(q);
1962 Tscal t3 = sham::pow_constexpr<4>(q);
1963 Tscal t4 = sham::pow_constexpr<5>(q);
1964 Tscal t5 = sham::pow_constexpr<6>(q);
1965 if (q < 1) {
1966 return (1.0 / 60.0) * shambase::constants::pi<Tscal> * (40 * t1 - 231);
1967 } else if (q < 3.0 / 2.0) {
1968 return (1.0 / 60.0) * shambase::constants::pi<Tscal>
1969 * (48 * t5 - 288 * t4 + 600 * t3 - 440 * t2 - 39 * q - 72) / q;
1970 } else if (q < 2) {
1971 return (1.0 / 120.0) * shambase::constants::pi<Tscal>
1972 * (-32 * t5 + 288 * t4 - 960 * t3 + 1280 * t2 - 1536 * q + 585) / q;
1973 } else
1974 return -(439.0 / 120.0) * shambase::constants::pi<Tscal> / q;
1975 }
1976
1977 inline static Tscal phi_tilde_3d_prime(Tscal q) {
1978 Tscal t1 = sham::pow_constexpr<2>(q);
1979 Tscal t2 = sham::pow_constexpr<3>(q);
1980 Tscal t3 = sham::pow_constexpr<4>(q);
1981 Tscal t4 = sham::pow_constexpr<5>(q);
1982 Tscal t5 = sham::pow_constexpr<6>(q);
1983 if (q < 1) {
1984 return (4.0 / 3.0) * shambase::constants::pi<Tscal> * q;
1985 } else if (q < 3.0 / 2.0) {
1986 return (1.0 / 60.0) * shambase::constants::pi<Tscal>
1987 * (288 * t4 - 1440 * t3 + 2400 * t2 - 1320 * t1 - 39) / q
1988 - (1.0 / 60.0) * shambase::constants::pi<Tscal>
1989 * (48 * t5 - 288 * t4 + 600 * t3 - 440 * t2 - 39 * q - 72) / t1;
1990 } else if (q < 2) {
1991 return (1.0 / 120.0) * shambase::constants::pi<Tscal>
1992 * (-192 * t4 + 1440 * t3 - 3840 * t2 + 3840 * t1 - 1536) / q
1993 - (1.0 / 120.0) * shambase::constants::pi<Tscal>
1994 * (-32 * t5 + 288 * t4 - 960 * t3 + 1280 * t2 - 1536 * q + 585) / t1;
1995 } else
1996 return (439.0 / 120.0) * shambase::constants::pi<Tscal> / t1;
1997 }
1998 };
1999
2000 template<class Tscal>
2002 public:
2003 inline static constexpr Tscal Rkern = 2;
2005 inline static constexpr Tscal hfactd = 1.2;
2006
2008 inline static constexpr Tscal norm_1d = 8.0 / 27.0;
2010 inline static constexpr Tscal norm_2d = (160.0 / 457.0) / shambase::constants::pi<Tscal>;
2012 inline static constexpr Tscal norm_3d = (320.0 / 2069.0) / shambase::constants::pi<Tscal>;
2013
2014 inline static Tscal f(Tscal q) {
2015 if (q < 1.5) {
2016 return 1.;
2017 } else {
2018 return KernelDefM4<Tscal>::f((q - 1.5) * 4);
2019 }
2020 }
2021
2022 inline static Tscal df(Tscal q) {
2023 if (q < 1.5) {
2024 return 0.;
2025 } else {
2026 return 4 * KernelDefM4<Tscal>::df((q - 1.5) * 4);
2027 }
2028 }
2029
2030 inline static Tscal ddf(Tscal q) {
2031 if (q < 1.5) {
2032 return 0.;
2033 } else {
2034 return 16 * KernelDefM4<Tscal>::ddf((q - 1.5) * 4);
2035 }
2036 }
2037
2038 inline static Tscal phi_tilde_3d(Tscal q) {
2039 Tscal t1 = sham::pow_constexpr<2>(q);
2040 Tscal t2 = sham::pow_constexpr<3>(q);
2041 Tscal t3 = sham::pow_constexpr<4>(q);
2042 Tscal t4 = sham::pow_constexpr<5>(q);
2043 Tscal t5 = sham::pow_constexpr<6>(q);
2044 if (q < 3.0 / 2.0) {
2045 return (1.0 / 240.0) * shambase::constants::pi<Tscal> * (160 * t1 - 1371);
2046 } else if (q < 7.0 / 4.0) {
2047 return (1.0 / 240.0) * shambase::constants::pi<Tscal>
2048 * (1536 * t5 - 11520 * t4 + 31680 * t3 - 34400 * t2 + 25845 * q - 14580) / q;
2049 } else if (q < 2) {
2050 return (1.0 / 960.0) * shambase::constants::pi<Tscal>
2051 * (-2048 * t5 + 18432 * t4 - 61440 * t3 + 81920 * t2 - 98304 * q + 59329)
2052 / q;
2053 } else
2054 return -(2069.0 / 320.0) * shambase::constants::pi<Tscal> / q;
2055 }
2056
2057 inline static Tscal phi_tilde_3d_prime(Tscal q) {
2058 Tscal t1 = sham::pow_constexpr<2>(q);
2059 Tscal t2 = sham::pow_constexpr<3>(q);
2060 Tscal t3 = sham::pow_constexpr<4>(q);
2061 Tscal t4 = sham::pow_constexpr<5>(q);
2062 Tscal t5 = sham::pow_constexpr<6>(q);
2063 if (q < 3.0 / 2.0) {
2064 return (4.0 / 3.0) * shambase::constants::pi<Tscal> * q;
2065 } else if (q < 7.0 / 4.0) {
2066 return (1.0 / 240.0) * shambase::constants::pi<Tscal>
2067 * (9216 * t4 - 57600 * t3 + 126720 * t2 - 103200 * t1 + 25845) / q
2068 - (1.0 / 240.0) * shambase::constants::pi<Tscal>
2069 * (1536 * t5 - 11520 * t4 + 31680 * t3 - 34400 * t2 + 25845 * q
2070 - 14580)
2071 / t1;
2072 } else if (q < 2) {
2073 return (1.0 / 960.0) * shambase::constants::pi<Tscal>
2074 * (-12288 * t4 + 92160 * t3 - 245760 * t2 + 245760 * t1 - 98304) / q
2075 - (1.0 / 960.0) * shambase::constants::pi<Tscal>
2076 * (-2048 * t5 + 18432 * t4 - 61440 * t3 + 81920 * t2 - 98304 * q
2077 + 59329)
2078 / t1;
2079 } else
2080 return (2069.0 / 320.0) * shambase::constants::pi<Tscal> / t1;
2081 }
2082 };
2083
2084 template<class Tscal>
2086 public:
2087 inline static constexpr Tscal Rkern = 2;
2089 inline static constexpr Tscal hfactd = 1.2;
2090
2092 inline static constexpr Tscal norm_1d = 16.0 / 59.0;
2094 inline static constexpr Tscal norm_2d = (640.0 / 2177.0) / shambase::constants::pi<Tscal>;
2096 inline static constexpr Tscal norm_3d = (7680.0 / 64303.0) / shambase::constants::pi<Tscal>;
2097
2098 inline static Tscal f(Tscal q) {
2099 if (q < 1.75) {
2100 return 1.;
2101 } else {
2102 return KernelDefM4<Tscal>::f((q - 1.75) * 8);
2103 }
2104 }
2105
2106 inline static Tscal df(Tscal q) {
2107 if (q < 1.75) {
2108 return 0.;
2109 } else {
2110 return 8 * KernelDefM4<Tscal>::df((q - 1.75) * 8);
2111 }
2112 }
2113
2114 inline static Tscal ddf(Tscal q) {
2115 if (q < 1.75) {
2116 return 0.;
2117 } else {
2118 return 64 * KernelDefM4<Tscal>::ddf((q - 1.75) * 8);
2119 }
2120 }
2121
2122 inline static Tscal phi_tilde_3d(Tscal q) {
2123 Tscal t1 = sham::pow_constexpr<2>(q);
2124 Tscal t2 = sham::pow_constexpr<3>(q);
2125 Tscal t3 = sham::pow_constexpr<4>(q);
2126 Tscal t4 = sham::pow_constexpr<5>(q);
2127 Tscal t5 = sham::pow_constexpr<6>(q);
2128 if (q < 7.0 / 4.0) {
2129 return (1.0 / 960.0) * shambase::constants::pi<Tscal> * (640 * t1 - 6531);
2130 } else if (q < 15.0 / 8.0) {
2131 return (1.0 / 960.0) * shambase::constants::pi<Tscal>
2132 * (49152 * t5 - 405504 * t4 + 1236480 * t3 - 1504640 * t2 + 1491693 * q
2133 - 907578)
2134 / q;
2135 } else if (q < 2) {
2136 return (1.0 / 7680.0) * shambase::constants::pi<Tscal>
2137 * (-131072 * t5 + 1179648 * t4 - 3932160 * t3 + 5242880 * t2 - 6291456 * q
2138 + 4130001)
2139 / q;
2140 } else
2141 return -(64303.0 / 7680.0) * shambase::constants::pi<Tscal> / q;
2142 }
2143
2144 inline static Tscal phi_tilde_3d_prime(Tscal q) {
2145 Tscal t1 = sham::pow_constexpr<2>(q);
2146 Tscal t2 = sham::pow_constexpr<3>(q);
2147 Tscal t3 = sham::pow_constexpr<4>(q);
2148 Tscal t4 = sham::pow_constexpr<5>(q);
2149 Tscal t5 = sham::pow_constexpr<6>(q);
2150 if (q < 7.0 / 4.0) {
2151 return (4.0 / 3.0) * shambase::constants::pi<Tscal> * q;
2152 } else if (q < 15.0 / 8.0) {
2153 return (1.0 / 960.0) * shambase::constants::pi<Tscal>
2154 * (294912 * t4 - 2027520 * t3 + 4945920 * t2 - 4513920 * t1 + 1491693)
2155 / q
2156 - (1.0 / 960.0) * shambase::constants::pi<Tscal>
2157 * (49152 * t5 - 405504 * t4 + 1236480 * t3 - 1504640 * t2 + 1491693 * q
2158 - 907578)
2159 / t1;
2160 } else if (q < 2) {
2161 return (1.0 / 7680.0) * shambase::constants::pi<Tscal>
2162 * (-786432 * t4 + 5898240 * t3 - 15728640 * t2 + 15728640 * t1 - 6291456)
2163 / q
2164 - (1.0 / 7680.0) * shambase::constants::pi<Tscal>
2165 * (-131072 * t5 + 1179648 * t4 - 3932160 * t3 + 5242880 * t2
2166 - 6291456 * q + 4130001)
2167 / t1;
2168 } else
2169 return (64303.0 / 7680.0) * shambase::constants::pi<Tscal> / t1;
2170 }
2171 };
2172
2173 template<class Tscal>
2175 public:
2176 inline static constexpr Tscal Rkern = 2;
2178 inline static constexpr Tscal hfactd = 1.2;
2179
2181 inline static constexpr Tscal norm_1d = 32.0 / 123.0;
2183 inline static constexpr Tscal norm_2d = (2560.0 / 9457.0) / shambase::constants::pi<Tscal>;
2185 inline static constexpr Tscal norm_3d = (4096.0 / 38785.0) / shambase::constants::pi<Tscal>;
2186
2187 inline static Tscal f(Tscal q) {
2188 if (q < 1.875) {
2189 return 1.;
2190 } else {
2191 return KernelDefM4<Tscal>::f((q - 1.875) * 16);
2192 }
2193 }
2194
2195 inline static Tscal df(Tscal q) {
2196 if (q < 1.875) {
2197 return 0.;
2198 } else {
2199 return 16 * KernelDefM4<Tscal>::df((q - 1.875) * 16);
2200 }
2201 }
2202
2203 inline static Tscal ddf(Tscal q) {
2204 if (q < 1.875) {
2205 return 0.;
2206 } else {
2207 return 256 * KernelDefM4<Tscal>::ddf((q - 1.875) * 16);
2208 }
2209 }
2210
2211 inline static Tscal phi_tilde_3d(Tscal q) {
2212 Tscal t1 = sham::pow_constexpr<2>(q);
2213 Tscal t2 = sham::pow_constexpr<3>(q);
2214 Tscal t3 = sham::pow_constexpr<4>(q);
2215 Tscal t4 = sham::pow_constexpr<5>(q);
2216 Tscal t5 = sham::pow_constexpr<6>(q);
2217 if (q < 15.0 / 8.0) {
2218 return (1.0 / 3840.0) * shambase::constants::pi<Tscal> * (2560 * t1 - 28371);
2219 } else if (q < 31.0 / 16.0) {
2220 return (1.0 / 3840.0) * shambase::constants::pi<Tscal>
2221 * (1572864 * t5 - 13565952 * t4 + 43315200 * t3 - 55293440 * t2
2222 + 60721629 * q - 38728125)
2223 / q;
2224 } else if (q < 2) {
2225 return (1.0 / 61440.0) * shambase::constants::pi<Tscal>
2226 * (-8388608 * t5 + 75497472 * t4 - 251658240 * t3 + 335544320 * t2
2227 - 402653184 * q + 267853681)
2228 / q;
2229 } else
2230 return -(38785.0 / 4096.0) * shambase::constants::pi<Tscal> / q;
2231 }
2232
2233 inline static Tscal phi_tilde_3d_prime(Tscal q) {
2234 Tscal t1 = sham::pow_constexpr<2>(q);
2235 Tscal t2 = sham::pow_constexpr<3>(q);
2236 Tscal t3 = sham::pow_constexpr<4>(q);
2237 Tscal t4 = sham::pow_constexpr<5>(q);
2238 Tscal t5 = sham::pow_constexpr<6>(q);
2239 if (q < 15.0 / 8.0) {
2240 return (4.0 / 3.0) * shambase::constants::pi<Tscal> * q;
2241 } else if (q < 31.0 / 16.0) {
2242 return (1.0 / 3840.0) * shambase::constants::pi<Tscal>
2243 * (9437184 * t4 - 67829760 * t3 + 173260800 * t2 - 165880320 * t1
2244 + 60721629)
2245 / q
2246 - (1.0 / 3840.0) * shambase::constants::pi<Tscal>
2247 * (1572864 * t5 - 13565952 * t4 + 43315200 * t3 - 55293440 * t2
2248 + 60721629 * q - 38728125)
2249 / t1;
2250 } else if (q < 2) {
2251 return (1.0 / 61440.0) * shambase::constants::pi<Tscal>
2252 * (-50331648 * t4 + 377487360 * t3 - 1006632960 * t2 + 1006632960 * t1
2253 - 402653184)
2254 / q
2255 - (1.0 / 61440.0) * shambase::constants::pi<Tscal>
2256 * (-8388608 * t5 + 75497472 * t4 - 251658240 * t3 + 335544320 * t2
2257 - 402653184 * q + 267853681)
2258 / t1;
2259 } else
2260 return (38785.0 / 4096.0) * shambase::constants::pi<Tscal> / t1;
2261 }
2262 };
2263} // namespace shammath::details
2264
2265namespace shammath {
2266
2267 // Type trait to detect if BaseKernel has phi_tilde_3d method
2268 template<typename T, typename Tscal, typename = void>
2269 struct has_phi_tilde_3d : std::false_type {};
2270
2271 template<typename T, typename Tscal>
2272 struct has_phi_tilde_3d<T, Tscal, std::void_t<decltype(T::phi_tilde_3d(std::declval<Tscal>()))>>
2273 : std::true_type {};
2274
2275 // Type trait to detect if BaseKernel has phi_tilde_3d_prime method
2276 template<typename T, typename Tscal, typename = void>
2277 struct has_phi_tilde_3d_prime : std::false_type {};
2278
2279 template<typename T, typename Tscal>
2281 T,
2282 Tscal,
2283 std::void_t<decltype(T::phi_tilde_3d_prime(std::declval<Tscal>()))>> : std::true_type {};
2284
2285 template<class Tscal_, class BaseKernel>
2287 public:
2288 using Generator = BaseKernel;
2289 using Tscal = Tscal_;
2290 inline static constexpr Tscal Rkern = BaseKernel::Rkern;
2291 inline static constexpr Tscal hfactd
2292 = BaseKernel::hfactd;
2302 inline static Tscal f(Tscal q) { return BaseKernel::f(q); }
2303
2310 inline static Tscal df(Tscal q) { return BaseKernel::df(q); }
2311
2312 inline static Tscal ddf(Tscal q) { return BaseKernel::ddf(q); }
2313
2314 inline static Tscal W_1d(Tscal r, Tscal h) { return BaseKernel::norm_1d * f(r / h) / (h); }
2315
2316 inline static Tscal W_2d(Tscal r, Tscal h) {
2317 return BaseKernel::norm_2d * f(r / h) / (h * h);
2318 }
2319
2329 inline static Tscal W_3d(Tscal r, Tscal h) {
2330 return BaseKernel::norm_3d * f(r / h) / (h * h * h);
2331 }
2332
2333 inline static Tscal dW_3d(Tscal r, Tscal h) {
2334 return BaseKernel::norm_3d * df(r / h) / (h * h * h * h);
2335 }
2336
2337 inline static Tscal ddW_3d(Tscal r, Tscal h) {
2338 return BaseKernel::norm_3d * ddf(r / h) / (h * h * h * h * h);
2339 }
2340
2341 inline static Tscal dhW_3d(Tscal r, Tscal h) {
2342 return -(BaseKernel::norm_3d) * (3 * f(r / h) + (r / h) * df(r / h)) / (h * h * h * h);
2343 }
2344
2345 inline static Tscal f3d_integ_z(Tscal x, int np = 32) {
2346 return integ_riemann_sum<Tscal>(-Rkern, Rkern, Rkern / np, [&](Tscal z) {
2347 return f(sqrt(x * x + z * z));
2348 });
2349 }
2350
2351 inline static Tscal Y_3d(Tscal r, Tscal h, int np = 32) {
2352 return BaseKernel::norm_3d * f3d_integ_z(r / h, np) / (h * h);
2353 }
2354
2355 static constexpr bool has_3d_phi_soft
2357
2358 inline static Tscal phi_tilde_3d(Tscal q) {
2359 if constexpr (has_3d_phi_soft) {
2360 return BaseKernel::phi_tilde_3d(q);
2361 } else {
2362 return std::numeric_limits<Tscal>::quiet_NaN();
2363 }
2364 }
2365
2366 static constexpr bool has_3d_phi_soft_prime
2368
2369 inline static Tscal phi_tilde_3d_prime(Tscal q) {
2370 if constexpr (has_3d_phi_soft_prime) {
2371 return BaseKernel::phi_tilde_3d_prime(q);
2372 } else {
2373 return std::numeric_limits<Tscal>::quiet_NaN();
2374 }
2375 }
2376
2377 inline static Tscal phi_3D(Tscal r, Tscal h) {
2378 return BaseKernel::norm_3d * phi_tilde_3d(r / h) / h;
2379 }
2380
2381 inline static Tscal phi_3D_prime(Tscal r, Tscal h) {
2382 return BaseKernel::norm_3d * phi_tilde_3d_prime(r / h) / (h * h);
2383 }
2384 };
2385
2392 template<class flt_type>
2394
2401 template<class flt_type>
2403
2410 template<class flt_type>
2412
2419 template<class flt_type>
2421
2428 template<class flt_type>
2430
2437 template<class flt_type>
2439
2446 template<class flt_type>
2448
2455 template<class flt_type>
2457
2464 template<class flt_type>
2466
2473 template<class flt_type>
2475
2481 template<class flt_type>
2483
2489 template<class flt_type>
2491
2498 template<class flt_type>
2500
2507 template<class flt_type>
2509
2516 template<class flt_type>
2518
2525 template<class flt_type>
2527
2534 template<class flt_type>
2536
2543 template<class flt_type>
2545
2552 template<class flt_type>
2554
2561 template<class flt_type>
2563
2564} // namespace shammath
2565
2566namespace shambase {
2567
2568 template<class flt_type>
2569 struct TypeNameInfo<shammath::M4<flt_type>> {
2570 inline static const std::string name = "M4<" + get_type_name<flt_type>() + ">";
2571 };
2572 template<class flt_type>
2573 struct TypeNameInfo<shammath::M5<flt_type>> {
2574 inline static const std::string name = "M5<" + get_type_name<flt_type>() + ">";
2575 };
2576 template<class flt_type>
2577 struct TypeNameInfo<shammath::M6<flt_type>> {
2578 inline static const std::string name = "M6<" + get_type_name<flt_type>() + ">";
2579 };
2580 template<class flt_type>
2581 struct TypeNameInfo<shammath::M7<flt_type>> {
2582 inline static const std::string name = "M7<" + get_type_name<flt_type>() + ">";
2583 };
2584 template<class flt_type>
2585 struct TypeNameInfo<shammath::M8<flt_type>> {
2586 inline static const std::string name = "M8<" + get_type_name<flt_type>() + ">";
2587 };
2588 template<class flt_type>
2589 struct TypeNameInfo<shammath::M9<flt_type>> {
2590 inline static const std::string name = "M9<" + get_type_name<flt_type>() + ">";
2591 };
2592 template<class flt_type>
2593 struct TypeNameInfo<shammath::M10<flt_type>> {
2594 inline static const std::string name = "M10<" + get_type_name<flt_type>() + ">";
2595 };
2596
2597 template<class flt_type>
2598 struct TypeNameInfo<shammath::C2<flt_type>> {
2599 inline static const std::string name = "C2<" + get_type_name<flt_type>() + ">";
2600 };
2601 template<class flt_type>
2602 struct TypeNameInfo<shammath::C4<flt_type>> {
2603 inline static const std::string name = "C4<" + get_type_name<flt_type>() + ">";
2604 };
2605 template<class flt_type>
2606 struct TypeNameInfo<shammath::C6<flt_type>> {
2607 inline static const std::string name = "C6<" + get_type_name<flt_type>() + ">";
2608 };
2609
2610 template<class flt_type>
2611 struct TypeNameInfo<shammath::TGauss3<flt_type>> {
2612 inline static const std::string name = "TGauss3<" + get_type_name<flt_type>() + ">";
2613 };
2614
2615 template<class flt_type>
2616 struct TypeNameInfo<shammath::TGauss5<flt_type>> {
2617 inline static const std::string name = "TGauss5<" + get_type_name<flt_type>() + ">";
2618 };
2619
2620 template<class flt_type>
2621 struct TypeNameInfo<shammath::M4DH<flt_type>> {
2622 inline static const std::string name = "M4DH<" + get_type_name<flt_type>() + ">";
2623 };
2624
2625 template<class flt_type>
2626 struct TypeNameInfo<shammath::M4DH3<flt_type>> {
2627 inline static const std::string name = "M4DH3<" + get_type_name<flt_type>() + ">";
2628 };
2629
2630 template<class flt_type>
2631 struct TypeNameInfo<shammath::M4DH5<flt_type>> {
2632 inline static const std::string name = "M4DH5<" + get_type_name<flt_type>() + ">";
2633 };
2634
2635 template<class flt_type>
2636 struct TypeNameInfo<shammath::M4DH7<flt_type>> {
2637 inline static const std::string name = "M4DH7<" + get_type_name<flt_type>() + ">";
2638 };
2639
2640 template<class flt_type>
2641 struct TypeNameInfo<shammath::M4Shift2<flt_type>> {
2642 inline static const std::string name = "M4Shift2<" + get_type_name<flt_type>() + ">";
2643 };
2644
2645 template<class flt_type>
2646 struct TypeNameInfo<shammath::M4Shift4<flt_type>> {
2647 inline static const std::string name = "M4Shift4<" + get_type_name<flt_type>() + ">";
2648 };
2649
2650 template<class flt_type>
2651 struct TypeNameInfo<shammath::M4Shift8<flt_type>> {
2652 inline static const std::string name = "M4Shift8<" + get_type_name<flt_type>() + ">";
2653 };
2654
2655 template<class flt_type>
2656 struct TypeNameInfo<shammath::M4Shift16<flt_type>> {
2657 inline static const std::string name = "M4Shift16<" + get_type_name<flt_type>() + ">";
2658 };
2659
2660} // namespace shambase
static Tscal W_3d(Tscal r, Tscal h)
compute the normed & resized version of the kernel :
static constexpr Tscal hfactd
static Tscal f(Tscal q)
the base function for this SPH kernel
static constexpr Tscal Rkern
static Tscal df(Tscal q)
derivative of M4::f
static constexpr Tscal norm_1d
1D norm of the kernel
static constexpr Tscal hfactd
default hfact to be used for this kernel
static constexpr Tscal norm_3d
3D norm of the kernel
static constexpr Tscal Rkern
static constexpr Tscal norm_2d
2D norm of the kernel
static constexpr Tscal norm_2d
2D norm of the kernel
static constexpr Tscal norm_3d
3D norm of the kernel
static constexpr Tscal Rkern
static constexpr Tscal norm_1d
1D norm of the kernel
static constexpr Tscal hfactd
default hfact to be used for this kernel
static constexpr Tscal norm_3d
3D norm of the kernel
static constexpr Tscal norm_1d
1D norm of the kernel
static constexpr Tscal hfactd
default hfact to be used for this kernel
static constexpr Tscal Rkern
static constexpr Tscal norm_2d
2D norm of the kernel
static constexpr Tscal norm_1d
1D norm of the kernel
static constexpr Tscal hfactd
default hfact to be used for this kernel
static constexpr Tscal norm_3d
3D norm of the kernel
static constexpr Tscal Rkern
static constexpr Tscal norm_2d
2D norm of the kernel
static constexpr Tscal hfactd
default hfact to be used for this kernel
static constexpr Tscal norm_2d
2D norm of the kernel
static constexpr Tscal norm_1d
1D norm of the kernel
static constexpr Tscal norm_3d
3D norm of the kernel
static constexpr Tscal norm_3d
3D norm of the kernel
static constexpr Tscal norm_2d
2D norm of the kernel
static constexpr Tscal norm_1d
1D norm of the kernel
static constexpr Tscal hfactd
default hfact to be used for this kernel
static constexpr Tscal norm_1d
1D norm of the kernel
static constexpr Tscal hfactd
default hfact to be used for this kernel
static constexpr Tscal norm_3d
3D norm of the kernel
static constexpr Tscal norm_2d
2D norm of the kernel
static constexpr Tscal hfactd
default hfact to be used for this kernel
static constexpr Tscal norm_1d
1D norm of the kernel
static constexpr Tscal norm_2d
2D norm of the kernel
static constexpr Tscal norm_3d
3D norm of the kernel
static constexpr Tscal norm_1d
1D norm of the kernel
static constexpr Tscal norm_2d
2D norm of the kernel
static constexpr Tscal hfactd
default hfact to be used for this kernel
static constexpr Tscal norm_3d
3D norm of the kernel
static constexpr Tscal norm_2d
2D norm of the kernel
static constexpr Tscal norm_3d
3D norm of the kernel
static constexpr Tscal norm_1d
1D norm of the kernel
static constexpr Tscal hfactd
default hfact to be used for this kernel
static constexpr Tscal norm_1d
1D norm of the kernel
static constexpr Tscal norm_3d
3D norm of the kernel
static constexpr Tscal norm_2d
2D norm of the kernel
static constexpr Tscal hfactd
default hfact to be used for this kernel
static constexpr Tscal norm_2d
2D norm of the kernel
static constexpr Tscal norm_1d
1D norm of the kernel
static constexpr Tscal norm_3d
3D norm of the kernel
static constexpr Tscal hfactd
default hfact to be used for this kernel
static constexpr Tscal norm_2d
2D norm of the kernel
static constexpr Tscal norm_3d
3D norm of the kernel
static constexpr Tscal hfactd
default hfact to be used for this kernel
static constexpr Tscal norm_1d
1D norm of the kernel
static constexpr Tscal Rkern
static constexpr Tscal norm_2d
2D norm of the kernel
static constexpr Tscal Rkern
static constexpr Tscal norm_1d
1D norm of the kernel
static constexpr Tscal norm_3d
3D norm of the kernel
static constexpr Tscal hfactd
default hfact to be used for this kernel
static constexpr Tscal norm_1d
1D norm of the kernel
static constexpr Tscal hfactd
default hfact to be used for this kernel
static constexpr Tscal Rkern
static constexpr Tscal norm_2d
2D norm of the kernel
static constexpr Tscal norm_3d
3D norm of the kernel
static constexpr Tscal Rkern
static constexpr Tscal norm_1d
1D norm of the kernel
static constexpr Tscal hfactd
default hfact to be used for this kernel
static constexpr Tscal norm_2d
2D norm of the kernel
static constexpr Tscal norm_3d
3D norm of the kernel
static constexpr Tscal norm_1d
1D norm of the kernel
static constexpr Tscal hfactd
default hfact to be used for this kernel
static constexpr Tscal Rkern
static constexpr Tscal norm_3d
3D norm of the kernel
static constexpr Tscal norm_2d
2D norm of the kernel
static constexpr Tscal norm_3d
3D norm of the kernel
static constexpr Tscal norm_2d
2D norm of the kernel
static constexpr Tscal norm_1d
1D norm of the kernel
static constexpr Tscal Rkern
static constexpr Tscal hfactd
default hfact to be used for this kernel
Truncated Gaussian kernel with compact support R=3h.
static constexpr Tscal norm_1d
1D norm of the kernel
static constexpr Tscal norm_3d
3D norm of the kernel
static constexpr Tscal norm_2d
2D norm of the kernel (accounts for truncation at q=3)
static constexpr Tscal hfactd
default hfact to be used for this kernel
static constexpr Tscal Rkern
Compact support radius of the kernel.
Truncated Gaussian kernel with compact support R=5h.
static constexpr Tscal norm_2d
2D norm of the kernel
static constexpr Tscal norm_1d
1D norm of the kernel
static constexpr Tscal Rkern
Compact support radius of the kernel.
static constexpr Tscal norm_3d
3D norm of the kernel
static constexpr Tscal hfactd
default hfact to be used for this kernel
Class holding the value of numerous constants generated from the following source.
namespace for basic c++ utilities
void throw_with_loc(std::string message, SourceLocation loc=SourceLocation{})
Throw an exception and append the source location to it.
namespace for math utility
Definition AABB.hpp:26
STL namespace.