[SciPy-User] flat / nonflat array index conversion

Christoph Deil Deil.Christoph@googlemail....
Mon Mar 8 13:02:49 CST 2010

Is there a numpy function to convert corresponding array indices in flattened / nonflat multidimensional arrays for a given shape?

E.g. for a = array([0,1,2,3,4,5]).reshape(2,3) I want some function that converts e.g. 1 to [0,1] and 5 to [1,2] if I tell it a.shape. For 2D it's of course easy to do it by hand, but I need something that is fast and works for arrays of any dimension.

More information about the SciPy-User mailing list