3 #include <unordered_map>
13 * Use dynamic programming / recursion
17 static unordered_map<int, int> dp;
18 static bool init = false;
27 int result = n*Factorial(n-1);
33 * Binomial coefficients
35 int BinomialCoeff(int n, int k)
37 return Factorial(n) / Factorial(k) / Factorial(n-k);
41 * Bernstein Basis Polynomial
43 Real Bernstein(int k, int n, const Real & u)
45 return Real(BinomialCoeff(n, k)) * pow(u, k) * pow(Real(1.0) - u, n-k);