[gnumeric] R.PGAMMA: fix extreme-value case.



commit 20b73c3ca08d05c2ca7a860d7a31ca346443af37
Author: Morten Welinder <terra gnome org>
Date:   Sat Nov 14 20:19:15 2009 -0500

    R.PGAMMA: fix extreme-value case.

 ChangeLog      |    6 ++++++
 NEWS           |    1 +
 src/mathfunc.c |    4 ++--
 3 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 012a264..d85cbb0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-11-14  Morten Welinder  <terra gnome org>
+
+	* src/mathfunc.c (pd_lower_cf): Fix convergence test.  Test case is
+	R.PGAMMA(X,1e-20,1,FALSE) with visible discontinuity at X=1.
+	Reported by the R team.
+
 2009-11-14  Andreas J. Guelzow <aguelzow pyrshep ca>
 
 	* configure.in: check for gtk_entry_get_buffer (We need to use it to
diff --git a/NEWS b/NEWS
index 00d3f3d..0e234d0 100644
--- a/NEWS
+++ b/NEWS
@@ -21,6 +21,7 @@ Morten:
 	* Fix problem with remote uris.  [#601274]
 	* Use external solver program.
 	* Allow constants on solver constraints' rhs.  [#369728]
+	* Fix extreme case for R.PGAMMA.
 
 --------------------------------------------------------------------------
 Gnumeric 1.9.15
diff --git a/src/mathfunc.c b/src/mathfunc.c
index 6881fa4..42a3608 100644
--- a/src/mathfunc.c
+++ b/src/mathfunc.c
@@ -1536,7 +1536,7 @@ pd_upper_series (gnm_float x, gnm_float y, gboolean log_p)
 static gnm_float
 pd_lower_cf (gnm_float i, gnm_float d)
 {
-    gnm_float f = 0, of;
+    gnm_float f = -42, of, rf = i / d;
 
     gnm_float c1 = 0, c2, c3, c4;
     gnm_float a1 = 0, b1 = 1;
@@ -1585,7 +1585,7 @@ pd_lower_cf (gnm_float i, gnm_float d)
 	    of = f;
 	    f = a2 / b2;
 	    /* convergence check: relative; absolute for small f : */
-	    if (gnm_abs (f - of) <= GNM_EPSILON * fmax2(1., gnm_abs(f)))
+	    if (gnm_abs (f - of) <= GNM_EPSILON * fmax2(rf, gnm_abs(f)))
 		return f;
 	}
     }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]