24 template <std::
floating_po
int T, std::
size_t max_order,
bool use_table = false>
class Legendre 27 std::array<T, max_order + 1> y;
28 std::array<T, max_order + 1> P;
33 if constexpr (use_table) {
34 for (std::size_t i = 1; i < max_order; ++i) {
35 y[i] = 1.0 + 1.0 /
T(i);
43 if constexpr (max_order > 0) {
45 for (std::size_t i = 1; i < max_order; ++i) {
46 if constexpr (use_table) {
47 P[i + 1] = ((y[i] + 1.0) * x * P[i] - P[i - 1]) / y[i];
50 P[i + 1] = ((2.0 + 1.0 /
T(i)) * x * P[i] - P[i - 1]) / (1.0 + 1.0 /
T(i));
57 #ifdef DOCTEST_LIBRARY_INCLUDED__ 61 using doctest::Approx;
65 CHECK_EQ(P[0], Approx(1));
66 CHECK_EQ(P[1], Approx(x));
67 CHECK_EQ(P[2], Approx(0.5 * (3 * x * x - 1)));
68 CHECK_EQ(P[3], Approx(0.5 * (5 * x * x * x - 3 * x)));
double T
floating point size
Definition: units.h:73
const auto & eval(T x)
Evaluate polynomials at x.
Definition: legendre.h:41
Cell list class templates.
Definition: actions.cpp:11
Evaluate n'th degree Legendre polynomial.
Definition: legendre.h:24