template<size_t K>
Rodin::Variational::LegendrePolynomial class

Compile-time degree Legendre polynomial evaluator.

Template parameters
K Polynomial degree of the Legendre polynomial $ P_K $ .

This class provides an efficient and numerically stable evaluation of the Legendre polynomial $ P_K(x) $ and its derivative $ P'_K(x) $ on the interval $ [-1, 1] $ , using the standard three-term recurrence relation and its differentiated form.

The polynomial degree $ K $ is encoded as a template parameter, which allows the compiler to optimize and possibly unroll the recurrence for fixed degrees typically used in high-order finite element methods.

This evaluator is intended for internal use in the construction of modal bases and Gauss–Lobatto–Legendre nodes for H1-conforming elements.

Public static functions

static void getValue(Real& P, Real& dP, Real x) constexpr
Computes $ P_K(x) $ and $ P'_K(x) $ using the three-term recurrence relation.

Function documentation

template<size_t K>
static void Rodin::Variational::LegendrePolynomial<K>::getValue(Real& P, Real& dP, Real x) constexpr

Computes $ P_K(x) $ and $ P'_K(x) $ using the three-term recurrence relation.

Parameters
out Value of $ P_K(x) $ .
dP out Value of $ P'_K(x) $ .
x Evaluation point (assumed in $ [-1, 1] $ ).

For $ K = 0 $ and $ K = 1 $ , explicit closed forms are used: $ P_0(x) = 1 $ , $ P_1(x) = x $ . For $ K \ge 2 $ , the standard recurrence

\[ (k + 1) P_{k + 1}(x) = (2k + 1)\,x\,P_k(x) - k\,P_{k - 1}(x) \]

and its derivative are used to advance from $ P_0, P_1 $ up to $ P_K $ .

The evaluation is intended for arguments $ x \in [-1, 1] $ .