-
#include <deal.II/base/polynomials_bernstein.h>
+
+#include <boost/math/special_functions/binomial.hpp>
+
#include <vector>
DEAL_II_NAMESPACE_OPEN
namespace Binomial
{
- unsigned int
- factorial (
- unsigned int k)
- {
- if (k > 1)
- return k * factorial(k - 1);
- else
- return 1;
- }
-
- inline unsigned int
- binomial (
- const unsigned int nValue, const unsigned int nValue2)
- {
- Assert(nValue >= nValue2,
- ExcMessage("nValue should be greater or equal than nValue2"));
- if (nValue2 == 1)
- return nValue;
- else
- return ((factorial(nValue))
- / (factorial(nValue2) * factorial((nValue - nValue2))));
- }
-
template <typename number>
std::vector<number>
get_bernstein_coefficients (
AssertIndexRange(k, n+1);
std::vector<number> coeff(n + 1, number(0.0));
for (unsigned int i = k; i < n + 1; ++i)
- coeff[i] = (pow(number(-1), number(i - k)) * binomial(n, i)
- * binomial(i, k));
+ {
+ coeff[i] = pow(number(-1), number(i - k))
+ * boost::math::binomial_coefficient<number>(n, i)
+ * boost::math::binomial_coefficient<number>(i, k);
+ }
return coeff;
}
-
}
template <typename number>