On 29.11.2013 21:15, Dan Goodman wrote:
> Hi,
> 
> Is it possible to get access to versions of ufuncs like sin and cos but
> compiled with the -ffast-math compiler switch?
> 
> I recently noticed that my weave.inline code was much faster for some fairly
> simple operations than my pure numpy code, and realised after some fiddling
> around that it was due to using this switch. The speed difference was
> enormous in my test example. I checked the difference in accuracy and over
> the range of values I'm interested in the errors are not really significant.
> 

can you show the code that is slow in numpy?
which version of gcc and libc are you using?
with gcc 4.8 it uses the glibc 2.17 sin/cos with fast-math, so there
should be no difference.


> If there's currently no way of using these faster versions of these
> functions in numpy, maybe it would be worth adding as a feature for future
> versions?
> 

it might be useful for some purposes to add a sort of precision context
which allows using faster but less accurate functions, hypot is a
another case where it would be useful.
But its probably a rather large change and the applications for it are
limited in numpy.
E.g. the main advantage of ffast-math is for vectorization and complex
numbers. For the former numpy can not merge operations like numexpr and
the simple loops are already vectorized.
For complex numbers numpy already implements them as if #pragma STDC
CX_LIMITED_RANGE is enabled (python does the same).
_______________________________________________
NumPy-Discussion mailing list
[email protected]
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to