# HG changeset patch # User Marco Atzeri # Date 1291875330 18000 # Node ID ef0e995f8c0ff9e0ac106c315efe36bf0f39bbcc # Parent f46aeb3ea6b764b43dc1b34e3f1724331094a4ec correctly compute gamma for negative integer values when tgamma is available diff --git a/liboctave/ChangeLog b/liboctave/ChangeLog --- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,8 @@ +2010-12-09 Marco Atzeri + + * lo-specfun.cc (xgamma): Also handle negative integer values as + special cases when using tgamma. + 2010-11-25 John W. Eaton * Sparse.cc (Sparse::assign): Use correct endpoint for diff --git a/liboctave/lo-specfun.cc b/liboctave/lo-specfun.cc --- a/liboctave/lo-specfun.cc +++ b/liboctave/lo-specfun.cc @@ -281,9 +281,6 @@ double xgamma (double x) { -#if defined (HAVE_TGAMMA) - return tgamma (x); -#else double result; if (xisnan (x)) @@ -291,10 +288,13 @@ else if ((x <= 0 && D_NINT (x) == x) || xisinf (x)) result = octave_Inf; else +#if defined (HAVE_TGAMMA) + result = tgamma (x); +#else F77_XFCN (xdgamma, XDGAMMA, (x, result)); +#endif return result; -#endif } double @@ -346,9 +346,6 @@ float xgamma (float x) { -#if defined (HAVE_TGAMMAF) - return tgammaf (x); -#else float result; if (xisnan (x)) @@ -356,10 +353,13 @@ else if ((x <= 0 && D_NINT (x) == x) || xisinf (x)) result = octave_Float_Inf; else +#if defined (HAVE_TGAMMAF) + result = tgammaf (x); +#else F77_XFCN (xgamma, XGAMMA, (x, result)); +#endif return result; -#endif } float diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2010-12-09 Marco Atzeri + + * mappers.cc: In test for gamma, expect Inf for gamma(-1), not NaN. + 2010-12-08 John W. Eaton * graphics.h.in (base_property::do_set): Don't reverse order of diff --git a/src/mappers.cc b/src/mappers.cc --- a/src/mappers.cc +++ b/src/mappers.cc @@ -918,7 +918,7 @@ %!test %! x = [-1, 0, 1, Inf]; -%! v = [NaN, Inf, 1, Inf]; +%! v = [Inf, Inf, 1, Inf]; %! assert (gamma(x), v); %! assert (gamma(single (x)), single (v));