On 23.04.2014 21:25, Matthew Brett wrote:
> Hi,
> 
> On Tue, Apr 15, 2014 at 12:34 AM, Julian Taylor
> <[email protected]> wrote:
>> On Tue, Apr 15, 2014 at 4:30 AM, Matthew Brett <[email protected]> 
>> wrote:
>>>
>>> It looks as though mingw-w64 is at fault, and I was confused (still
>>> am) because of the different behavior with double and a constant:
>>>
>>> #include <stdio.h>
>>> #include <math.h>
>>>
>>> int main() {
>>>     double z, i = -0.0;
>>>     printf("With double %f=%f, with constant=%f\n",
>>>    i, expm1(i), expm1(-0.));
>>> }
>>>
>>> gives:
>>>
>>> With double -0.000000=0.000000, with constant=-0.000000
>>>
>>> That was ugly to track down.
>>>
>>> What is the right way to work round this (using the numpy version
>>> instead of the system version I suppose)?
>>>
>>
>> The right way is to file a bug at mingw and get it fixed at the source.
> 
> http://sourceforge.net/p/mingw-w64/code/6594/

great thanks for reporting it.

> 
>> Additionally as this time npymath seems to be better (thats 3 bugs in
>> npymath vs 1 in mingw on my scoreboard) one could use the mingw
>> preprocessor define instead of HAVE_EXP1M to select this function from
>> npymath.
> 
> Sorry to be slow - could you unpack what you mean in this paragraph?
> Is there a way to force use of the numpy version of the function using
> environment variables or similar?
> 

I mean something along the line of attached patch, maybe you can try it.
If it works I can file a numpy PR.
diff --git a/numpy/core/src/npymath/npy_math.c.src b/numpy/core/src/npymath/npy_math.c.src
index 1ca7033..e371061 100644
--- a/numpy/core/src/npymath/npy_math.c.src
+++ b/numpy/core/src/npymath/npy_math.c.src
@@ -62,7 +62,9 @@
  */
 
 /* Original code by Konrad Hinsen.  */
-#ifndef HAVE_EXPM1
+#if !defined(HAVE_EXPM1) || defined(__MINGW32__)
+/* http://sourceforge.net/p/mingw-w64/code/6594/ */
+#define NPY_USE_OWN_EXPM1 1
 double npy_expm1(double x)
 {
     if (npy_isinf(x) && x > 0) {
@@ -80,6 +82,8 @@ double npy_expm1(double x)
         }
     }
 }
+#else
+#define NPY_USE_OWN_EXPM1 0
 #endif
 
 #ifndef HAVE_LOG1P
@@ -335,12 +339,13 @@ double npy_log2(double x)
  *         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#
+ * #skip = 0*15,NPY_USE_OWN_EXPM1,0*9#
  */
 
 #ifdef @kind@@c@
 #undef @kind@@c@
 #endif
-#ifndef HAVE_@KIND@@C@
+#if !defined HAVE_@KIND@@C@ || @skip@
 @type@ npy_@kind@@c@(@type@ x)
 {
     return (@type@) npy_@kind@((double)x);
@@ -394,8 +399,9 @@ double npy_log2(double x)
  *         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#
+ * #skip = 0*15,NPY_USE_OWN_EXPM1,0*9#
  */
-#ifdef HAVE_@KIND@@C@
+#if defined HAVE_@KIND@@C@ && !@skip@
 @type@ npy_@kind@@c@(@type@ x)
 {
     return @kind@@c@(x);
_______________________________________________
NumPy-Discussion mailing list
[email protected]
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to