Hello, I have a peculiar situation where I am trying to solve AX + XB = C
but A is sparse, for example think of A
as a differential operator. But, this isn’t allowed, I have a small working example here:
begin
A = sparse(diagm(0=>rand(10),1=>rand(9),-1=>rand(9)))
B = rand(2,2)
C = rand(10,2)
sylvester(A,B,C)
end
to which I get the following error
ERROR: MethodError: no method matching schur!(::SparseMatrixCSC{Float64, Int64})
The function `schur!` exists, but no method is defined for this combination of argument types.
Closest candidates are:
schur!(::StridedMatrix{T}, ::StridedMatrix{T}) where T<:Union{Float32, Float64, ComplexF64, ComplexF32}
@ LinearAlgebra ~/.julia/juliaup/julia-1.11.3+0.x64.linux.gnu/share/julia/stdlib/v1.11/LinearAlgebra/src/schur.jl:348
schur!(::UpperHessenberg{T, S} where S<:AbstractMatrix{T}) where T<:Union{Float32, Float64, ComplexF64, ComplexF32}
@ LinearAlgebra ~/.julia/juliaup/julia-1.11.3+0.x64.linux.gnu/share/julia/stdlib/v1.11/LinearAlgebra/src/schur.jl:105
schur!(::StridedMatrix{var"#s5030"} where var"#s5030"<:Union{Float32, Float64, ComplexF64, ComplexF32})
@ LinearAlgebra ~/.julia/juliaup/julia-1.11.3+0.x64.linux.gnu/share/julia/stdlib/v1.11/LinearAlgebra/src/schur.jl:103
Stacktrace:
[1] schur(A::SparseMatrixCSC{Float64, Int64})
@ LinearAlgebra ~/.julia/juliaup/julia-1.11.3+0.x64.linux.gnu/share/julia/stdlib/v1.11/LinearAlgebra/src/schur.jl:157
[2] sylvester(A::SparseMatrixCSC{Float64, Int64}, B::Matrix{Float64}, C::Matrix{Float64})
@ LinearAlgebra ~/.julia/juliaup/julia-1.11.3+0.x64.linux.gnu/share/julia/stdlib/v1.11/LinearAlgebra/src/dense.jl:1692
[3] top-level scope
@ REPL[81]:5
[4] top-level scope
@ ~/.julia/juliaup/julia-1.11.3+0.x64.linux.gnu/share/julia/stdlib/v1.11/REPL/src/REPL.jl:1660
of course, if I omit the sparse
function call everything works smoothly. From what I understand sparse matrices are just not implemented for the schur
function, but is this expected or should this be a github issue, so that it is included?