Skip to content

Converting constructors #612

Description

@orenbenkiki

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions