I do not believe that there is a built-in way to do this, but here is a function to do this
function findmat(f, A::AbstractMatrix) m,n = size(A) out = (Int,Int)[] for i in 1:m, j in 1:n f(A[i,j]) && push!(out,(i,j)) end out end
eg.
julia> findmat(x->x==2, [ 1 2 3; 2 3 4; 1 0 2] ) 3-element Array{(Int64,Int64),1}: (1,2) (2,1) (3,3)
If a large number of elements satisfies the condition, it would be more efficient to do this in two passes, but I doubt it.
source share