JuliaMath / openspecfun

A collection of special mathematical functions
Other
35 stars 20 forks source link

Faddeeva/Faddeeva.cc needs an update (my_copysign function is wrong) #49

Closed fp4code closed 2 years ago

fp4code commented 6 years ago

Comparing Faddeeva/Faddeeva.cc with http://ab-initio.mit.edu/Faddeeva.cc we obtain

142a143
>           12 May 2015: Bugfix for systems lacking copysign function.
202c203
< static inline double my_copysign(double x, double y) { return y<0 ? -x : x; }
---
> static inline double my_copysign(double x, double y) { return x<0 != y<0 ? -x : x; }
223,226d223
< 
< #ifdef USE_OPENLIBM
< #  include <openlibm.h>
< #else
228d224
< #endif
248,254d243
< #  endif
< 
< #  ifdef USE_OPENLIBM
< #  ifndef CMPLX
< #    include "openlibm.h"
< #    define CMPLX(a,b) cpack(a,b)
< #  endif

The function my_copysign is clearly wrong.

ViralBShah commented 6 years ago

cc @stevengj

stevengj commented 6 years ago

Yes, this patch should be applied to openspecfun too. In practice, probably all of the platforms supported by openspecfun have a copysign function, so my_copysign is never invoked, but still would be good to patch.

ViralBShah commented 2 years ago

Closed by #55. I don't think a new release is necessary immediately for reasons mentioned above, but if I do end up excising rem_pio2, the new binaries will include this fix too.