summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTravis Oliphant <oliphant@enthought.com>2005-10-12 07:45:42 +0000
committerTravis Oliphant <oliphant@enthought.com>2005-10-12 07:45:42 +0000
commitac4db180f8cab1d302e699426a7257ec6b0df426 (patch)
tree5ca12da46af920924c3c6cfd17137ebe92c08263
parentdce41a2a15d9be0cd2cd592ed209b7f30ce166ee (diff)
downloadnumpy-0.4.2b1.tar.gz
Merged changes from newcorev0.4.2b1
-rw-r--r--scipy/base/setup.py2
-rw-r--r--scipy/base/src/umathmodule.c.src108
2 files changed, 93 insertions, 17 deletions
diff --git a/scipy/base/setup.py b/scipy/base/setup.py
index a1455eb25..b147d2e6c 100644
--- a/scipy/base/setup.py
+++ b/scipy/base/setup.py
@@ -62,6 +62,8 @@ def configuration(parent_package='',top_path=None):
moredefs.append('HAVE_INVERSE_HYPERBOLIC')
if config_cmd.check_func('atanhf', **kws_args):
moredefs.append('HAVE_INVERSE_HYPERBOLIC_FLOAT')
+ if config_cmd.check_func('atanhl', **kws_args):
+ moredefs.append('HAVE_INVERSE_HYPERBOLIC_LONGDOUBLE')
if config_cmd.check_func('isnan', **kws_args):
moredefs.append('HAVE_ISNAN')
diff --git a/scipy/base/src/umathmodule.c.src b/scipy/base/src/umathmodule.c.src
index fe4d8bb7f..67742fa7e 100644
--- a/scipy/base/src/umathmodule.c.src
+++ b/scipy/base/src/umathmodule.c.src
@@ -47,23 +47,6 @@ static double atanh(double x)
}
#endif
-#if !defined(HAVE_INVERSE_HYPERBOLIC_FLOAT)
-static float acoshf(float x)
-{
- return (float)acosh((double)(x));
-}
-
-static float asinhf(float x)
-{
- return (float)asinh((double)(x));
-}
-
-static float atanhf(float x)
-{
- return (float)atanh((double)(x));
-}
-#endif
-
#ifdef HAVE_HYPOT
#if !defined(NeXT) && !defined(_MSC_VER)
extern double hypot(double, double);
@@ -239,6 +222,97 @@ hypot, atan2, pow
/**end repeat**/
+#if !defined(HAVE_INVERSE_HYPERBOLIC_FLOAT)
+#ifdef HAVE_FLOAT_FUNCS
+static float acoshf(float x)
+{
+ return logf(x + sqrtf((x-1.0)*(x+1.0)));
+}
+
+static float asinhf(float xx)
+{
+ float x;
+ int sign;
+ if (xx < 0.0) {
+ sign = -1;
+ x = -xx;
+ }
+ else {
+ sign = 1;
+ x = xx;
+ }
+ return sign*logf(x + sqrtf(x*x+1.0));
+}
+
+static float atanhf(float x)
+{
+ return 0.5*logf((1.0+x)/(1.0-x));
+}
+#else
+static float acoshf(float x)
+{
+ return (float)acosh((double)(x));
+}
+
+static float asinhf(float x)
+{
+ return (float)asinh((double)(x));
+}
+
+static float atanhf(float x)
+{
+ return (float)atanh((double)(x));
+}
+#endif
+#endif
+
+
+#if !defined(HAVE_INVERSE_HYPERBOLIC_LONGDOUBLE)
+#ifdef HAVE_LONGDOUBLE_FUNCS
+static longdouble acoshl(longdouble x)
+{
+ return logl(x + sqrtl((x-1.0)*(x+1.0)));
+}
+
+static longdouble asinhl(longdouble xx)
+{
+ longdouble x;
+ int sign;
+ if (xx < 0.0) {
+ sign = -1;
+ x = -xx;
+ }
+ else {
+ sign = 1;
+ x = xx;
+ }
+ return sign*logl(x + sqrtl(x*x+1.0));
+}
+
+static longdouble atanhl(longdouble x)
+{
+ return 0.5*logl((1.0+x)/(1.0-x));
+}
+#else
+static longdouble acoshl(longdouble x)
+{
+ return (longdouble)acosh((double)(x));
+}
+
+static longdouble asinhl(longdouble x)
+{
+ return (longdouble)asinh((double)(x));
+}
+
+static longdouble atanhl(longdouble x)
+{
+ return (longdouble)atanh((double)(x));
+}
+#endif
+#endif
+
+
+
/* Don't pass structures between functions (only pointers) because how
structures are passed is compiler dependent and could cause