Mercurial > octave
changeset 23636:563a9fc1ef23
Use exp2, exp2f from C++ std library.
These functions are guaranteed to be part of C++11 standard library.
* configure.ac: Remove AC_CHECK_DECL, AC_CHECK_FUNCS for log2.
Remove AC_CHECK_FUNCS for log2f.
* lo-mappers.cc: Delegate to std::exp2 or std::exp2f for exp2.
author | Rik <rik@octave.org> |
---|---|
date | Sat, 17 Jun 2017 17:41:40 -0700 |
parents | b5a9cd6de1b8 |
children | 2208cc0e89a3 |
files | configure.ac liboctave/numeric/lo-mappers.cc |
diffstat | 2 files changed, 4 insertions(+), 41 deletions(-) [+] |
line wrap: on
line diff
--- a/configure.ac Sat Jun 17 20:08:06 2017 -0400 +++ b/configure.ac Sat Jun 17 17:41:40 2017 -0700 @@ -2422,15 +2422,12 @@ ## exp2, round, tgamma function checks AC_LANG_PUSH(C++) -AC_CHECK_DECLS([exp2, round, tgamma], [], [], [[#include <cmath>]]) -AC_CHECK_FUNCS([exp2 round tgamma]) +AC_CHECK_DECLS([round, tgamma], [], [], [[#include <cmath>]]) +AC_CHECK_FUNCS([round tgamma]) AH_VERBATIM([Z_FUNCS_AND_DECLS], [ #if defined (__cplusplus) extern "C" { #endif -#if HAVE_EXP2 && ! HAVE_DECL_EXP2 -double exp2 (double); -#endif #if HAVE_ROUND && ! HAVE_DECL_ROUND double round (double); #endif @@ -2452,11 +2449,6 @@ OCTAVE_CHECK_FUNC_COMPLEX(atan) OCTAVE_CHECK_FUNC_COMPLEX(atanh) -## Check for nonstandard, but common math functions, that we need. - -dnl Use multiple AC_CHECKs to avoid line continuations '\' in list -AC_CHECK_FUNCS([exp2f]) - ## Check for math defines such as M_LN2 in math.h AC_CACHE_CHECK([for MATH DEFINES in math.h], [octave_cv_header_math_defines],
--- a/liboctave/numeric/lo-mappers.cc Sat Jun 17 20:08:06 2017 -0400 +++ b/liboctave/numeric/lo-mappers.cc Sat Jun 17 17:41:40 2017 -0700 @@ -274,37 +274,8 @@ return (ax != lax) ? (x / ax) * lax : x; } - double - exp2 (double x) - { -#if defined (HAVE_EXP2) - return ::exp2 (x); -#else -# if defined (M_LN2) - static double ln2 = M_LN2; -# else - static double ln2 = std::log (2.0); -# endif - return exp (x * ln2); -#endif - } - - float - exp2 (float x) - { -#if defined (HAVE_EXP2F) - return exp2f (x); -#elif defined (HAVE_EXP2) - return ::exp2 (x); -#else -# if defined (M_LN2) - static float ln2 = M_LN2; -# else - static float ln2 = log2 (2.0f); -# endif - return exp (x * ln2); -#endif - } + double exp2 (double x) { return std::exp2 (x); } + float exp2 (float x) { return std::exp2f (x); } double copysign (double x, double y) { return std::copysign (x, y); } float copysign (float x, float y) { return std::copysign (x, y); }