Skip to content

Error when converting TensorProductOperator to sparse matrix #356

@cvsvensson

Description

@cvsvensson

Converting a TensorProductOperator to a sparse matrix results in an error.

using SparseArrays, SciMLOperators
m = MatrixOperator(rand(1,1))
M = kron(m,m)
sparse(M)
#MethodError: no method matching sparse(::Type{AbstractMatrix}, ::MatrixOperator{Float64, Matrix{Float64}

This happens at

function SparseArrays.sparse(L::SciMLOperators.TensorProductOperator)
return LinearAlgebra.kron(sparse.(AbstractMatrix, L.ops)...)
end

in SciMLOperators v1.16.0. It seems to me that the argument AbstractMatrix should not be there.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions