bugGNU Scientific Library - Bugs: bug #31854, A divide by zero in the...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #31854: A divide by zero in the gsl_ran_gamma_knuth()

Submitted by:  Myoung-serp. Shin. <relent95>
Submitted on:  Sun 12 Dec 2010 04:47:09 PM UTC  
 
Category:  Runtime error Severity:  3 - Normal
Operating System:  Status:  Fixed
Assigned to:  None Open/Closed:  Closed
Release:  1.14

Wed 15 Dec 2010 08:37:04 PM UTC, comment #2:

This is now fixed in r4706.  Thanks for the bug report!

=== modified file 'randist/gamma.c'
--- randist/gamma.c 2008-11-30 09:00:46 +0000
+++ randist/gamma.c 2010-12-14 21:53:37 +0000
@@ -120,6 +120,11 @@
      on page 551.  */

   double p, q, x, u, v;
+
+  if (a == 0) {
+    return 0;
+  }
+
   p = M_E / (a + M_E);
   do
     {

-Deleted Account- <bjg>
Mon 13 Dec 2010 07:54:17 PM UTC, comment #1:

Thanks for the bug report.  I guess we should just return 0 immediately from gamma_frac when a=0.

-Deleted Account- <bjg>
Sun 12 Dec 2010 04:47:09 PM UTC, original submission:

The following lines of the randist/gamma.c calls gamma_frac(r, 0) if a is an integer.

double
gsl_ran_gamma_knuth (const gsl_rng * r, const double a, const double b)
...
  if(a >= UINT_MAX)
    {
      return b * (gamma_large (r, floor (a)) + gamma_frac (r, a - floor (a)));
    }
...

And as the following, the argument a of the gamma_frac() shouldn't be zero.

static double
gamma_frac (const gsl_rng * r, const double a)
{
...
          x = exp ((1 / a) * log (v));
...
}

Myoung-serp. Shin. <relent95>

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by relent95 (Submitted the item)
  •  

     

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2010-12-15 bjg StatusConfirmed => Fixed
        Open/ClosedOpen => Closed
    2010-12-13 bjg StatusNone => Confirmed

    Back to the top


    Powered by Savane 3.4