[Numpy-svn] r5910 - branches/ufunc_cleanup/numpy/core/src

numpy-svn@scip... numpy-svn@scip...
Sun Oct 5 00:29:11 CDT 2008


Author: charris
Date: 2008-10-05 00:29:09 -0500 (Sun, 05 Oct 2008)
New Revision: 5910

Modified:
   branches/ufunc_cleanup/numpy/core/src/umathmodule.c.src
Log:
Cleanup some floating constant types.
Make cast from double explicit for integer kind reciprocal.
Small style cleanup.


Modified: branches/ufunc_cleanup/numpy/core/src/umathmodule.c.src
===================================================================
--- branches/ufunc_cleanup/numpy/core/src/umathmodule.c.src	2008-10-05 05:19:52 UTC (rev 5909)
+++ branches/ufunc_cleanup/numpy/core/src/umathmodule.c.src	2008-10-05 05:29:09 UTC (rev 5910)
@@ -1243,7 +1243,7 @@
 {
     UNARY_LOOP {
         const @s@@type@ in1 = *(@s@@type@ *)ip1;
-        *((@s@@type@ *)op) = 1.0/in1;
+        *((@s@@type@ *)op) = (@s@@type@)(1.0/in1);
     }
 }
 
@@ -1513,6 +1513,9 @@
  *  #C = F, , L#
  */
 
+#define ONE 1.0@c@
+#define ZERO 0.0@c@
+
 /**begin repeat1
  * Arithmetic
  * # kind = add, subtract, multiply, divide#
@@ -1650,7 +1653,7 @@
 {
     UNARY_LOOP {
         const @type@ in1 = *(@type@ *)ip1;
-        *((@type@ *)op) = 1.0/in1;
+        *((@type@ *)op) = ONE/in1;
     }
 }
 
@@ -1658,7 +1661,7 @@
 @TYPE@_ones_like(char **args, intp *dimensions, intp *steps, void *data)
 {
     OUTPUT_LOOP {
-        *((@type@ *)op) = 1;
+        *((@type@ *)op) = ONE;
     }
 }
 
@@ -1676,7 +1679,7 @@
 {
     UNARY_LOOP {
         const @type@ in1 = *(@type@ *)ip1;
-        const @type@ tmp = (in1 > 0) ? in1 : -in1;
+        const @type@ tmp = in1 > 0 ? in1 : -in1;
         /* add 0 to clear -0.0 */
         *((@type@ *)op) = tmp + 0;
     }
@@ -1697,7 +1700,7 @@
     /*  */
     UNARY_LOOP {
         const @type@ in1 = *(@type@ *)ip1;
-        *((@type@ *)op) = in1 > 0 ? 1 : (in1 < 0 ? -1 : 0);
+        *((@type@ *)op) = in1 > 0 ? ONE : (in1 < 0 ? -ONE : ZERO);
     }
 }
 
@@ -1734,6 +1737,8 @@
 #undef HAVE_DOUBLE_FUNCS
 
 #define @TYPE@_true_divide @TYPE@_divide
+#undef ONE
+#undef ZERO
 
 /**end repeat**/
 



More information about the Numpy-svn mailing list