Question: how to obtain positions in matrix that meet some condition?

I am finding it a struggle to do this trivial task in Maple.

Given a matrix, I simply wanted to find the positions (index i,j) of all elements that meets some condition. For example, given matrix A:=[[1,2,3,],[4,5,-1]]; I want to find the index of all elements >=3, so the result should be a list of set such as

         [[1,3],[2,1],[2,2]] 

I tried to use member with 'pos' option but that does not work for matirx. It seems only designed for 1D

A:=Matrix( [ [1,2,3],[4,5,-1]] );
c:=select[flatten](x->x>=3,A);  #tried without flatten also
member(c,A,'pos');
pos;

Then I tried rtable_scanblock(), which is the most convoluted and badly documented command I have ever seen in my life (for such a complex command, one will expect 100 examples of many sorts of functionality to illustrate how to use, but only 3-4 trivial examples exist and 3 of them pretty much the same).  What is operation_passindex? what is operation_passnoindex? how to use them? Why is there a star next to val* and operation* ? What is passindex actually? is it a name? value? proc?  etc.. Worst help page ever. 11 parameters for a command??

This is what I tried:

A:=Matrix( [ [1,2,3],[4,5,-1]] ):
rtable_scanblock(A,[],(val,ind,res)->( evalb(val>=3),[ind,val],res),[[1,1],A[1,1]]);

So the result I want is there. I just do not understand why the true,false and those last entries are there and how to get rid of them. I tried. I think I need one other options, but I am lost with all the options listed there with no examples on how to use them.

rtable_scanblock(A,[],(val,ind,res)->`if`( val>=3,[ind,val],res),[[1,1],A[1,1]]);

but then I get only the last value:

I tried

rtable_scanblock(A,[],(val,ind,res)->`if`( evalb(val>=3),[ind,val],res),[[1,1],A[1,1]]);

no difference.  I think I am close, but after 30 minutes, I am calling it quit. If something so easy takes that much effort to find how to in Maple, then something is wrong.

In Matlab, I do this with my eyes closed:

A=[1,2,3;4,5,-1];
[I,J]=find(A>=3)

I =
     2
     2
     1
J =
     1
     2
     3

In Mathematica, such as trivial

mat = {{1, 2, 3}, {4, 5, -1}};
Position[mat, x_ /; x >= 3]

                 {{1, 3}, {2, 1}, {2, 2}}

Thank you

 

Please Wait...