changeset 23624:65e5ddf6d059

Use cbrt, cbrtf from C++ std library. These functions are guaranteed to be part of C++11 standard library. * configure.ac: Remove AC_CHECK_FUNCS for cbrt, cbrtf. * lo-specfun.cc (cbrt, cbrtf): Map functions onto std::XXX of the same name. * lo-specfun.cc (xcbrt): Delete unused function.
author Rik <rik@octave.org>
date Fri, 16 Jun 2017 17:09:29 -0700
parents 4feed155a1f2
children b0a2367823f5
files configure.ac liboctave/numeric/lo-specfun.cc
diffstat 2 files changed, 2 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/configure.ac	Fri Jun 16 16:33:30 2017 -0700
+++ b/configure.ac	Fri Jun 16 17:09:29 2017 -0700
@@ -2455,7 +2455,6 @@
 ## Check for nonstandard, but common math functions, that we need.
 
 dnl Use multiple AC_CHECKs to avoid line continuations '\' in list
-AC_CHECK_FUNCS([cbrt cbrtf])
 AC_CHECK_FUNCS([erf erff erfc erfcf exp2f hypotf _hypotf log2 log2f])
 
 ## Check for math defines such as M_LN2 in math.h
--- a/liboctave/numeric/lo-specfun.cc	Fri Jun 16 16:33:30 2017 -0700
+++ b/liboctave/numeric/lo-specfun.cc	Fri Jun 16 17:09:29 2017 -0700
@@ -578,31 +578,7 @@
       return retval;
     }
 
-    template <typename T>
-    T
-    xcbrt (T x)
-    {
-      static const T one_third = 0.3333333333333333333f;
-      if (octave::math::isfinite (x))
-        {
-          // Use pow.
-          T y = std::pow (std::abs (x), one_third) * signum (x);
-          // Correct for better accuracy.
-          return (x / (y*y) + y + y) / 3;
-        }
-      else
-        return x;
-    }
-
-    double
-    cbrt (double x)
-    {
-#if defined (HAVE_CBRT)
-      return ::cbrt (x);
-#else
-      return xxcbrt (x);
-#endif
-    }
+    double cbrt (double x) { return std::cbrt (x); }
 
     float
     log1p (float x)
@@ -649,15 +625,7 @@
       return retval;
     }
 
-    float
-    cbrt (float x)
-    {
-#if defined (HAVE_CBRTF)
-      return cbrtf (x);
-#else
-      return xxcbrt (x);
-#endif
-    }
+    float cbrt (float x) { return std::cbrtf (x); }
 
     static inline Complex
     zbesj (const Complex& z, double alpha, int kode, octave_idx_type& ierr);