From bug-request at octave dot org Tue Mar 21 12:03:02 2006 Subject: Re: try catch block not working after error in FORTRAN code in 2.9.4 From: David Bateman To: Wolfgang Lehrach Cc: bug at octave dot org Date: Tue, 21 Mar 2006 18:58:46 +0100 This is a multi-part message in MIME format. --------------090905080306090109030608 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Wolfgang Lehrach wrote: >Hi - according to http://mathworld.wolfram.com/GammaFunction.html, gamma >for negative non-integers is defined. matlab and octave will both >evaluate gamma(-0.5) to the same value (-3.5449). gammaln will >currently not work for negative input values for both, despite being >sometimes defined (gamma(-1.5) = 2.3633, so gammaln should be ok in >theory as well). > >Maybe replace: > else if (x <= 0 || xisinf (x)) >with: > else if ((x <= 0) && floor(x) == x) || xisinf (x)) >in the check below? > >or whatever the best way to check a value being an integer would be... > >Thanks, >Wolfgang > >PS David, sorry for duplicate. > > Ok, this patch is going to drive me crazy.... Then what about this... D. -- David Bateman David dot Bateman at motorola dot com Motorola Labs - Paris +33 1 69 35 48 04 (Ph) Parc Les Algorithmes, Commune de St Aubin +33 6 72 01 06 33 (Mob) 91193 Gif-Sur-Yvette FRANCE +33 1 69 35 77 01 (Fax) The information contained in this communication has been classified as: [x] General Business Information [ ] Motorola Internal Use Only [ ] Motorola Confidential Proprietary --------------090905080306090109030608 Content-Type: text/plain; name="patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="patch" *** ./liboctave/lo-specfun.cc.orig3 2005-04-26 21:24:29.000000000 +0200 --- ./liboctave/lo-specfun.cc 2006-03-21 18:57:01.884052840 +0100 *************** *** 37,42 **** --- 37,43 ---- #include "lo-ieee.h" #include "lo-specfun.h" #include "mx-inlines.cc" + #include "lo-mappers.h" #ifndef M_PI #define M_PI 3.14159265358979323846 *************** *** 160,166 **** xgamma (double x) { double result; ! F77_XFCN (xdgamma, XDGAMMA, (x, result)); return result; } --- 161,173 ---- xgamma (double x) { 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; } *************** *** 170,180 **** double result; double sgngam; ! if (x < 0) ! (*current_liboctave_error_handler) ! ("xlgamma: argument must be nonnegative"); ! ! F77_XFCN (dlgams, DLGAMS, (x, result, sgngam)); return result; } --- 177,188 ---- double result; double sgngam; ! if (xisnan (x)) ! result = x; ! else if (x <= 0 || xisinf (x)) ! result = octave_Inf; ! else ! F77_XFCN (dlgams, DLGAMS, (x, result, sgngam)); return result; } --------------090905080306090109030608-- ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------