summaryrefslogtreecommitdiff
path: root/numpy/core/src/npymath
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2010-04-05 04:03:19 +0000
committerCharles Harris <charlesr.harris@gmail.com>2010-04-05 04:03:19 +0000
commit21178ae32f4f8dfdcc40e6b5c9eea999fcc52884 (patch)
treed3ca6d6e0875b1f4c5ac0a9ddd1a4ccaf1c04677 /numpy/core/src/npymath
parenta63d83291ea7037da280597c275668066b8dd996 (diff)
downloadnumpy-21178ae32f4f8dfdcc40e6b5c9eea999fcc52884.tar.gz
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.
Diffstat (limited to 'numpy/core/src/npymath')
-rw-r--r--numpy/core/src/npymath/npy_math.c.src108
1 files changed, 49 insertions, 59 deletions
diff --git a/numpy/core/src/npymath/npy_math.c.src b/numpy/core/src/npymath/npy_math.c.src
index 33c8c0a01..8b4b3421b 100644
--- a/numpy/core/src/npymath/npy_math.c.src
+++ b/numpy/core/src/npymath/npy_math.c.src
@@ -370,6 +370,53 @@ double npy_log2(double x)
/**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 @@ double npy_log2(double x)
@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 @@ double npy_log2(double x)
#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**/