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 errorSeverity: 3 - Normal
Operating System: Status: Fixed
Assigned to: NoneOpen/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
  • -unavailable- added by relent95 (Submitted the item)
  •  

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 15 Dec 2010 08:37:04 PM UTCbjgStatusConfirmed=>Fixed
      Open/ClosedOpen=>Closed
    Mon 13 Dec 2010 07:54:17 PM UTCbjgStatusNone=>Confirmed

    Back to the top


    Powered by Savane 3.1-cleanup1