Skip to content
Browse files

Merged changes from newcore

  • Loading branch information...
1 parent dce41a2 commit ac4db180f8cab1d302e699426a7257ec6b0df426 Travis Oliphant committed Oct 12, 2005
Showing with 93 additions and 17 deletions.
  1. +2 −0 scipy/base/setup.py
  2. +91 −17 scipy/base/src/umathmodule.c.src
View
2 scipy/base/setup.py
@@ -62,6 +62,8 @@ def generate_config_h(ext, build_dir):
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')
View
108 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

0 comments on commit ac4db18

Please sign in to comment.
Something went wrong with that request. Please try again.