Use C++11 erf/erfc instead of custom one

time-shift
Sébastien Villemot 2019-01-08 17:49:15 +01:00
parent ba609cce07
commit 8b56ab6f11
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
1 changed files with 2 additions and 13 deletions

View File

@ -11,17 +11,6 @@
using namespace ogp;
/** Here we just implement complementary error function without
* declaring it for uses from outside this unit. The implementation is taken from "Numerical Recipes in C" 2nd ed. 1992 p. 221, */
double
erffc(double x)
{
double z = std::abs(x);
double t = 1/(1+0.5*z);
double r = t*exp(-z*z-1.26551223+t*(1.00002368+t*(0.37409196+t*(0.09678418+t*(-0.18628806+t*(0.27886807+t*(-1.13520398+t*(1.48851587+t*(-0.82215223+t*0.17087277)))))))));
return x >= 0 ? r : 2-r;
}
/** Here we initialize OperationTree to contain only zero, one, nan
* and two_over_pi terms. */
OperationTree::OperationTree()
@ -620,9 +609,9 @@ EvalTree::eval(int t)
else if (op.getCode() == SQRT)
res = sqrt(r1);
else if (op.getCode() == ERF)
res = 1-erffc(r1);
res = erf(r1);
else if (op.getCode() == ERFC)
res = erffc(r1);
res = erfc(r1);
else
{
throw ogu::Exception(__FILE__, __LINE__,