From c13a19d462ef595201447272e357a65f5c005521 Mon Sep 17 00:00:00 2001 From: Eike Rathke Date: Thu, 6 Oct 2016 17:48:40 +0200 Subject: remove approxEqual() from OpenCL It's only use was approxEqual(value,0.0) which doesn't yield true for any other value than 0.0, so replace with value==0.0 Change-Id: I9f4f496c94c2a24e934a1d33c070a070e4f2e1c6 Reviewed-on: https://gerrit.libreoffice.org/29576 Reviewed-by: Tor Lillqvist Tested-by: Tor Lillqvist --- sc/source/core/opencl/op_financial.cxx | 12 ++++++------ sc/source/core/opencl/opinlinefun_finacial.cxx | 16 ---------------- 2 files changed, 6 insertions(+), 22 deletions(-) (limited to 'sc/source') diff --git a/sc/source/core/opencl/op_financial.cxx b/sc/source/core/opencl/op_financial.cxx index 771635510c54..fce903e8e7ab 100644 --- a/sc/source/core/opencl/op_financial.cxx +++ b/sc/source/core/opencl/op_financial.cxx @@ -4067,9 +4067,9 @@ void OpTbillprice::GenSlidingWindowFunction( void RATE::BinInlineFun(std::set& decls, std::set& funs) { - decls.insert(approxEqualDecl);decls.insert(nKorrValDecl); + decls.insert(nKorrValDecl); decls.insert(SCdEpsilonDecl);decls.insert(RoundDecl); - funs.insert(approxEqual);funs.insert(Round); + funs.insert(Round); } void RATE::GenSlidingWindowFunction( @@ -4127,7 +4127,7 @@ void RATE::GenSlidingWindowFunction( ss << " {\n"; ss << " fPowNminus1 = pow( 1.0+fX, arg0-1.0);\n"; ss << " fPowN = fPowNminus1 * (1.0+fX);\n"; - ss << " if (approxEqual( fabs(fX), 0.0))\n"; + ss << " if (fX == 0.0)\n"; ss << " {\n"; ss << " fGeoSeries = arg0;\n"; ss << " fGeoSeriesDerivation = arg0 * (arg0-1.0)"; @@ -4146,7 +4146,7 @@ void RATE::GenSlidingWindowFunction( ss << " bFound = true;\n"; ss << " else\n"; ss << " {\n"; - ss << " if (approxEqual(fabs(fTermDerivation), 0.0))\n"; + ss << " if (fTermDerivation == 0.0)\n"; ss << " fXnew = fX + 1.1 * SCdEpsilon;\n"; ss << " else\n"; ss << " fXnew = fX - fTerm "; @@ -4162,7 +4162,7 @@ void RATE::GenSlidingWindowFunction( ss << " fX = (arg5 < -1.0) ? -1.0 : arg5;\n"; ss << " while (bValid && !bFound && nCount < nIterationsMax)\n"; ss << " {\n"; - ss << " if (approxEqual(fabs(fX), 0.0)){\n"; + ss << " if (fX == 0.0){\n"; ss << " fGeoSeries = arg0;\n"; ss << " fGeoSeriesDerivation = arg0 * "; ss << "(arg0-1.0)* pow(2.0,-1);\n"; @@ -4181,7 +4181,7 @@ void RATE::GenSlidingWindowFunction( ss << " if (fabs(fTerm) < fEpsilonSmall)\n"; ss << " bFound = true;\n"; ss << " else{\n"; - ss << " if (approxEqual(fabs(fTermDerivation), 0.0))\n"; + ss << " if (fTermDerivation == 0.0)\n"; ss << " fXnew = fX + 1.1 * SCdEpsilon;\n"; ss << " else\n"; ss << " fXnew = fX - fTerm "; diff --git a/sc/source/core/opencl/opinlinefun_finacial.cxx b/sc/source/core/opencl/opinlinefun_finacial.cxx index 63d8a775b9c9..e57da04f50f3 100644 --- a/sc/source/core/opencl/opinlinefun_finacial.cxx +++ b/sc/source/core/opencl/opinlinefun_finacial.cxx @@ -9,22 +9,6 @@ #ifndef SC_OPENCL_OPINLINFUN_finacial #define SC_OPENCL_OPINLINFUN_finacial -std::string approxEqualDecl="bool approxEqual(double a, double b);\n"; - -// FIXME: this approxEqual() is identical to what the C++ rtl_math_approxEqual() used to be, but -// that has been improved in the meantime, so probably this should be, too? OTOH, this is used only -// to compare against 0.0, so could be made much simpler, and actually questionable whether it works -// as intended anyway. - -std::string approxEqual = -"bool approxEqual(double a, double b)\n" -"{\n" -" if (a == b)\n" -" return true;\n" -" double x = a - b;\n" -" return (x < 0.0 ? -x : x) < ((a < 0.0 ? -a : a) * (1.0 / (16777216.0 *" -"16777216.0)));\n" -"}\n"; std::string nKorrValDecl ="double constant nKorrVal[]" "= {0, 9e-1, 9e-2, 9e-3, 9e-4, 9e-5, 9e-6, 9e-7, " -- cgit