From 9ee414d10c37d37991dc505a930599f8b4e22f58 Mon Sep 17 00:00:00 2001 From: Arun sanganal <74652697+ArunSanganal@users.noreply.github.com> Date: Wed, 9 Jun 2021 16:46:32 +0530 Subject: [PATCH] Added a method to broaden schur for adjoint and transpose. (#41120) --- stdlib/LinearAlgebra/src/schur.jl | 4 ++++ stdlib/LinearAlgebra/test/schur.jl | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/stdlib/LinearAlgebra/src/schur.jl b/stdlib/LinearAlgebra/src/schur.jl index 9436776863dd8..268758383b7f1 100644 --- a/stdlib/LinearAlgebra/src/schur.jl +++ b/stdlib/LinearAlgebra/src/schur.jl @@ -355,6 +355,10 @@ function schur(A::StridedMatrix{TA}, B::StridedMatrix{TB}) where {TA,TB} S = promote_type(eigtype(TA), TB) return schur!(copy_oftype(A, S), copy_oftype(B, S)) end +function schur(A::AbstractMatrix{TA}, B::AbstractMatrix{TB}) where {TA,TB} + S = promote_type(eigtype(TA), TB) + return schur!(copy_oftype(A, S), copy_oftype(B, S)) +end """ ordschur!(F::GeneralizedSchur, select::Union{Vector{Bool},BitVector}) -> F::GeneralizedSchur diff --git a/stdlib/LinearAlgebra/test/schur.jl b/stdlib/LinearAlgebra/test/schur.jl index 03bc7650ba6e6..d047ca12abc1f 100644 --- a/stdlib/LinearAlgebra/test/schur.jl +++ b/stdlib/LinearAlgebra/test/schur.jl @@ -193,4 +193,13 @@ end end end +@testset "adjoint and transpose for schur (#40941)" begin + A = rand(3, 3) + B = schur(A', A) + C = B.left*B.S*B.right' + D = schur(transpose(A), A) + E = D.left*D.S*D.right' + @test A' ≈ C ≈ E +end + end # module TestSchur