bugGNU Octave - Bugs: bug #30824, gammaln(0) and gammaln((minus...

 
 

bug #30824: gammaln(0) and gammaln((minus integer)) give slatec error

Submitted by:  Tatsuro MATSUOKA <tmacchant>
Submitted on:  Fri 20 Aug 2010 12:48:37 AM UTC  
 
Category: LibrariesSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: FixedAssigned to: None
Originator Name: Tatsuro MATSUOKAOpen/Closed: Closed
Release: 3.3.52Operating System: Microsoft Windows

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Sat 21 Aug 2010 06:06:41 PM UTC, comment #1:

Yes, you are right. The documentation for GNU GAMMA specifies that x must not be zero or a negative integer (http://gcc.gnu.org/onlinedocs/gfortran/LOG_005fGAMMA.html#LOG_005fGAMMA). I have applied your patch in this changeset crediting you (http://hg.savannah.gnu.org/hgweb/octave/rev/9a64e02e2aad).

Thanks for contributing.

Rik <rik5>
Project Administrator
Fri 20 Aug 2010 12:48:37 AM UTC, original submission:

I have reported in maintainers list

http://octave.1599824.n4.nabble.com/gammaln-0-octave-3-3-51-MinGW-td2309223.html#a2309822

gammaln(0) and gammaln((minus integer)) give slatec error
(developement tip)

octave:5> gammaln(0)
***MESSAGE FROM ROUTINE DGAMMA IN LIBRARY SLATEC.
***FATAL ERROR, PROG ABORTED, TRACEBACK REQUESTED

  • X IS 0
  • ERROR NUMBER = 4

***END OF MESSAGE

***JOB ABORT DUE TO FATAL ERROR.

  1. ERROR MESSAGE SUMMARY

LIBRARY SUBROUTINE MESSAGE START NERR LEVEL COUNT
SLATEC DGAMMA X IS 0 4 2 2

error: lgamma: exception encountered in Fortran subroutine dlgams_

Seeing the code, liboctave/lo-specfun.cc, I found

double
xgamma (double x)
{
#if defined (HAVE_TGAMMA)
return tgamma (x);
#else
double result;

if (xisnan (x))
result = x;
else if ((x <= 0 && D_NINT (x) == x) || xisinf (x))
result = octave_Inf;
else
F77_XFCN (xdgamma, XDGAMMA, (x, result));

return result;
#endif
}

For also xlgamma, is the below to be used
else if ((x <= 0 && D_NINT (x) == x) || xisinf (x))
instead if
else if (xisinf (x))

Am I right?

The attached changeset is my proposal to fix the issue

Tatsuro MATSUOKA <tmacchant>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #21262:  slatec_gamma.diff added by tmacchant (1KiB - application/octet-stream - changeset for liboctave/lo-specfun.cc)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by rik5 (Posted a comment)
  • -unavailable- added by tmacchant (Submitted the item)
  • -unavailable- added by tmacchant
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

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

     

     

    Follow 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sat 21 Aug 2010 06:06:41 PM UTCrik5StatusNone=>Fixed
      Open/ClosedOpen=>Closed
    Fri 20 Aug 2010 12:48:37 AM UTCtmacchantAttached File-=>Added slatec_gamma.diff, #21262
      Carbon-Copy-=>Added -unavailable-

    Back to the top


    Powered by Savane 3.1-cleanup1