[Numpy-svn] r8320 - trunk/numpy/core/src/npymath

numpy-svn@scip... numpy-svn@scip...
Sun Apr 4 23:03:19 CDT 2010


Author: charris
Date: 2010-04-04 23:03:19 -0500 (Sun, 04 Apr 2010)
New Revision: 8320

Modified:
   trunk/numpy/core/src/npymath/npy_math.c.src
Log:
ENH: Make npy_log2_1p and npy_exp2_1m use standard functions.
This avoids some problems with gcc optimizations on 32 intel systems.
In any case, the problem is pushed back to location single functions.

Modified: trunk/numpy/core/src/npymath/npy_math.c.src
===================================================================
--- trunk/numpy/core/src/npymath/npy_math.c.src	2010-04-04 20:47:48 UTC (rev 8319)
+++ trunk/numpy/core/src/npymath/npy_math.c.src	2010-04-05 04:03:19 UTC (rev 8320)
@@ -370,7 +370,54 @@
 
 /**end repeat**/
 
+
 /*
+ * Decorate all the math functions which are available on the current platform
+ */
+
+/**begin repeat
+ * #type = npy_longdouble,double,float#
+ * #c = l,,f#
+ * #C = L,,F#
+ */
+/**begin repeat1
+ * #kind = sin,cos,tan,sinh,cosh,tanh,fabs,floor,ceil,rint,trunc,sqrt,log10,
+ *         log,exp,expm1,asin,acos,atan,asinh,acosh,atanh,log1p,exp2,log2#
+ * #KIND = SIN,COS,TAN,SINH,COSH,TANH,FABS,FLOOR,CEIL,RINT,TRUNC,SQRT,LOG10,
+ *         LOG,EXP,EXPM1,ASIN,ACOS,ATAN,ASINH,ACOSH,ATANH,LOG1P,EXP2,LOG2#
+ */
+#ifdef HAVE_@KIND@@C@
+@type@ npy_@kind@@c@(@type@ x)
+{
+    return @kind@@c@(x);
+}
+#endif
+
+/**end repeat1**/
+
+/**begin repeat1
+ * #kind = atan2,hypot,pow,fmod,copysign#
+ * #KIND = ATAN2,HYPOT,POW,FMOD,COPYSIGN#
+ */
+#ifdef HAVE_@KIND@@C@
+@type@ npy_@kind@@c@(@type@ x, @type@ y)
+{
+    return @kind@@c@(x, y);
+}
+#endif
+/**end repeat1**/
+
+#ifdef HAVE_MODF@C@
+@type@ npy_modf@c@(@type@ x, @type@ *iptr)
+{
+    return modf@c@(x, iptr);
+}
+#endif
+
+/**end repeat**/
+
+
+/*
  * Non standard functions
  */
 
@@ -397,24 +444,12 @@
 
 @type@ npy_log2_1p@c@(@type@ x)
 {
-    @type@ u = 1 + x;
-    if (u == 1) {
-        return LOG2E*x;
-    } else {
-        return npy_log2@c@(u) * x / (u - 1);
-    }
+    return LOG2E*npy_log1p@c@(x);
 }
 
 @type@ npy_exp2_1m@c@(@type@ x)
 {
-    @type@ u = npy_exp@c@(x);
-    if (u == 1.0) {
-        return LOGE2*x;
-    } else if (u - 1 == -1) {
-        return -LOGE2;
-    } else {
-        return (u - 1) * x/npy_log2@c@(u);
-    }
+    return npy_exp1m@c@(LOGE2*x);
 }
 
 @type@ npy_logaddexp@c@(@type@ x, @type@ y)
@@ -453,48 +488,3 @@
 #undef DEG2RAD
 
 /**end repeat**/
-
-/*
- * Decorate all the math functions which are available on the current platform
- */
-
-/**begin repeat
- * #type = npy_longdouble,double,float#
- * #c = l,,f#
- * #C = L,,F#
- */
-/**begin repeat1
- * #kind = sin,cos,tan,sinh,cosh,tanh,fabs,floor,ceil,rint,trunc,sqrt,log10,
- *         log,exp,expm1,asin,acos,atan,asinh,acosh,atanh,log1p,exp2,log2#
- * #KIND = SIN,COS,TAN,SINH,COSH,TANH,FABS,FLOOR,CEIL,RINT,TRUNC,SQRT,LOG10,
- *         LOG,EXP,EXPM1,ASIN,ACOS,ATAN,ASINH,ACOSH,ATANH,LOG1P,EXP2,LOG2#
- */
-#ifdef HAVE_@KIND@@C@
-@type@ npy_@kind@@c@(@type@ x)
-{
-    return @kind@@c@(x);
-}
-#endif
-
-/**end repeat1**/
-
-/**begin repeat1
- * #kind = atan2,hypot,pow,fmod,copysign#
- * #KIND = ATAN2,HYPOT,POW,FMOD,COPYSIGN#
- */
-#ifdef HAVE_@KIND@@C@
-@type@ npy_@kind@@c@(@type@ x, @type@ y)
-{
-    return @kind@@c@(x, y);
-}
-#endif
-/**end repeat1**/
-
-#ifdef HAVE_MODF@C@
-@type@ npy_modf@c@(@type@ x, @type@ *iptr)
-{
-    return modf@c@(x, iptr);
-}
-#endif
-
-/**end repeat**/



More information about the Numpy-svn mailing list