Iterate over sparse array

Since you can create a sparse matrix with row-indices, column-indices, and values, how do you get those back after the creation of the matrix?

i = [1, 2, 3]
j = [1, 2, 3]
v = [1, 1, 2]

a = sparse(i, j, v)

I hoping for something that acts like:

for (i, j, v) in notsure(a)
    println(i, "- ", j, "- ", v)
end

would output

1-1-1
2-2-1
3-3-2

findnz

2 Likes