-
Notifications
You must be signed in to change notification settings - Fork 52
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
Conversion from SparseMatrixCSC to Matrix uses the same eltype
.
#49
Comments
So the element type should be A = length(S) == nnz(S) ? Matrix{Tv}(undef, S.m, S.n) : zeros(promote_type(Tv, typeof(zero(Tv))), S.m, S.n) This would lead to a type-instability in the rare case that |
Yes, that would work.
In which case does one need to convert a full |
There's a bigger problem with this premise: |
from the doc of
this is just wrong. |
When converting a SparseMatrixCSC to a Matrix, the current implementation assumes that it can store the result in a matrix of the same
eltype
https://github.com/JuliaLang/julia/blob/989de7903e492aa25f5a888c19b4b8e8a3f9f1f0/stdlib/SparseArrays/src/sparsematrix.jl#L404
However, this does not work of
zero
of theeltype
returns an element of a different type.MCWE:
output:
The error is due to the call
zero(A, 2, 2)
.This example is a bit artificial but the problem also occurs in JuMP with sparse matrices of
VariableRef
for which the zero type isAffExpr
.The text was updated successfully, but these errors were encountered: