[Numpy-discussion] convert strides/shape/offset into nd index?

Zachary Pincus zachary.pincus@yale....
Sun Nov 29 09:36:24 CST 2009


Hi all,

I'm curious as to what the most straightforward way is to convert an  
offset into a memory buffer representing an arbitrarily strided array  
into the nd index into that array. (Let's assume for simplicity that  
each element is one byte...)

Does sorting the strides from largest to smallest and then using  
integer division and mod (in the obvious way) always work? (I can't  
seem to find a counterexample, but I am not used to thinking too  
deeply about bizarrely-strided configurations.) Is there a method that  
doesn't involve sorting?

Thanks,
Zach


More information about the NumPy-Discussion mailing list