From: David Wells Date: Sat, 29 Aug 2015 17:33:54 +0000 (-0400) Subject: Compute powers of -1 by checking exponent parity. X-Git-Tag: v8.4.0-rc2~521^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0c6450f69b1c9a0e99d0e34968342d05b8a99882;p=dealii.git Compute powers of -1 by checking exponent parity. --- diff --git a/source/base/polynomials_bernstein.cc b/source/base/polynomials_bernstein.cc index c9c3e8849b..942d3e9314 100644 --- a/source/base/polynomials_bernstein.cc +++ b/source/base/polynomials_bernstein.cc @@ -18,7 +18,7 @@ namespace Binomial 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)) + coeff[i] = ((i - k) % 2 == 0 ? 1 : -1) * boost::math::binomial_coefficient(n, i) * boost::math::binomial_coefficient(i, k); }