Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index


Hallo,
In the ODF 1.2 specification stand , that the GAMMADIST Function only for x < 0 0 returns. The case x > 0 was ok, but there is the special case x == 0. I've tried to implement this.

greetings
Wolfgang
From 6c45fe24805cf9eba135d3f28b0ddada35806cd5 Mon Sep 17 00:00:00 2001
From: Wolfgang Pechlaner <wope@melmak.(none)>
Date: Mon, 12 Sep 2011 10:52:12 +0200
Subject: [PATCH]        modified:   sc/source/core/tool/interpr6.cxx

---
 sc/source/core/tool/interpr6.cxx |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/sc/source/core/tool/interpr6.cxx b/sc/source/core/tool/interpr6.cxx
index abd6f18..df5a4be 100644
--- a/sc/source/core/tool/interpr6.cxx
+++ b/sc/source/core/tool/interpr6.cxx
@@ -152,8 +152,25 @@ double ScInterpreter::GetUpRegIGamma( double fA, double fX )
 double ScInterpreter::GetGammaDistPDF( double fX, double fAlpha, double fLambda )
 {
     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::GetGammaDistPDF" );
-    if (fX <= 0.0)
+    if (fX < 0.0)
         return 0.0;     // see ODFF
+    else if (fX == 0)  
+        // in this case 0^0 isn't zero
+    {
+        if (fAlpha < 1.0)
+        {
+            SetError(errDivisionByZero);  // should be #DIV/0
+            return HUGE_VAL;
+        }
+        else if (fAlpha == 1)
+        {
+            return (1.0 / fLambda);
+        }
+        else
+        {
+            return 0.0;
+        }
+    }       
     else
     {
         double fXr = fX / fLambda;
-- 
1.7.3.4


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.