[Numpy-discussion] cummax
Nissim Karpenstein
nissimk@gmail....
Wed Sep 23 09:34:55 CDT 2009
Hi,
I want a cummax function where given an array inp it returns this:
numpy.array([inp[:i].max() for i in xrange(1,len(inp)+1)]).
Various python versions equivalent to the above are quite slow (though a
single python loop is much faster than a python loop with a nested numpy C
loop as shown above).
I have numpy 1.3.0 source. It looks to me like I could add cummax function
by simply adding PyArray_CumMax to multiarraymodule.c which would be the
same as PyArray_Max except it would call PyArray_GenericAccumulateFunction
instead of PyArray_GenericReduceFunction. Also add array_cummax to
arraymethods.c.
Is there interest in adding this function to numpy? If so, I will check out
the latest code and try to check in these changes.
If not, how can I write my own Python module in C that adds this UFunc and
still gets to reuse the code in PyArray_GenericReduceFunction?
Thanks,
-Nissim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20090923/a756fd92/attachment.html
More information about the NumPy-Discussion
mailing list