Dear all, I have some problems with CartesianIndex. In numpy when I want to index of nonzero elements I can do like this:
>>> x = np.array([[3, 0, 0], [0, 4, 0], [5, 6, 0]])
>>> x
array([[3, 0, 0],
[0, 4, 0],
[5, 6, 0]])
>>> a,b=np.nonzero(x)
>>> a
array([0, 1, 2, 2])
>>> b
array([0, 1, 0, 1]))
In Julia
>>> x = [3 0 0; 0 4 0; 5 6 0]
3×3 Array{Int64,2}:
3 0 0
0 4 0
5 6 0
>>> findall(x.>0)
4-element Array{CartesianIndex{2},1}:
CartesianIndex(1, 1)
CartesianIndex(3, 1)
CartesianIndex(2, 2)
CartesianIndex(3, 2)
How can I get an variable a and b like in Python where a = [1,3,2,3] and b = [1,1,2,2]?