I'm looking for vector (fast) code that does what matlab find
function does without loops. find
returns both value and index for a given function. Swift's filter, map or reduce do not return indices.
example
X = [18 3 1 11; 8 10 11 3; 9 14 6 1; 4 3 15 21]
[row,col] = find(X>0 & X<10,3)
row =
2
3
4
col =
1
1
1
From the matlab docs
[row,col] = find(___) returns the row and column subscripts of each nonzero element in array X using any of the input arguments in previous syntaxes.