SparseArrays.jl
SparseArrays.jl copied to clipboard
Incomplete promotion rules for sparse matrices
promote_type(typeof(sprand(10,10,0.1)),typeof(sprand(ComplexF64,10,10,0.1)))
SparseMatrixCSC{Tv,Int64} where Tv
vs in the dense case:
promote_type(typeof(rand(10,10)),typeof(rand(ComplexF64,10,10)))
Array{Complex{Float64},2}
Is this ok:
promote_rule(::Type{SparseMatrixCSC{T1,S1}},::Type{SparseMatrixCSC{T2,S2}}) where {T1,T2,S1,S2} = SparseMatrixCSC{promote_type(T1,T2),promote_type(S1,S2)}
JuliaLang/julia#22757
Does JuliaLang/julia#22757 fix this problem?
I have been using the following locally:
promote_rule{T1,T2,S1,S2}(::Type{SparseMatrixCSC{T1,S1}},::Type{SparseMatrixCSC{T2,S2}}) = SparseMatrixCSC{promote_type(T1,T2),promote_type(S1,S2)}
promote_rule{T1,S1,T2,S2<:AbstractMatrix{T2}}(::Type{SparseMatrixCSC{T1,S1}},::Type{S2}) = Matrix{promote_type(T1,T2)}
promote_rule{T1,S1,T2,S2<:AbstractMatrix{T2}}(::Type{S2},::Type{SparseMatrixCSC{T1,S1}}) = Matrix{promote_type(T1,T2)}
should I make a PR?
Revisiting old sparse issues. This does need the PR.