Skip to content

Commit

Permalink
Optimize _coo_from_sparse!
Browse files Browse the repository at this point in the history
  • Loading branch information
lassepe committed Sep 4, 2023
1 parent 47b9796 commit 9938c24
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/sparse_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,13 @@ This implementation has been extracted from \
"""
function _coo_from_sparse!(col, len, row, data, M)
@assert length(col) == length(len) == size(M, 1)
@assert length(row) == length(data)
@assert length(row) == length(data) == SparseArrays.nnz(M)
n = length(col)
for i in 1:n
col[i] = M.colptr[i]
len[i] = M.colptr[i + 1] - M.colptr[i]
end
for (i, v) in enumerate(SparseArrays.rowvals(M))
row[i] = v
end
for (i, v) in enumerate(SparseArrays.nonzeros(M))
data[i] = v
@inbounds begin
col .= @view M.colptr[1:n]
len .= diff(M.colptr)
row .= SparseArrays.rowvals(M)
data .= SparseArrays.nonzeros(M)
end
end

Expand Down

0 comments on commit 9938c24

Please sign in to comment.