Skip to content

How to execute schur! for a pair of submatrices? #15

@andreasvarga

Description

@andreasvarga

schur! accepts as arguments only strided matrices, but I have to call it on submatrices. Is it any trick to overcome this limitation?

The following call with views fails:

julia> a = rand(Complex{BigFloat},5,5); b = rand(Complex{BigFloat},5,5);

julia> LinearAlgebra.schur!(a[1:2,1:2],b[1:2,1:2]);  #OK

julia> LinearAlgebra.schur!(view(a,1:2,1:2),view(b,1:2,1:2));
ERROR: MethodError: Cannot `convert` an object of type Matrix{Complex{BigFloat}} to an object of type SubArray{Complex{BigFloat}, 2, Matrix{Complex{BigFloat}}, Tuple{UnitRange{Int64}, UnitRange{Int64}}, false}
The function `convert` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  SubArray{T, N, P, I, L}(::Any, ::Any, ::Any, ::Any) where {T, N, P, I, L}
   @ Base subarray.jl:19
  convert(::Type{T}, ::T) where T
   @ Base Base.jl:126
  convert(::Type{T}, ::Factorization) where T<:AbstractArray
   @ LinearAlgebra C:\Users\Andreas\.julia\juliaup\julia-1.11.5+0.x64.w64.mingw32\share\julia\stdlib\v1.11\LinearAlgebra\src\factorization.jl:104
  ...

Stacktrace:
 [1] GeneralizedSchur{…}(S::SubArray{…}, T::Matrix{…}, alpha::Vector{…}, beta::Vector{…}, Q::Matrix{…}, Z::Matrix{…})
   @ LinearAlgebra C:\Users\Andreas\.julia\juliaup\julia-1.11.5+0.x64.w64.mingw32\share\julia\stdlib\v1.11\LinearAlgebra\src\schur.jl:320
 [2] GeneralizedSchur(S::SubArray{Complex{…}, 2, Matrix{…}, Tuple{…}, false}, T::Matrix{Complex{…}}, alpha::Vector{Complex{…}}, beta::Vector{Complex{…}}, Q::Matrix{Complex{…}}, Z::Matrix{Complex{…}})
   @ LinearAlgebra C:\Users\Andreas\.julia\juliaup\julia-1.11.5+0.x64.w64.mingw32\share\julia\stdlib\v1.11\LinearAlgebra\src\schur.jl:326
 [3] ggschur!(A::SubArray{Complex{…}, 2, Matrix{…}, Tuple{…}, false}, B::SubArray{Complex{…}, 2, Matrix{…}, Tuple{…}, false}; wantQ::Bool, wantZ::Bool, scale::Bool, kwargs::@Kwargs{})
   @ GenericSchur C:\Users\Andreas\.julia\packages\GenericSchur\8grtV\src\generalized.jl:75
 [4] ggschur!(A::SubArray{Complex{BigFloat}, 2, Matrix{Complex{BigFloat}}, Tuple{UnitRange{Int64}, UnitRange{Int64}}, false}, B::SubArray{Complex{BigFloat}, 2, Matrix{Complex{BigFloat}}, Tuple{UnitRange{Int64}, UnitRange{Int64}}, false})
   @ GenericSchur C:\Users\Andreas\.julia\packages\GenericSchur\8grtV\src\generalized.jl:24
 [5] schur!(A::SubArray{Complex{BigFloat}, 2, Matrix{Complex{…}}, Tuple{UnitRange{…}, UnitRange{…}}, false}, B::SubArray{Complex{BigFloat}, 2, Matrix{Complex{…}}, Tuple{UnitRange{…}, UnitRange{…}}, false}; kwargs::@Kwargs{})
   @ GenericSchur C:\Users\Andreas\.julia\packages\GenericSchur\8grtV\src\generalized.jl:16
 [6] schur!(A::SubArray{Complex{BigFloat}, 2, Matrix{Complex{BigFloat}}, Tuple{UnitRange{Int64}, UnitRange{Int64}}, false}, B::SubArray{Complex{BigFloat}, 2, Matrix{Complex{BigFloat}}, Tuple{UnitRange{Int64}, UnitRange{Int64}}, false})
   @ GenericSchur C:\Users\Andreas\.julia\packages\GenericSchur\8grtV\src\generalized.jl:14
 [7] top-level scope
   @ REPL[56]:1
Some type information was truncated. Use `show(err)` to see complete types.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions