Does Julia have a generic way to find nonzero elemements of arrays?

In https://github.com/JuliaLang/julia/pull/38315#issuecomment-722623188 I suggested iterating over nonzero values as a possible efficient generic constructor for SparseMatrix I then proceed to realize that there isn’t such a function that works generically. SparseArrays has findnz, but it only seems to be defined for SparseMatrixCSC and SparseVector. Why is this? This feels like it would be a really useful method to have for generic structured arrays.

2 Likes

TODO: finish ArrayIteration. I just haven’t really needed it for my own work.

3 Likes