[Numpy-svn] r5953 - branches/ufunc_cleanup/numpy/core/src
numpy-svn at scipy.org
numpy-svn at scipy.org
Tue Oct 21 00:49:46 EDT 2008
Author: charris
Date: 2008-10-20 23:49:44 -0500 (Mon, 20 Oct 2008)
New Revision: 5953
Modified:
branches/ufunc_cleanup/numpy/core/src/umathmodule.c.src
Log:
Put back fmin, fmax lost in merge.
Modified: branches/ufunc_cleanup/numpy/core/src/umathmodule.c.src
===================================================================
--- branches/ufunc_cleanup/numpy/core/src/umathmodule.c.src 2008-10-21 02:48:38 UTC (rev 5952)
+++ branches/ufunc_cleanup/numpy/core/src/umathmodule.c.src 2008-10-21 04:49:44 UTC (rev 5953)
@@ -654,7 +654,7 @@
{
UNARY_LOOP {
const @s@@type@ in1 = *(@s@@type@ *)ip1;
- *((@s@@type@ *)op) = 1.0/in1;
+ *((@s@@type@ *)op) = (@s@@type@)(1.0/in1);
}
}
@@ -924,6 +924,9 @@
* #C = F, , L#
*/
+#define ONE 1.0 at c@
+#define ZERO 0.0 at c@
+
/**begin repeat1
* Arithmetic
* # kind = add, subtract, multiply, divide#
@@ -991,7 +994,7 @@
/**begin repeat1
* #kind = maximum, minimum#
- * #OP = >, <#
+ * #OP = >=, <=#
**/
static void
@TYPE at _@kind@(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func))
@@ -1000,12 +1003,28 @@
BINARY_LOOP {
const @type@ in1 = *(@type@ *)ip1;
const @type@ in2 = *(@type@ *)ip2;
- *((@type@ *)op) = in1 @OP@ in2 ? in1 : in2;
+ *((@type@ *)op) = (in1 @OP@ in2 || isnan(in1)) ? in1 : in2;
}
}
/**end repeat1**/
+/**begin repeat1
+ * #kind = fmax, fmin#
+ * #OP = >=, <=#
+ **/
static void
+ at TYPE@_ at kind@(char **args, intp *dimensions, intp *steps, void *func)
+{
+ /* */
+ BINARY_LOOP {
+ const @type@ in1 = *(@type@ *)ip1;
+ const @type@ in2 = *(@type@ *)ip2;
+ *((@type@ *)op) = (in1 @OP@ in2 || isnan(in2)) ? in1 : in2;
+ }
+}
+/**end repeat1**/
+
+static void
@TYPE at _floor_divide(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func))
{
BINARY_LOOP {
@@ -1045,7 +1064,7 @@
{
UNARY_LOOP {
const @type@ in1 = *(@type@ *)ip1;
- *((@type@ *)op) = 1.0/in1;
+ *((@type@ *)op) = ONE/in1;
}
}
@@ -1053,7 +1072,7 @@
@TYPE at _ones_like(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(data))
{
OUTPUT_LOOP {
- *((@type@ *)op) = 1;
+ *((@type@ *)op) = ONE;
}
}
@@ -1071,7 +1090,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;
}
@@ -1138,6 +1157,9 @@
#define @TYPE at _true_divide @TYPE at _divide
+#undef ONE
+#undef ZERO
+
/**end repeat**/
@@ -1155,6 +1177,11 @@
* #c = f, , l#
*/
+#define CGE(xr,xi,yr,yi) (xr > yr || (xr == yr && xi >= yi))
+#define CLE(xr,xi,yr,yi) (xr < yr || (xr == yr && xi <= yi))
+#define ONE 1.0 at c@
+#define ZERO 0.0 at c@
+
/**begin repeat1
* arithmetic
* #kind = add, subtract#
@@ -1348,8 +1375,8 @@
@CTYPE at _ones_like(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(data))
{
OUTPUT_LOOP {
- ((@type@ *)op)[0] = 1;
- ((@type@ *)op)[1] = 0;
+ ((@type@ *)op)[0] = ONE;
+ ((@type@ *)op)[1] = ZERO;
}
}
@@ -1380,29 +1407,30 @@
const @type@ in1r = ((@type@ *)ip1)[0];
const @type@ in1i = ((@type@ *)ip1)[1];
if (in1r > 0) {
- ((@type@ *)op)[0] = 1;
+ ((@type@ *)op)[0] = ONE;
}
else if (in1r < 0) {
- ((@type@ *)op)[0] = -1;
+ ((@type@ *)op)[0] = -ONE;
}
else {
if (in1i > 0) {
- ((@type@ *)op)[0] = 1;
+ ((@type@ *)op)[0] = ONE;
}
else if (in1i < 0) {
- ((@type@ *)op)[0] = -1;
+ ((@type@ *)op)[0] = -ONE;
}
else {
- ((@type@ *)op)[0] = 0;
+ ((@type@ *)op)[0] = ZERO;
}
}
- ((@type@ *)op)[1] = 0;
+ ((@type@ *)op)[1] = ZERO;
}
}
/**begin repeat1
* #kind = maximum, minimum#
- * #OP = >, <#
+ * #OP1 = CGE, CLE#
+ * #OP2 = CLE, CGE#
*/
static void
@CTYPE at _@kind@(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func))
@@ -1412,11 +1440,45 @@
const @type@ in1i = ((@type@ *)ip1)[1];
const @type@ in2r = ((@type@ *)ip2)[0];
const @type@ in2i = ((@type@ *)ip2)[1];
- if (in1r @OP@ in2r || ((in1r == in2r) && (in1i @OP@ in2i))) {
+ if (@OP1@(in1r, in1i, in2r, in2i)) {
((@type@ *)op)[0] = in1r;
((@type@ *)op)[1] = in1i;
}
+ else if (@OP2@(in1r, in1i, in2r, in2i)) {
+ ((@type@ *)op)[0] = in2r;
+ ((@type@ *)op)[1] = in2i;
+ }
else {
+ ((@type@ *)op)[0] = NAN;
+ ((@type@ *)op)[1] = NAN;
+ }
+ }
+}
+/**end repeat1**/
+
+/**begin repeat1
+ * #kind = fmax, fmin#
+ * #OP1 = CGE, CLE#
+ */
+static void
+ at CTYPE@_ at kind@(char **args, intp *dimensions, intp *steps, void *func)
+{
+ BINARY_LOOP {
+ const @type@ in1r = ((@type@ *)ip1)[0];
+ const @type@ in1i = ((@type@ *)ip1)[1];
+ const @type@ in2r = ((@type@ *)ip2)[0];
+ const @type@ in2i = ((@type@ *)ip2)[1];
+ if (@OP1@(in1r, in1i, in2r, in2i) || isnan(in2r) || isnan(in2i)) {
+ if (isnan(in1r) || isnan(in1i)) {
+ ((@type@ *)op)[0] = NAN;
+ ((@type@ *)op)[1] = NAN;
+ }
+ else {
+ ((@type@ *)op)[0] = in1r;
+ ((@type@ *)op)[1] = in1i;
+ }
+ }
+ else {
((@type@ *)op)[0] = in2r;
((@type@ *)op)[1] = in2i;
}
@@ -1425,6 +1487,12 @@
/**end repeat1**/
#define @CTYPE at _true_divide @CTYPE at _divide
+
+#undef CGE
+#undef CLE
+#undef ONE
+#undef ZERO
+
/**end repeat**/
/*
@@ -1464,6 +1532,16 @@
*/
+/*
+ *****************************************************************************
+ ** SETUP UFUNCS **
+ *****************************************************************************
+ */
+
+#include "__umath_generated.c"
+#include "ufuncobject.c"
+#include "__ufunc_api.c"
+
static PyUFuncGenericFunction frexp_functions[] = {
#ifdef HAVE_FREXPF
FLOAT_frexp,
@@ -1485,7 +1563,6 @@
#endif
};
-
static PyUFuncGenericFunction ldexp_functions[] = {
#ifdef HAVE_LDEXPF
FLOAT_ldexp,
@@ -1507,10 +1584,6 @@
};
-#include "__umath_generated.c"
-#include "ufuncobject.c"
-#include "__ufunc_api.c"
-
static double
pinf_init(void)
{
More information about the Numpy-svn
mailing list