sc/qa/unit/data/functions/mathematical/fods/atan2.fods |   16 ++++++++++++----
 sc/source/core/opencl/op_math.cxx                      |    2 ++
 sc/source/core/opencl/opinlinefun_math.hxx             |    2 +-
 3 files changed, 15 insertions(+), 5 deletions(-)

New commits:
commit 218b288d0ca32e4372f546b143fa71542f75dcd0
Author:     Luboš Luňák <l.lu...@collabora.com>
AuthorDate: Thu Sep 1 13:53:19 2022 +0200
Commit:     Luboš Luňák <l.lu...@collabora.com>
CommitDate: Tue Sep 6 12:02:50 2022 +0200

    fix opencl trigonometric functions
    
    Change-Id: Iacdae9fceff2feb198bd722e7e58e5e6dff5facc
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139194
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lu...@collabora.com>

diff --git a/sc/qa/unit/data/functions/mathematical/fods/atan2.fods 
b/sc/qa/unit/data/functions/mathematical/fods/atan2.fods
index 4e11319cd652..b78437d3ed93 100644
--- a/sc/qa/unit/data/functions/mathematical/fods/atan2.fods
+++ b/sc/qa/unit/data/functions/mathematical/fods/atan2.fods
@@ -1925,10 +1925,18 @@
      <table:table-cell table:number-columns-repeated="5"/>
     </table:table-row>
     <table:table-row table:style-name="ro2">
-     <table:table-cell table:style-name="ce12"/>
-     <table:table-cell/>
-     <table:table-cell table:style-name="ce21"/>
-     <table:table-cell table:style-name="ce26"/>
+     <table:table-cell table:style-name="ce12" table:formula="of:=ATAN2(0;0)" 
office:value-type="float" office:value="0" calcext:value-type="float">
+      <text:p>0</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="float" office:value="0" 
calcext:value-type="float">
+      <text:p>0</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce21" 
table:formula="of:=[.A11]=[.B11]" office:value-type="boolean" 
office:boolean-value="true" calcext:value-type="boolean">
+      <text:p>TRUE</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce26" 
table:formula="of:=FORMULA([.A11])" office:value-type="string" 
office:string-value="=ATAN2(0;0)" calcext:value-type="string">
+      <text:p>=ATAN2(0;0)</text:p>
+     </table:table-cell>
      <table:table-cell table:style-name="ce28"/>
      <table:table-cell table:number-columns-repeated="4"/>
      <table:table-cell table:formula="of:=PI()" office:value-type="float" 
office:value="3.14159265358979" calcext:value-type="float">
diff --git a/sc/source/core/opencl/op_math.cxx 
b/sc/source/core/opencl/op_math.cxx
index dd70241c5f41..744c360a75bc 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -1094,6 +1094,8 @@ void OpArcCosHyp::GenSlidingWindowFunction(outputstream 
&ss,
         ss << ";\n";
     }
 
+    ss << "    if( tmp < 1 )\n";
+    ss << "        return CreateDoubleError(IllegalArgument);\n";
     ss << "    return  log( tmp + pow( (pown(tmp, 2) - 1.0), 0.5));\n";
     ss << "}";
 }
diff --git a/sc/source/core/opencl/opinlinefun_math.hxx 
b/sc/source/core/opencl/opinlinefun_math.hxx
index dc962b4635f1..0160671ed164 100644
--- a/sc/source/core/opencl/opinlinefun_math.hxx
+++ b/sc/source/core/opencl/opinlinefun_math.hxx
@@ -62,7 +62,7 @@ std::string atan2Content =
 "double arctan2(double y, double x)\n"
 "{\n"
 "    if(y==0.0)\n"
-"        return 0.0;\n"
+"        return x >= 0 ? 0.0 : M_PI;\n"
 "    double a,num,den,tmpPi;\n"
 "    int flag;\n"
 "    tmpPi = 0;\n"

Reply via email to