[SciPy-User] Can I create a 3 argument UFunc easily?

John Salvatier jsalvati@u.washington....
Tue Jun 8 17:46:28 CDT 2010


Hello,

I would like to make a 3 argument UFunc that finds the weighted average of
two of the arguments using the 3rd argument as the weight. This way, the
.accumulate method of the ufunc can be used as an exponentially weighted
moving average function.

Unfortunately I am not very familiar with the Numpy C API, so I was hoping
to use the Cython hack for making UFuncs (
http://wiki.cython.org/MarkLodato/CreatingUfuncs). However, looking at the
UFunc C API doc (http://docs.scipy.org/doc/numpy/reference/c-api.ufunc.html),
it looks like numpy only has 2 argument "generic functions". Is there a
simple way to create a "generic function" that takes 3 arguments that will
still work with accumulate? Is there another way to create the sort of UFunc
I want?

Best Regards,
John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20100608/d4b05a82/attachment.html 


More information about the SciPy-User mailing list