Skip to content

Commit

Permalink
fix dropstored for sparse matrices (#20516)
Browse files Browse the repository at this point in the history
  • Loading branch information
KristofferC authored Feb 8, 2017
1 parent 1b7a684 commit e24faa5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion base/sparse/sparsematrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2745,7 +2745,7 @@ function dropstored!(A::SparseMatrixCSC, i::Integer, j::Integer)
# Entry A[i,j] is stored. Drop and return.
deleteat!(A.rowval, searchk)
deleteat!(A.nzval, searchk)
@simd for m in j:(A.n + 1)
@simd for m in (j+1):(A.n + 1)
@inbounds A.colptr[m] -= 1
end
end
Expand Down
16 changes: 16 additions & 0 deletions test/sparse/sparse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1705,3 +1705,19 @@ end
@testset "issue #14398" begin
@test transpose(view(speye(10), 1:5, 1:5)) eye(5,5)
end

@testset "dropstored issue #20513" begin
x = sparse(rand(3,3))
Base.SparseArrays.dropstored!(x, 1, 1)
@test x[1, 1] == 0.0
@test x.colptr == [1, 3, 6, 9]
Base.SparseArrays.dropstored!(x, 2, 1)
@test x.colptr == [1, 2, 5, 8]
@test x[2, 1] == 0.0
Base.SparseArrays.dropstored!(x, 2, 2)
@test x.colptr == [1, 2, 4, 7]
@test x[2, 2] == 0.0
Base.SparseArrays.dropstored!(x, 2, 3)
@test x.colptr == [1, 2, 4, 6]
@test x[2, 3] == 0.0
end

2 comments on commit e24faa5

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing the daily benchmark build, I will reply here when finished:

@nanosoldier runbenchmarks(ALL, isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @jrevels

Please sign in to comment.