Skip to content

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