[Numpy-svn] r5761 - in branches/clean_math_config/numpy/core: . src

numpy-svn@scip... numpy-svn@scip...
Thu Sep 4 09:45:40 CDT 2008


Author: cdavid
Date: 2008-09-04 09:45:33 -0500 (Thu, 04 Sep 2008)
New Revision: 5761

Modified:
   branches/clean_math_config/numpy/core/setup.py
   branches/clean_math_config/numpy/core/src/math_c99.c.src
   branches/clean_math_config/numpy/core/src/umathmodule.c.src
Log:
Use C99 math compatibility module.

Completely broken for now, needs to update the configuration stage.


Modified: branches/clean_math_config/numpy/core/setup.py
===================================================================
--- branches/clean_math_config/numpy/core/setup.py	2008-09-04 14:40:00 UTC (rev 5760)
+++ branches/clean_math_config/numpy/core/setup.py	2008-09-04 14:45:33 UTC (rev 5761)
@@ -293,6 +293,7 @@
     config.add_extension('umath',
                          sources = [generate_config_h,
                                     generate_numpyconfig_h,
+                                    join('src','math_c99.c.src'),
                                     join('src','umathmodule.c.src'),
                                     generate_umath_c,
                                     generate_ufunc_api,

Modified: branches/clean_math_config/numpy/core/src/math_c99.c.src
===================================================================
--- branches/clean_math_config/numpy/core/src/math_c99.c.src	2008-09-04 14:40:00 UTC (rev 5760)
+++ branches/clean_math_config/numpy/core/src/math_c99.c.src	2008-09-04 14:45:33 UTC (rev 5761)
@@ -1,18 +1,11 @@
 /*
+ * vim:syntax=c
  * A small module to implement missing C99 math capabilities required by numpy
  *
  * Please keep this independant of python as much as possible !
  */
 
 /*
- * Include python.h because it may modify math.h configuration, but we won't
- * use any python code at all here
- */
-#include "Python.h"
-#include "config.h"
-#include <math.h>
-
-/*
  * Basic functions, double version. Some old/weird platforms may not have those
  *
  * Original code by Konrad Hinsen.

Modified: branches/clean_math_config/numpy/core/src/umathmodule.c.src
===================================================================
--- branches/clean_math_config/numpy/core/src/umathmodule.c.src	2008-09-04 14:40:00 UTC (rev 5760)
+++ branches/clean_math_config/numpy/core/src/umathmodule.c.src	2008-09-04 14:45:33 UTC (rev 5761)
@@ -18,336 +18,14 @@
  **                     BASIC MATH FUNCTIONS                                **
  *****************************************************************************
  */
+#include "math_c99.c"
 
-/* A whole slew of basic math functions are provided originally
-   by Konrad Hinsen. */
-
-#if !defined(__STDC__) && !defined(_MSC_VER)
-extern double fmod (double, double);
-extern double frexp (double, int *);
-extern double ldexp (double, int);
-extern double modf (double, double *);
-#endif
-#ifndef M_PI
-#define M_PI 3.14159265358979323846264338328
-#endif
-
-
-#if defined(DISTUTILS_USE_SDK)
-/* win32 on AMD64 build architecture */
-/* See also http://projects.scipy.org/scipy/numpy/ticket/164 */
-#ifndef HAVE_FABSF
-#ifdef fabsf
-#undef fabsf
-#endif
-static float fabsf(float x)
-{
-    return (float)fabs((double)(x));
-}
-#endif
-#ifndef HAVE_HYPOTF
-static float hypotf(float x, float y)
-{
-    return (float)hypot((double)(x), (double)(y));
-}
-#endif
-#ifndef HAVE_RINTF
-#ifndef HAVE_RINT
-static double rint (double x);
-#endif
-static float rintf(float x)
-{
-    return (float)rint((double)(x));
-}
-#endif
-#ifndef HAVE_FREXPF
-static float frexpf(float x, int * i)
-{
-    return (float)frexp((double)(x), i);
-}
-#endif
-#ifndef HAVE_LDEXPF
-static float ldexpf(float x, int i)
-{
-    return (float)ldexp((double)(x), i);
-}
-#endif
-#define tanhf nc_tanhf
-#endif
-
-#ifndef HAVE_INVERSE_HYPERBOLIC
-static double acosh(double x)
-{
-    return 2*log(sqrt((x+1.0)/2)+sqrt((x-1.0)/2));
-}
-
-double log1p(double);
-static double asinh(double xx)
-{
-    double x, d;
-    int sign;
-    if (xx < 0.0) {
-        sign = -1;
-        x = -xx;
-    }
-    else {
-        sign = 1;
-        x = xx;
-    }
-    if (x > 1e8) {
-        d = x;
-    } else {
-        d = sqrt(x*x + 1);
-    }
-    return sign*log1p(x*(1.0 + x/(d+1)));
-}
-
-static double atanh(double x)
-{
-    return 0.5*log1p(2.0*x/(1.0-x));
-}
-#endif
-
-#if !defined(HAVE_INVERSE_HYPERBOLIC_FLOAT)
-#ifdef HAVE_FLOAT_FUNCS
-#ifdef log1pf
-#undef log1pf
-#endif
-#ifdef logf
-#undef logf
-#endif
-#ifdef sqrtf
-#undef sqrtf
-#endif
-float log1pf(float);
-#ifdef DISTUTILS_USE_SDK
-DL_IMPORT(float) logf(float);
-DL_IMPORT(float) sqrtf(float);
-#else
-/* should these be extern?: */
-float logf(float);
-float sqrtf(float);
-#endif
-#ifdef acoshf
-#undef acoshf
-#endif
-static float acoshf(float x)
-{
-    return 2*logf(sqrtf((x+1)/2)+sqrtf((x-1)/2));
-}
-
-#ifdef asinhf
-#undef asinhf
-#endif
-static float asinhf(float xx)
-{
-    float x, d;
-    int sign;
-    if (xx < 0) {
-        sign = -1;
-        x = -xx;
-    }
-    else {
-        sign = 1;
-        x = xx;
-    }
-    if (x > 1e5) {
-        d = x;
-    } else {
-        d = sqrtf(x*x + 1);
-    }
-    return sign*log1pf(x*(1 + x/(d+1)));
-}
-
-#ifdef atanhf
-#undef atanhf
-#endif
-static float atanhf(float x)
-{
-    return log1pf(2*x/(1-x))/2;
-}
-#else
-#ifdef acoshf
-#undef acoshf
-#endif
-static float acoshf(float x)
-{
-    return (float)acosh((double)(x));
-}
-
-#ifdef asinhf
-#undef asinhf
-#endif
-static float asinhf(float x)
-{
-    return (float)asinh((double)(x));
-}
-
-#ifdef atanhf
-#undef atanhf
-#endif
-static float atanhf(float x)
-{
-    return (float)atanh((double)(x));
-}
-#endif
-#endif
-
-
-#if !defined(HAVE_INVERSE_HYPERBOLIC_LONGDOUBLE)
-#ifdef HAVE_LONGDOUBLE_FUNCS
-#ifdef logl
-#undef logl
-#endif
-#ifdef sqrtl
-#undef sqrtl
-#endif
-#ifdef log1pl
-#undef log1pl
-#endif
-longdouble logl(longdouble);
-longdouble sqrtl(longdouble);
-longdouble log1pl(longdouble);
-#ifdef acoshl
-#undef acoshl
-#endif
-static longdouble acoshl(longdouble x)
-{
-    return 2*logl(sqrtl((x+1.0)/2)+sqrtl((x-1.0)/2));
-}
-
-#ifdef asinhl
-#undef asinhl
-#endif
-static longdouble asinhl(longdouble xx)
-{
-    longdouble x, d;
-    int sign;
-    if (xx < 0.0) {
-        sign = -1;
-        x = -xx;
-    }
-    else {
-        sign = 1;
-        x = xx;
-    }
-    if (x > 1e17) {
-        d = x;
-    } else {
-        d = sqrtl(x*x + 1);
-    }
-    return sign*log1pl(x*(1.0 + x/(d+1)));
-}
-
-#ifdef atanhl
-#undef atanhl
-#endif
-static longdouble atanhl(longdouble x)
-{
-    return 0.5*log1pl(2.0*x/(1.0-x));
-}
-
-#else
-
-#ifdef acoshl
-#undef acoshl
-#endif
-static longdouble acoshl(longdouble x)
-{
-    return (longdouble)acosh((double)(x));
-}
-
-#ifdef asinhl
-#undef asinhl
-#endif
-static longdouble asinhl(longdouble x)
-{
-    return (longdouble)asinh((double)(x));
-}
-
-#ifdef atanhl
-#undef atanhl
-#endif
-static longdouble atanhl(longdouble x)
-{
-    return (longdouble)atanh((double)(x));
-}
-
-#endif
-#endif
-
-
-#ifdef HAVE_HYPOT
-#if !defined(NeXT) && !defined(_MSC_VER)
-extern double hypot(double, double);
-#endif
-#else
-static double hypot(double x, double y)
-{
-    double yx;
-
-    x = fabs(x);
-    y = fabs(y);
-    if (x < y) {
-        double temp = x;
-        x = y;
-        y = temp;
-    }
-    if (x == 0.)
-        return 0.;
-    else {
-        yx = y/x;
-        return x*sqrt(1.+yx*yx);
-    }
-}
-#endif
-
-#ifndef HAVE_RINT
-/* needs cleanup */
-static double
-rint(double x)
-{
-    double y, r;
-
-    y = floor(x);
-    r = x - y;
-
-    if (r > 0.5) goto rndup;
-
-    /* Round to nearest even */
-    if (r==0.5) {
-        r = y - 2.0*floor(0.5*y);
-        if (r==1.0) {
-        rndup:
-            y+=1.0;
-        }
-    }
-    return y;
-}
-#endif
-
 /*
- * Comment out trunc definition until build problems are fixed.
+ *****************************************************************************
+ **                     IEEE 754 FPU HANDLING                               **
+ *****************************************************************************
  */
-/*
-#ifndef HAVE_TRUNC
-static double
-trunc(double x)
-{
-    if (x < 0) {
-    	return ceil(x);
-    }
-    else {
-        return floor(x);
-    }
 
-}
-#endif
-*/
-
-
-
-
 /* Define isnan, isinf, isfinite, signbit if needed */
 /* Use fpclassify if possible */
 /* isnan, isinf --
@@ -463,168 +141,6 @@
     return x * (M_PI/180.0L);
 }
 
-/* First, the C functions that do the real work */
-
-/* if C99 extensions not available then define dummy functions that use the
-   double versions for
-
-   sin, cos, tan
-   sinh, cosh, tanh,
-   fabs, floor, ceil, fmod, sqrt, log10, log, exp, fabs
-   asin, acos, atan,
-   asinh, acosh, atanh
-
-   hypot, atan2, pow
-*/
-
-/**begin repeat
-
-   #kind=(sin,cos,tan,sinh,cosh,tanh,fabs,floor,ceil,sqrt,log10,log,exp,asin,acos,atan,rint)*2#
-   #typ=longdouble*17, float*17#
-   #c=l*17,f*17#
-   #TYPE=LONGDOUBLE*17, FLOAT*17#
-*/
-
-#ifndef HAVE_@TYPE@_FUNCS
-#ifdef @kind@@c@
-#undef @kind@@c@
-#endif
-@typ@ @kind@@c@(@typ@ x) {
-    return (@typ@) @kind@((double)x);
-}
-#endif
-/**end repeat**/
-
-/**begin repeat
-
-   #kind=(atan2,hypot,pow,fmod)*2#
-   #typ=longdouble*4, float*4#
-   #c=l*4,f*4#
-   #TYPE=LONGDOUBLE*4,FLOAT*4#
-*/
-#ifndef HAVE_@TYPE@_FUNCS
-#ifdef @kind@@c@
-#undef @kind@@c@
-#endif
-@typ@ @kind@@c@(@typ@ x, @typ@ y) {
-    return (@typ@) @kind@((double)x, (double) y);
-}
-#endif
-/**end repeat**/
-
-/**begin repeat
-   #kind=modf*2#
-   #typ=longdouble, float#
-   #c=l,f#
-   #TYPE=LONGDOUBLE, FLOAT#
-*/
-#ifndef HAVE_@TYPE@_FUNCS
-#ifdef modf@c@
-#undef modf@c@
-#endif
-@typ@ modf@c@(@typ@ x, @typ@ *iptr) {
-    double nx, niptr, y;
-    nx = (double) x;
-    y = modf(nx, &niptr);
-    *iptr = (@typ@) niptr;
-    return (@typ@) y;
-}
-#endif
-/**end repeat**/
-
-
-
-#ifndef HAVE_LOG1P
-double log1p(double x)
-{
-    double u = 1. + x;
-    if (u == 1.0) {
-        return x;
-    } else {
-        return log(u) * x / (u-1.);
-    }
-}
-#endif
-
-#if !defined(HAVE_LOG1P) || !defined(HAVE_LONGDOUBLE_FUNCS)
-#ifdef log1pl
-#undef log1pl
-#endif
-longdouble log1pl(longdouble x)
-{
-    longdouble u = 1. + x;
-    if (u == 1.0) {
-        return x;
-    } else {
-        return logl(u) * x / (u-1.);
-    }
-}
-#endif
-
-#if !defined(HAVE_LOG1P) || !defined(HAVE_FLOAT_FUNCS)
-#ifdef log1pf
-#undef log1pf
-#endif
-float log1pf(float x)
-{
-    float u = 1 + x;
-    if (u == 1) {
-        return x;
-    } else {
-        return logf(u) * x / (u-1);
-    }
-}
-#endif
-
-#ifndef HAVE_EXPM1
-static double expm1(double x)
-{
-    double u = exp(x);
-    if (u == 1.0) {
-        return x;
-    } else if (u-1.0 == -1.0) {
-        return -1;
-    } else {
-        return (u-1.0) * x/log(u);
-    }
-}
-#endif
-
-#if !defined(HAVE_EXPM1) || !defined(HAVE_LONGDOUBLE_FUNCS)
-#ifdef expml1
-#undef expml1
-#endif
-static longdouble expm1l(longdouble x)
-{
-    longdouble u = expl(x);
-    if (u == 1.0) {
-        return x;
-    } else if (u-1.0 == -1.0) {
-        return -1;
-    } else {
-        return (u-1.0) * x/logl(u);
-    }
-}
-#endif
-
-#if !defined(HAVE_EXPM1) || !defined(HAVE_FLOAT_FUNCS)
-#ifdef expm1f
-#undef expm1f
-#endif
-static float expm1f(float x)
-{
-    float u = expf(x);
-    if (u == 1) {
-        return x;
-    } else if (u-1 == -1) {
-        return -1;
-    } else {
-        return (u-1) * x/logf(u);
-    }
-}
-#endif
-
-
 /*
  *****************************************************************************
  **                           COMPLEX FUNCTIONS                             **



More information about the Numpy-svn mailing list