On 1/11/07, Christopher Barker <[EMAIL PROTECTED]> wrote:
[CHOP]
I'd still like to know if anyone knows how to efficiently loop through all the elements of a non-contiguous array in C.
First, it's not that important if the array is contiguous for this sort of thing. What you really care about is whether it's simply-strided (or maybe single-strided would be a better term). Anyway, the last dimension of the array can be strided without making things more difficult. All you need to be able to do is to address the elements of the array as thedata[offset + stride*index]. That being said, the strategy that the ufuncs use, and possibly other functions as well, is to have the core functions operate only on simply-strided chunks of data. At a higher level, there is some magic that parcels up non-contiguous array into simply-strided chunks and feeds them to core functions. How efficient this is obviously depends on how large the chunks that the magic parceler manages to extract are, but typically it seems to work pretty well. I don't know whether the magic that does the parcelling is available for use by random functions or whether it's specific to the ufunc machinery, I never delved into that end of the ufuncs. -tim
_______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion