summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2008-10-05 05:29:09 +0000
committerCharles Harris <charlesr.harris@gmail.com>2008-10-05 05:29:09 +0000
commitbdb51a609ab370705ba781abe673be8f1c71f8b9 (patch)
tree0c0bec7ed456e21ebbcb45bbdc50f99ef807878a
parent10ed170a5d4e82024c2b4deff7d4c3549e3e4ff4 (diff)
downloadnumpy-bdb51a609ab370705ba781abe673be8f1c71f8b9.tar.gz
Cleanup some floating constant types.
Make cast from double explicit for integer kind reciprocal. Small style cleanup.
-rw-r--r--numpy/core/src/umathmodule.c.src15
1 files changed, 10 insertions, 5 deletions
diff --git a/numpy/core/src/umathmodule.c.src b/numpy/core/src/umathmodule.c.src
index a30a98abd..05ee27d0d 100644
--- a/numpy/core/src/umathmodule.c.src
+++ b/numpy/core/src/umathmodule.c.src
@@ -1243,7 +1243,7 @@ static void
{
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 @@ U@TYPE@_remainder(char **args, intp *dimensions, intp *steps, void *func)
* #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 @@ static void
{
UNARY_LOOP {
const @type@ in1 = *(@type@ *)ip1;
- *((@type@ *)op) = 1.0/in1;
+ *((@type@ *)op) = ONE/in1;
}
}
@@ -1658,7 +1661,7 @@ static void
@TYPE@_ones_like(char **args, intp *dimensions, intp *steps, void *data)
{
OUTPUT_LOOP {
- *((@type@ *)op) = 1;
+ *((@type@ *)op) = ONE;
}
}
@@ -1676,7 +1679,7 @@ static void
{
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 @@ static void
/* */
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 @@ static void
#undef HAVE_DOUBLE_FUNCS
#define @TYPE@_true_divide @TYPE@_divide
+#undef ONE
+#undef ZERO
/**end repeat**/