[Numpy-svn] r6396 - in branches/coremath/numpy/core: include/numpy src

numpy-svn@scip... numpy-svn@scip...
Wed Feb 18 11:31:44 CST 2009


Author: cdavid
Date: 2009-02-18 11:31:27 -0600 (Wed, 18 Feb 2009)
New Revision: 6396

Modified:
   branches/coremath/numpy/core/include/numpy/npy_math.h
   branches/coremath/numpy/core/src/_signbit.c
   branches/coremath/numpy/core/src/npy_math.c.src
Log:
Fix nan/inf/co macro when not available on the target platform in npy_math.

Modified: branches/coremath/numpy/core/include/numpy/npy_math.h
===================================================================
--- branches/coremath/numpy/core/include/numpy/npy_math.h	2009-02-18 17:30:41 UTC (rev 6395)
+++ branches/coremath/numpy/core/include/numpy/npy_math.h	2009-02-18 17:31:27 UTC (rev 6396)
@@ -21,25 +21,28 @@
  * IEEE 754 fpu handling. Those are guaranteed to be macros
  */
 #ifndef NPY_HAVE_DECL_ISNAN
-        #define npy_isnan(x) _npy_isnan((x))
+        #define npy_isnan(x) ((x) != (x))
 #else
         #define npy_isnan(x) isnan((x))
 #endif
 
 #ifndef NPY_HAVE_DECL_ISFINITE
-        #define npy_isfinite(x) _npy_isfinite((x))
+        #define npy_isfinite(x) !npy_isnan((x) + (-x))
 #else
         #define npy_isfinite(x) isfinite((x))
 #endif
 
 #ifndef NPY_HAVE_DECL_ISFINITE
-        #define npy_isinf(x) _npy_isinf((x))
+        #define npy_isinf(x) (!npy_isfinite(x) && !npy_isnan(x))
 #else
         #define npy_isinf(x) isinf((x))
 #endif
 
 #ifndef NPY_HAVE_DECL_SIGNBIT
-        #define npy_signbit(x) _npy_signbit((x))
+        #define npy_signbit(x) \
+              (sizeof (x) == sizeof (long double) ? _npy_signbit_ld (x) \
+               : sizeof (x) == sizeof (double) ? _npy_signbit_d (x) \
+               : _npy_signbit_f (x))
 #else
         #define npy_signbit(x) signbit((x))
 #endif

Modified: branches/coremath/numpy/core/src/_signbit.c
===================================================================
--- branches/coremath/numpy/core/src/_signbit.c	2009-02-18 17:30:41 UTC (rev 6395)
+++ branches/coremath/numpy/core/src/_signbit.c	2009-02-18 17:31:27 UTC (rev 6396)
@@ -1,7 +1,7 @@
 /* Adapted from cephes */
 
 static int
-signbit_d(double x)
+_npy_signbit_d(double x)
 {
     union
     {

Modified: branches/coremath/numpy/core/src/npy_math.c.src
===================================================================
--- branches/coremath/numpy/core/src/npy_math.c.src	2009-02-18 17:30:41 UTC (rev 6395)
+++ branches/coremath/numpy/core/src/npy_math.c.src	2009-02-18 17:31:27 UTC (rev 6396)
@@ -195,35 +195,17 @@
  **                     IEEE 754 FPU HANDLING                               **
  *****************************************************************************
  */
-#if !defined(HAVE_DECL_ISNAN)
-    # define isnan(x) ((x) != (x))
-#endif
-
-/* VS 2003 with /Ox optimizes (x)-(x) to 0, which is not IEEE compliant. So we
- * force (x) + (-x), which seems to work. */
-#if !defined(HAVE_DECL_ISFINITE)
-    # define isfinite(x) !isnan((x) + (-x))
-#endif
-
-#if !defined(HAVE_DECL_ISINF)
-#define isinf(x) (!isfinite(x) && !isnan(x))
-#endif
-
 #if !defined(HAVE_DECL_SIGNBIT)
-    #include "_signbit.c"
-    # define signbit(x) \
-              (sizeof (x) == sizeof (long double) ? signbit_ld (x) \
-               : sizeof (x) == sizeof (double) ? signbit_d (x) \
-               : signbit_f (x))
+#include "_signbit.c"
 
-static int signbit_f (float x)
+static int _npy_signbit_f (float x)
 {
-    return signbit_d((double)x);
+    return npy_signbit_d((double)x);
 }
 
-static int signbit_ld (long double x)
+static int _npy_signbit_ld (long double x)
 {
-    return signbit_d((double)x);
+    return _npy_signbit_d((double)x);
 }
 #endif
 



More information about the Numpy-svn mailing list