SparseArrays.jl
SparseArrays.jl copied to clipboard
Converting constructors
This doesn't work:
using SparseArrays
m64 = [0 1 2; 3 4 0]
println("m64: $(typeof(m64))")
m32 = SparseMatrixCSC{Int32}(m64)
println("m32: $(typeof(m32))")
v64 = [0 1 2 0]
println("v64: $(typeof(v64))")
v32 = SparseVector{Int32}(v64)
println("v32: $(typeof(v32))")
However this does:
using SparseArrays
m64 = sprand(5, 5, 0.5)
println("m64: $(typeof(m64))")
m32 = SparseMatrixCSC{Float32}(m64)
println("m32: $(typeof(m32))")
v64 = sprand(5, 0.5)
println("v64: $(typeof(v64))")
v32 = SparseVector{Float32}(v64)
println("v32: $(typeof(v32))")
Shouldn't the code above work as well?
I don't think there is an inherent issue with adding support for this, but it's not going to be much more efficient than map(Float32, sparse(m64)); basically you'll need to add constructors that take a function as input, but this adds somewhat pointless complexity.