MarkLodato CreatingUfuncs

Unknown edited this page Feb 11, 2009 · 1 revision

You can create NumPy [http://docs.scipy.org/doc/numpy/reference/c-api.ufunc.html ufuncs] easily using the following files: attachment:numpy_ufunc_api.pxd attachment:numpy_ufuncs.pxi

The following example makes a ufunc for calling the system "lgamma" function:

#!python
include "numpy_ufuncs.pxi"

cdef extern from "math.h":
    double lgammad "lgamma" (double)
    float lgammaf(float)
    long double lgammal(long double)

lgamma = register_ufunc_fdg(lgammaf, lgammad, lgammal,
    "lgamma", "log gamma function", PyUFunc_None)
Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.