I found a template to calculate the binomial coefficient, which I happily used for function generation. The advantage is that I use this template for compile time Bernstein polynomial generation instead of using the derived polynomials (just 5 very simple ones).
I initially thought the code would become easier by doing so because the generation of the five random functions now obvious. Unfortunately, the code below is hard to read for someone not used to templates. Is there a way to get rid of at least some of the template specializations?
// Template functions to estimate the binominal coefficient
template<uint8_t n, uint8_t k>
struct binomial {
static constexpr int value = (binomial<n - 1, k - 1>::value + binomial<n - 1, k>::value);
};
template<>
struct binomial<0, 0> {
static constexpr int value = 1;
};
template<uint8_t n>
struct binomial<n, 0> {
static constexpr int value = 1;
};
template<uint8_t n>
struct binomial<n, n> {
static constexpr int value = 1;
};