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

Sparse outer product fails for SparseVector with stored zero #42670

Closed
Keno opened this issue Oct 16, 2021 · 0 comments · Fixed by #42671
Closed

Sparse outer product fails for SparseVector with stored zero #42670

Keno opened this issue Oct 16, 2021 · 0 comments · Fixed by #42671

Comments

@Keno
Copy link
Member

Keno commented Oct 16, 2021

julia> A = spzeros(Int, 4)
4-element SparseVector{Int64, Int64} with 0 stored entries

julia> A[2] = 1
1

julia> A[2] = 0
0

julia> A * sparsevec([0 0 1 1 0 0])'
ERROR: ArgumentError: Illegal buffers for SparseMatrixCSC construction 6 [1, 1, 1, 1, 1, 1, 1] [0, 139764218343329] [0, 139765420920097]
Stacktrace:
  [1] SparseMatrixCSC
    @ ~/julia/usr/share/julia/stdlib/v1.8/SparseArrays/src/sparsematrix.jl:29 [inlined]
  [2] SparseMatrixCSC(m::Int64, n::Int64, colptr::Vector{Int64}, rowval::Vector{Int64}, nzval::Vector{Int64})
    @ SparseArrays ~/julia/usr/share/julia/stdlib/v1.8/SparseArrays/src/sparsematrix.jl:44
  [3] _outer(trans::typeof(conj), x::SparseVector{Int64, Int64}, y::SparseVector{Int64, Int64})
    @ SparseArrays.HigherOrderFns ~/julia/usr/share/julia/stdlib/v1.8/SparseArrays/src/higherorderfns.jl:858
  [4] _outer
    @ ~/julia/usr/share/julia/stdlib/v1.8/SparseArrays/src/higherorderfns.jl:820 [inlined]
  [5] _copy
    @ ~/julia/usr/share/julia/stdlib/v1.8/SparseArrays/src/higherorderfns.jl:819 [inlined]
  [6] copy
    @ ~/julia/usr/share/julia/stdlib/v1.8/SparseArrays/src/higherorderfns.jl:1130 [inlined]
  [7] materialize
    @ ./broadcast.jl:860 [inlined]
  [8] broadcast(::typeof(*), ::SparseVector{Int64, Int64}, ::Adjoint{Int64, SparseVector{Int64, Int64}})
    @ Base.Broadcast ./broadcast.jl:798
  [9] *(u::SparseVector{Int64, Int64}, v::Adjoint{Int64, SparseVector{Int64, Int64}})
    @ LinearAlgebra ~/julia/usr/share/julia/stdlib/v1.8/LinearAlgebra/src/adjtrans.jl:300
 [10] top-level scope
    @ REPL[41]:1

Keno added a commit that referenced this issue Oct 16, 2021
The SparseMatrixCSC constructor checks that the passed in buffers
have length matching the expected number of non-zeros, but the
_outer constructor allocated buffers of the number of structural
non-zeros, not actual non-zeros. Fix this by shrinking the buffers
once the outer product is fully computed.
Keno added a commit that referenced this issue Oct 18, 2021
The SparseMatrixCSC constructor checks that the passed in buffers
have length matching the expected number of non-zeros, but the
_outer constructor allocated buffers of the number of structural
non-zeros, not actual non-zeros. Fix this by shrinking the buffers
once the outer product is fully computed.
KristofferC pushed a commit that referenced this issue Oct 18, 2021
The SparseMatrixCSC constructor checks that the passed in buffers
have length matching the expected number of non-zeros, but the
_outer constructor allocated buffers of the number of structural
non-zeros, not actual non-zeros. Fix this by shrinking the buffers
once the outer product is fully computed.

(cherry picked from commit d885fc2)
LilithHafner pushed a commit to LilithHafner/julia that referenced this issue Feb 22, 2022
…ros (JuliaLang#42671)

The SparseMatrixCSC constructor checks that the passed in buffers
have length matching the expected number of non-zeros, but the
_outer constructor allocated buffers of the number of structural
non-zeros, not actual non-zeros. Fix this by shrinking the buffers
once the outer product is fully computed.
LilithHafner pushed a commit to LilithHafner/julia that referenced this issue Mar 8, 2022
…ros (JuliaLang#42671)

The SparseMatrixCSC constructor checks that the passed in buffers
have length matching the expected number of non-zeros, but the
_outer constructor allocated buffers of the number of structural
non-zeros, not actual non-zeros. Fix this by shrinking the buffers
once the outer product is fully computed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant