From 8b56ab6f11807bf4a452dc64d31d5ba35785a258 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Tue, 8 Jan 2019 17:49:15 +0100 Subject: [PATCH] Use C++11 erf/erfc instead of custom one --- dynare++/parser/cc/tree.cc | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/dynare++/parser/cc/tree.cc b/dynare++/parser/cc/tree.cc index efd6b97cf..8209e9c0c 100644 --- a/dynare++/parser/cc/tree.cc +++ b/dynare++/parser/cc/tree.cc @@ -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__,