54 auto constexpr epsilon = T(0.1);
55#if not defined(__CUDACC__)
59 auto const pix = std::numbers::pi_v<T> * x;
62 return sin(pix) / pix;
64 auto constexpr factorial = [](
int n)
consteval {
73 auto constexpr c0 = T(+1) / T(factorial(1));
74 auto constexpr c2 = T(-1) / T(factorial(3));
75 auto constexpr c4 = T(+1) / T(factorial(5));
76 auto constexpr c6 = T(-1) / T(factorial(7));
77 auto constexpr c8 = T(+1) / T(factorial(9));
79 auto const pix2 = pix * pix;
80 return c0 + pix2 * (c2 + pix2 * (c4 + pix2 * (c6 + pix2 * c8)));
94 static_assert(cao >= 1 and cao <= 7);
95#if not defined(__CUDACC__)
98 auto const theta =
static_cast<double>(n) * mesh_i * std::numbers::pi;
101 if constexpr (cao == 1) {
104 if constexpr (cao == 2) {
105 return (1. + c * 2.) / 3.;
107 if constexpr (cao == 3) {
108 return (2. + c * (11. + c * 2.)) / 15.;
110 if constexpr (cao == 4) {
111 return (17. + c * (180. + c * (114. + c * 4.))) / 315.;
113 if constexpr (cao == 5) {
114 return (62. + c * (1072. + c * (1452. + c * (247. + c * 2.)))) / 2835.;
116 if constexpr (cao == 6) {
118 c * (35396. + c * (83021. + c * (34096. + c * (2026. + c * 4.))))) /
124 c * (2123860. + c * (349500. + c * (8166. + c * 4.)))))) /
129 decltype(&analytic_cotangent_sum<1>) ptr =
nullptr;
131 ptr = &analytic_cotangent_sum<1>;
132 }
else if (cao == 2) {
133 ptr = &analytic_cotangent_sum<2>;
134 }
else if (cao == 3) {
135 ptr = &analytic_cotangent_sum<3>;
136 }
else if (cao == 4) {
137 ptr = &analytic_cotangent_sum<4>;
138 }
else if (cao == 5) {
139 ptr = &analytic_cotangent_sum<5>;
140 }
else if (cao == 6) {
141 ptr = &analytic_cotangent_sum<6>;
142 }
else if (cao == 7) {
143 ptr = &analytic_cotangent_sum<7>;
145 if (ptr ==
nullptr) {
146 throw std::logic_error(
"Invalid value cao=" + std::to_string(cao));