[Numpy-discussion] Iterating over a given axis with buffering

Sergio Pascual sergio.pasra at gmail.com
Mon Aug 13 12:16:43 EDT 2012

Hi, I have a 3d array of bitswapped data, dimensions 2000x2000x20. I
want to apply a function over the third axis to obtain a 2000x2000
array. This is what numpy.apply_along_axis does, but I need a faster
version, so I'm writing it in C. I started by writing a generic ufunc
version of the code. It is not what I need, because my particular
function has several free parameters, but with this version I could
get a hint of the performance. The ufunc was nice, because it handled
the bitswapped data, and naturally the innermost loop was over the
third axis.

So I tried to write the final version using NpyIter. The only way I
found to do the innermost loop over the third axis was passing the
flag NPY_ITER_MULTI_INDEX, but then I can't use NPY_ITER_BUFFERED to
handle my bitswapped, at least in numpy 1.6 they couldn't be used

Any hint on how I can do this?

Regards, Sergio

More information about the NumPy-Discussion mailing list