[SciPy-User] Speed up sin/sqrt functions with cython
Jerome Kieffer
Jerome.Kieffer at esrf.fr
Wed Jan 12 07:40:21 EST 2011
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
More information about the SciPy-User
mailing list