In my application I have a sparse matrix, but every element of this matrix is a discretised function. If I try to use SparseMatrixCSC{Array{Float64,1},Int64}
as the container, but setindex!(...)
in 0.7 throws a stackoverflow:
julia> sa=sparse([1],[1],[Vector{Float64}(undef,3)],3,3)
3×3 SparseMatrixCSC{Array{Float64,1},Int64} with 1 stored entry:
[1, 1] = [6.93279e-310, 6.93279e-310, 6.93279e-310]
julia> sa[1,1] = [1.0,2.0,3.0]
StackOverflowError:
Stacktrace:
[1] setindex!(::SparseMatrixCSC{Array{Int64,1},Int64}, ::Array{Int64,1}, ::Int64, ::Int64) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/SparseArrays/src/sparsematrix.jl:2540 (repeats 80000 times)
This can be solved by using broadcasted setindex!(...)
, but it does not solve the problem adding new elements to the array:
julia> sa[1,1] .= [1.0,2.0,3.0]
3-element Array{Float64,1}:
1.0
2.0
3.0
julia> sa[2,2] = [1.0,2.0,3.0]
StackOverflowError:
Stacktrace:
[1] setindex!(::SparseMatrixCSC{Array{Float64,1},Int64}, ::Array{Float64,1}, ::Int64, ::Int64) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/SparseArrays/src/sparsematrix.jl:2540 (repeats 80000 times)
I can work around it using custom structures, but this has worked in 0.6.x. Is it intentional, or a bug?