[SciPy-User] Speed up sin/sqrt functions with cython

Wes McKinney wesmckinn at gmail.com
Wed Jan 12 09:53:48 EST 2011


On Wed, Jan 12, 2011 at 7:40 AM, Jerome Kieffer <Jerome.Kieffer at esrf.fr> wrote:
> On Wed, 12 Jan 2011 13:05:25 +0100 (CET)
> <g.plantageneto at runbox.com> wrote:
>
>>
>> Hi,
>>
>> I am using cython to speed up some computations (btw, thanks a lot to the people who gave me suggestions on a previous thread).
>> I don't understand how to apply the fast C-coded sin/sqrt functions to a numpy array.
>> I can import from math.h like this:
>>
>> cdef extern from "math.h"
>>     double sin(double)
>>
>> but then I can't use this function on a numpy ndarray, obviously.
>>
>> Any ideas? It sounds silly to me to write a cycle on ndarray elements.
>
> it is not ... and you will gain a lot in speed.
>
> --
> Jérôme Kieffer
> On-Line Data analysis / Software Group
> ISDD / ESRF
> tel +33 476 882 445
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>

http://docs.cython.org/src/userguide/numpy_tutorial.html



More information about the SciPy-User mailing list