[Libreoffice-commits] core.git: sc/source

Eike Rathke erack at redhat.com
Thu Oct 6 16:01:28 UTC 2016


 sc/source/core/opencl/op_financial.cxx         |   12 ++++++------
 sc/source/core/opencl/opinlinefun_finacial.cxx |   16 ----------------
 2 files changed, 6 insertions(+), 22 deletions(-)

New commits:
commit c13a19d462ef595201447272e357a65f5c005521
Author: Eike Rathke <erack at redhat.com>
Date:   Thu Oct 6 17:48:40 2016 +0200

    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 <tml at collabora.com>
    Tested-by: Tor Lillqvist <tml at collabora.com>

diff --git a/sc/source/core/opencl/op_financial.cxx b/sc/source/core/opencl/op_financial.cxx
index 7716355..fce903e 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<std::string>& decls,
     std::set<std::string>& 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 63d8a77..e57da04 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, "


More information about the Libreoffice-commits mailing list