changeset 23642:18ae8d3c745b

Use log1p, log1pf from C++ std library. These functions are guaranteed to be part of C++11 standard library. * configure.ac: Remove AC_CHECK_FUNCS for log1p, log1pf. * lo-specfun.cc: Delegate to std::log1p or std::log1pf.
author Rik <rik@octave.org>
date Sun, 18 Jun 2017 21:55:12 -0700
parents be69ea3de7a3
children 3dc16b35ba2c
files configure.ac liboctave/numeric/lo-specfun.cc
diffstat 2 files changed, 2 insertions(+), 51 deletions(-) [+]
line wrap: on
line diff
--- a/configure.ac	Sun Jun 18 22:26:07 2017 -0400
+++ b/configure.ac	Sun Jun 18 21:55:12 2017 -0700
@@ -2409,7 +2409,6 @@
 AC_CHECK_FUNCS([getpgrp getpid getppid getpwent getpwuid getuid])
 AC_CHECK_FUNCS([isascii kill])
 AC_CHECK_FUNCS([lgamma lgammaf lgamma_r lgammaf_r])
-AC_CHECK_FUNCS([log1p log1pf])
 AC_CHECK_FUNCS([realpath resolvepath roundl])
 AC_CHECK_FUNCS([select setgrent setpwent setsid siglongjmp strsignal])
 AC_CHECK_FUNCS([tcgetattr tcsetattr tgammaf toascii])
--- a/liboctave/numeric/lo-specfun.cc	Sun Jun 18 22:26:07 2017 -0400
+++ b/liboctave/numeric/lo-specfun.cc	Sun Jun 18 21:55:12 2017 -0700
@@ -423,31 +423,7 @@
       return retval;
     }
 
-    double
-    log1p (double x)
-    {
-#if defined (HAVE_LOG1P)
-      return ::log1p (x);
-#else
-      double retval;
-
-      double ax = fabs (x);
-
-      if (ax < 0.2)
-        {
-          // approximation log (1+x) ~ 2*sum ((x/(2+x)).^ii ./ ii), ii = 1:2:2n+1
-          double u = x / (2 + x), t = 1, s = 0;
-          for (int i = 2; i < 12; i += 2)
-            s += (t *= u*u) / (i+1);
-
-          retval = 2 * (s + 1) * u;
-        }
-      else
-        retval = std::log (1 + x);
-
-      return retval;
-#endif
-    }
+    double log1p (double x) { return std::log1p (x); }
 
     Complex
     log1p (const Complex& x)
@@ -470,31 +446,7 @@
 
     double cbrt (double x) { return std::cbrt (x); }
 
-    float
-    log1p (float x)
-    {
-#if defined (HAVE_LOG1PF)
-      return log1pf (x);
-#else
-      float retval;
-
-      float ax = fabs (x);
-
-      if (ax < 0.2)
-        {
-          // approximation log (1+x) ~ 2*sum ((x/(2+x)).^ii ./ ii), ii = 1:2:2n+1
-          float u = x / (2 + x), t = 1.0f, s = 0;
-          for (int i = 2; i < 12; i += 2)
-            s += (t *= u*u) / (i+1);
-
-          retval = 2 * (s + 1.0f) * u;
-        }
-      else
-        retval = std::log (1.0f + x);
-
-      return retval;
-#endif
-    }
+    float log1p (float x) { return std::log1pf (x); }
 
     FloatComplex
     log1p (const FloatComplex& x)