changeset 23646:0a5c6836c499

Use tgamma, tgammaf from C++ std library. These functions are guaranteed to be part of C++11 standard library. * configure.ac: Remove AC_CHECK_FUNCS for tgamma, tgammaf. Remove AC_CHECK_DECLS for tgamma. * lo-specfun.cc: Delegate to std::tgamma or std::tgammaf.
author Rik <rik@octave.org>
date Mon, 19 Jun 2017 10:30:55 -0700
parents e553b7b2fe39
children 38b015656c29
files configure.ac liboctave/numeric/lo-specfun.cc
diffstat 2 files changed, 11 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/configure.ac	Mon Jun 19 09:14:17 2017 -0700
+++ b/configure.ac	Mon Jun 19 10:30:55 2017 -0700
@@ -2411,7 +2411,7 @@
 AC_CHECK_FUNCS([lgamma lgammaf lgamma_r lgammaf_r])
 AC_CHECK_FUNCS([realpath resolvepath])
 AC_CHECK_FUNCS([select setgrent setpwent setsid siglongjmp strsignal])
-AC_CHECK_FUNCS([tcgetattr tcsetattr tgammaf toascii])
+AC_CHECK_FUNCS([tcgetattr tcsetattr toascii])
 AC_CHECK_FUNCS([umask waitpid])
 AC_CHECK_FUNCS([_getch _kbhit])
 
@@ -2419,23 +2419,6 @@
 AC_CHECK_FUNCS([sqrt sqrtf], [],
                [AC_MSG_ERROR([Missing function required to build Octave])])
 
-## exp2, round, tgamma function checks
-AC_LANG_PUSH(C++)
-AC_CHECK_DECLS([tgamma], [], [], [[#include <cmath>]])
-AC_CHECK_FUNCS([tgamma])
-AH_VERBATIM([Z_FUNCS_AND_DECLS], [
-#if defined (__cplusplus)
-extern "C" {
-#endif
-#if HAVE_TGAMMA && ! HAVE_DECL_TGAMMA
-double tgamma (double);
-#endif
-#if defined (__cplusplus)
-}
-#endif
-])
-AC_LANG_POP(C++)
-
 ## Look in <complex> for C++ variants of math functions that we need.
 
 OCTAVE_CHECK_FUNC_COMPLEX(acos)
--- a/liboctave/numeric/lo-specfun.cc	Mon Jun 19 09:14:17 2017 -0700
+++ b/liboctave/numeric/lo-specfun.cc	Mon Jun 19 10:30:55 2017 -0700
@@ -232,25 +232,20 @@
     {
       double result;
 
-      // Special cases for (near) compatibility with Matlab instead of
-      // tgamma.  Matlab does not have -0.
+      // Special cases for (near) compatibility with Matlab instead of tgamma.
+      // Matlab does not have -0.
 
       if (x == 0)
         result = (octave::math::negative_sign (x)
                   ? -octave::numeric_limits<double>::Inf ()
                   : octave::numeric_limits<double>::Inf ());
-      else if ((x < 0 && octave::math::x_nint (x) == x) || octave::math::isinf (x))
+      else if ((x < 0 && octave::math::x_nint (x) == x)
+               || octave::math::isinf (x))
         result = octave::numeric_limits<double>::Inf ();
       else if (octave::math::isnan (x))
         result = octave::numeric_limits<double>::NaN ();
       else
-        {
-#if defined (HAVE_TGAMMA)
-          result = tgamma (x);
-#else
-          F77_XFCN (xdgamma, XDGAMMA, (x, result));
-#endif
-        }
+        result = std::tgamma (x);
 
       return result;
     }
@@ -309,25 +304,20 @@
     {
       float result;
 
-      // Special cases for (near) compatibility with Matlab instead of
-      // tgamma.  Matlab does not have -0.
+      // Special cases for (near) compatibility with Matlab instead of tgamma.
+      // Matlab does not have -0.
 
       if (x == 0)
         result = (octave::math::negative_sign (x)
                   ? -octave::numeric_limits<float>::Inf ()
                   : octave::numeric_limits<float>::Inf ());
-      else if ((x < 0 && octave::math::x_nint (x) == x) || octave::math::isinf (x))
+      else if ((x < 0 && octave::math::x_nint (x) == x)
+               || octave::math::isinf (x))
         result = octave::numeric_limits<float>::Inf ();
       else if (octave::math::isnan (x))
         result = octave::numeric_limits<float>::NaN ();
       else
-        {
-#if defined (HAVE_TGAMMA)
-          result = tgammaf (x);
-#else
-          F77_XFCN (xgamma, XGAMMA, (x, result));
-#endif
-        }
+        result = std::tgammaf (x);
 
       return result;
     }