Skip to content

Commit

Permalink
Merged changes from newcore
Browse files Browse the repository at this point in the history
  • Loading branch information
teoliphant committed Oct 12, 2005
1 parent dce41a2 commit ac4db18
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 17 deletions.
2 changes: 2 additions & 0 deletions scipy/base/setup.py
Expand Up @@ -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')

Expand Down
108 changes: 91 additions & 17 deletions scipy/base/src/umathmodule.c.src
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ac4db18

Please sign in to comment.