Skip to content

Commit

Permalink
Similar rows and cols allocations (#46)
Browse files Browse the repository at this point in the history
* Add similar function

---------

Co-authored-by: Maxence Gollier <[email protected]>
  • Loading branch information
MaxenceGollier and MaxenceGollier authored Jul 1, 2024
1 parent 45ba84e commit 8133dd1
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/coo_types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,8 @@ complex(S::SparseMatrixCOO) = SparseMatrixCOO(

import Base.similar

similar(S::SparseMatrixCOO) = SparseMatrixCOO(
size(S, 1),
size(S, 2),
similar(rows(S)),
similar(columns(S)),
similar(nonzeros(S)),
)
function Base.similar(S::SparseMatrixCOO)
newcol = copy(columns(S))
newrow = copy(rows(S))
SparseMatrixCOO(size(S,1), size(S,2), newrow, newcol, similar(nonzeros(S)))
end

0 comments on commit 8133dd1

Please sign in to comment.