On Sat, Feb 21, 2009 at 1:46 PM, Nicolas Pinto <pinto@mit.edu> wrote:
Dear all,
I'm trying to optimize the code below and I was wondering if there is an efficient method that could reduce the numpy slicing overheard without going with cython. Is there anyway I could use mgrid to get a matrix with all my "windows" and then do a large matrix multiply instead?
If you only care about removing the two loops for the per-window processing, Anne Archibald and Robert Kern wrote a very useful function, segment_axis, which is like the matlab buffer function on steroids, using numpy stride tricks (to avoid copies in many cases). I think that would do everything you want, right ? I use it a lot in my own code, it may be worth being included in numpy or scipy proper. http://projects.scipy.org/scipy/scikits/browser/trunk/talkbox/scikits/talkbo... David