Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dropstored! had one job #20513

Closed
Sacha0 opened this issue Feb 8, 2017 · 1 comment · Fixed by #20516
Closed

dropstored! had one job #20513

Sacha0 opened this issue Feb 8, 2017 · 1 comment · Fixed by #20516
Labels
bug Indicates an unexpected problem or unintended behavior sparse Sparse arrays

Comments

@Sacha0
Copy link
Member

Sacha0 commented Feb 8, 2017

Tracker for #20488 (comment). dropstored! appears broken:

julia> foo = sprand(4, 4, 0.5)
4×4 sparse matrix with 10 Float64 stored entries:
  [2, 1]  =  0.986522
  [1, 2]  =  0.331456
  [2, 2]  =  0.181261
  [4, 2]  =  0.545928
  [1, 3]  =  0.864019
  [2, 3]  =  0.48957
  [3, 3]  =  0.575748
  [4, 3]  =  0.509864
  [1, 4]  =  0.368723
  [3, 4]  =  0.332495

julia> Base.SparseArrays.dropstored!(foo, 2, 1)
4×4 sparse matrix with 9 Float64 stored entries:Error showing value of type SparseMatrixCSC{Float64,Int64}:
ERROR: BoundsError: attempt to access 9-element Array{Int64,1} at index [0]
Stacktrace:
 [1] show(::IOContext{Base.Terminals.TTYTerminal}, ::SparseMatrixCSC{Float64,Int64}) at ./sparse/sparsematrix.jl:147
 [2] show(::IOContext{Base.Terminals.TTYTerminal}, ::MIME{Symbol("text/plain")}, ::SparseMatrixCSC{Float64,Int64}) at ./sparse/sparsematrix.jl:122
 [3] display(::Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, ::MIME{Symbol("text/plain")}, ::SparseMatrixCSC{Float64,Int64}) at ./REPL.jl:122
 [4] display(::Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, ::SparseMatrixCSC{Float64,Int64}) at ./REPL.jl:125
 [5] display(::SparseMatrixCSC{Float64,Int64}) at ./multimedia.jl:194

julia> foo.colptr
5-element Array{Int64,1}:
  0
  1
  4
  8
 10

Best!

@Sacha0 Sacha0 added bug Indicates an unexpected problem or unintended behavior sparse Sparse arrays labels Feb 8, 2017
@KristofferC
Copy link
Member

diff --git a/base/sparse/sparsematrix.jl b/base/sparse/sparsematrix.jl
index 21720ab..fb6e0c5 100644
--- a/base/sparse/sparsematrix.jl
+++ b/base/sparse/sparsematrix.jl
@@ -2788,7 +2788,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

?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior sparse Sparse arrays
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants