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

 
 

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

Submitter:  Tatsuro MATSUOKA <tmacchant>
Submitted:  Fri 20 Aug 2010 12:48:37 AM UTC
   
 
Category:  Libraries Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Tatsuro MATSUOKA Open/Closed:  * Closed
Release:  * 3.3.52 Operating System:  * Microsoft Windows
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

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>
Group 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 Files:
   
   
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
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by tmacchant (Submitted the item)
  • -email is unavailable- added by tmacchant
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2010-08-21 rik5 StatusNone Fixed
        Open/ClosedOpen Closed
    2010-08-20 tmacchant Attached File- Added slatec_gamma.diff, #21262
        Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.13-caa5.
    Corresponding source code