find() applied on multidimensional arrays

It's simpler in numarray:

i,j = where(z<0.5)

For numeric it's more work:

ind = where(z.flat < 0.5)
i = ind//z.shape[1]
j = ind % z.shape[1]

One could turn this into a function for Numeric (to handle all dimensionalities, etc)

···

On May 17, 2005, at 10:04 AM, Dimitri D'Or wrote:

Hello,

Here under a question that has probably already been asked:

I would like to apply the find() function on a bidimensional array and receive as output the bidimensional indices for the elements matching the condition. This is easy in Matlab but doesn't seem to be possible with Python.

Here is a short example (in Matlab code) of what I would like to have:

>> z=rand(3,3)

z =

0\.9501    0\.4860    0\.4565

0\.2311    0\.8913    0\.0185

0\.6068    0\.7621    0\.8214

>> [i,j]=find(z<0.5)

i =

 2

 1

 1

 2

j =

 1

 2

 3

 3

A solution for me?

Thank you,

Dimitri D'Or