Skip to content

Request for additional findnz() method #16

Closed
@btmit

Description

@btmit

I often find the following pattern useful for sparse matrices.

a = sprand(4, 4, 0.5)
b = [nnz(c) for c in eachcol(a)]

However, if I try the same thing with the findnz() it appears that this method does not exist.

b = [findnz(c)[1] for c in eachcol(a)]

ERROR: MethodError: no method matching findnz(::SubArray{Float64, 1, SparseMatrixCSC{Float64, Int64}, Tuple{Base.Slice{Base.OneTo{Int64}}, Int64}, false})

Does adding this method make sense for a future version SparseArrays?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions