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

Incomplete promotion rules for sparse matrices #54

Open
jebej opened this issue Jul 28, 2017 · 5 comments
Open

Incomplete promotion rules for sparse matrices #54

jebej opened this issue Jul 28, 2017 · 5 comments

Comments

@jebej
Copy link
Contributor

jebej commented Jul 28, 2017

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}
@jebej
Copy link
Contributor Author

jebej commented Jul 28, 2017

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)}

@fredrikekre
Copy link
Member

JuliaLang/julia#22757

@jebej
Copy link
Contributor Author

jebej commented Sep 8, 2017

Does JuliaLang/julia#22757 fix this problem?

@jebej
Copy link
Contributor Author

jebej commented Mar 19, 2018

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?

@KristofferC KristofferC transferred this issue from JuliaLang/julia Jan 14, 2022
@ViralBShah
Copy link
Member

Revisiting old sparse issues. This does need the PR.

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

No branches or pull requests

3 participants