Mercurial > octave
changeset 23638:799833716c7b
Use expm1, expm1f from C++ std library.
These functions are guaranteed to be part of C++11 standard library.
* configure.ac: Remove AC_CHECK_FUNCS for expm1, expm1f.
* lo-specfun.cc: Delegate to std::expm1 or std::expm1f for expm1.
author | Rik <rik@octave.org> |
---|---|
date | Sun, 18 Jun 2017 14:24:07 -0700 |
parents | 2208cc0e89a3 |
children | b488e958d024 |
files | configure.ac liboctave/numeric/lo-specfun.cc |
diffstat | 2 files changed, 3 insertions(+), 75 deletions(-) [+] |
line wrap: on
line diff
--- a/configure.ac Sat Jun 17 20:34:49 2017 -0400 +++ b/configure.ac Sun Jun 18 14:24:07 2017 -0700 @@ -2404,7 +2404,7 @@ dnl Code tests HAVE_FUNCNAME and either uses function or provides workaround. dnl Use multiple AC_CHECKs to avoid line continuations '\' in list AC_CHECK_FUNCS([ctermid dup2]) -AC_CHECK_FUNCS([endgrent endpwent execvp expm1 expm1f fork]) +AC_CHECK_FUNCS([endgrent endpwent execvp fork]) AC_CHECK_FUNCS([getegid geteuid getgid getgrent getgrgid getgrnam]) AC_CHECK_FUNCS([getpgrp getpid getppid getpwent getpwuid getuid]) AC_CHECK_FUNCS([isascii kill])
--- a/liboctave/numeric/lo-specfun.cc Sat Jun 17 20:34:49 2017 -0400 +++ b/liboctave/numeric/lo-specfun.cc Sun Jun 18 14:24:07 2017 -0700 @@ -381,43 +381,7 @@ return result; } - double - expm1 (double x) - { -#if defined (HAVE_EXPM1) - return ::expm1 (x); -#else - double retval; - - double ax = fabs (x); - - if (ax < 0.1) - { - ax /= 16; - - // use Taylor series to calculate exp(x)-1. - double t = ax; - double s = 0; - for (int i = 2; i < 7; i++) - s += (t *= ax/i); - s += ax; - - // use the identity (a+1)^2-1 = a*(a+2) - double e = s; - for (int i = 0; i < 4; i++) - { - s *= e + 2; - e *= e + 2; - } - - retval = (x > 0) ? s : -s / (1+s); - } - else - retval = exp (x) - 1; - - return retval; -#endif - } + double expm1 (double x) { return std::expm1 (x); } Complex expm1 (const Complex& x) @@ -438,43 +402,7 @@ return retval; } - float - expm1 (float x) - { -#if defined (HAVE_EXPM1F) - return expm1f (x); -#else - float retval; - - float ax = fabs (x); - - if (ax < 0.1) - { - ax /= 16; - - // use Taylor series to calculate exp(x)-1. - float t = ax; - float s = 0; - for (int i = 2; i < 7; i++) - s += (t *= ax/i); - s += ax; - - // use the identity (a+1)^2-1 = a*(a+2) - float e = s; - for (int i = 0; i < 4; i++) - { - s *= e + 2; - e *= e + 2; - } - - retval = (x > 0) ? s : -s / (1+s); - } - else - retval = exp (x) - 1; - - return retval; -#endif - } + float expm1 (float x) { return std::expm1f (x); } FloatComplex expm1 (const FloatComplex& x)