From 6ca0b4704367f8804e0373cb439e6e17e5146e4a Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Fri, 15 Nov 2019 14:00:18 +0100 Subject: Issue #1291 - Part 2: Stop using the lib's sqrt() function Use 's functions over fdlibm's for performance reasons. No significant precision loss when doing this. --- modules/fdlibm/src/e_hypot.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'modules/fdlibm/src/e_hypot.cpp') diff --git a/modules/fdlibm/src/e_hypot.cpp b/modules/fdlibm/src/e_hypot.cpp index f5c7037bb..b34a1f575 100644 --- a/modules/fdlibm/src/e_hypot.cpp +++ b/modules/fdlibm/src/e_hypot.cpp @@ -46,6 +46,7 @@ * than 1 ulps (units in the last place) */ +#include #include #include "math_private.h" @@ -105,7 +106,7 @@ __ieee754_hypot(double x, double y) t1 = 0; SET_HIGH_WORD(t1,ha); t2 = a-t1; - w = sqrt(t1*t1-(b*(-b)-t2*(a+t1))); + w = std::sqrt(t1*t1-(b*(-b)-t2*(a+t1))); } else { a = a+a; y1 = 0; @@ -114,7 +115,7 @@ __ieee754_hypot(double x, double y) t1 = 0; SET_HIGH_WORD(t1,ha+0x00100000); t2 = a - t1; - w = sqrt(t1*y1-(w*(-w)-(t1*y2+t2*b))); + w = std::sqrt(t1*y1-(w*(-w)-(t1*y2+t2*b))); } if(k!=0) { u_int32_t high; -- cgit v1.2.3 From 5e902a4a9a25a9e151b5d3945c68517bc0c73139 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Fri, 15 Nov 2019 15:17:01 +0100 Subject: Issue #1291 - Part 3: Update fdlibm to Sept 2019 version --- modules/fdlibm/src/e_hypot.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules/fdlibm/src/e_hypot.cpp') diff --git a/modules/fdlibm/src/e_hypot.cpp b/modules/fdlibm/src/e_hypot.cpp index b34a1f575..a23571150 100644 --- a/modules/fdlibm/src/e_hypot.cpp +++ b/modules/fdlibm/src/e_hypot.cpp @@ -70,7 +70,7 @@ __ieee754_hypot(double x, double y) if(ha >= 0x7ff00000) { /* Inf or NaN */ u_int32_t low; /* Use original arg order iff result is NaN; quieten sNaNs. */ - w = fabs(x+0.0)-fabs(y+0.0); + w = fabsl(x+0.0L)-fabs(y+0); GET_LOW_WORD(low,a); if(((ha&0xfffff)|low)==0) w = a; GET_LOW_WORD(low,b); -- cgit v1.2.3