From: David Wells Date: Sat, 29 Aug 2015 17:32:16 +0000 (-0400) Subject: Use the boost implementation of binomials. X-Git-Tag: v8.4.0-rc2~521^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=64fa4273255327209a47efbb2b641d9bcce99131;p=dealii.git Use the boost implementation of binomials. --- diff --git a/source/base/polynomials_bernstein.cc b/source/base/polynomials_bernstein.cc index f32cdb3da6..c9c3e8849b 100644 --- a/source/base/polynomials_bernstein.cc +++ b/source/base/polynomials_bernstein.cc @@ -1,34 +1,13 @@ - #include + +#include + #include 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 std::vector get_bernstein_coefficients ( @@ -38,11 +17,13 @@ namespace Binomial AssertIndexRange(k, n+1); std::vector 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(n, i) + * boost::math::binomial_coefficient(i, k); + } return coeff; } - } template