From efbeb98810cbede55295720810d3d2824bfc4de5 Mon Sep 17 00:00:00 2001 From: Aravindh Krishnamoorthy Date: Sat, 29 Apr 2023 20:10:59 +0200 Subject: [PATCH] Forward eigvals! calls with A::Matrix and B::Hermitian to A::Matrix and B::Matrix --- stdlib/LinearAlgebra/src/symmetriceigen.jl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/stdlib/LinearAlgebra/src/symmetriceigen.jl b/stdlib/LinearAlgebra/src/symmetriceigen.jl index 17371b74bb343..08c8c61c5d354 100644 --- a/stdlib/LinearAlgebra/src/symmetriceigen.jl +++ b/stdlib/LinearAlgebra/src/symmetriceigen.jl @@ -195,3 +195,11 @@ function eigvals!(A::Hermitian{T,S}, B::Hermitian{T,S}; sortby::Union{Function,N return vals end eigvecs(A::HermOrSym) = eigvecs(eigen(A)) + +# For A::StridedMatrix and B::Hermitian, a call to LAPACK is faster. See: https://github.com/JuliaLang/julia/issues/49533 +function eigvals!(A::StridedMatrix{T}, B::HermOrSym{T,S}; sortby::Union{Function,Nothing}=nothing) where {T<:BlasReal,S<:StridedMatrix} + return eigvals!(A, Matrix{T}(B); sortby) +end +function eigvals!(A::StridedMatrix, B::Hermitian{T,S}; sortby::Union{Function,Nothing}=nothing) where {T<:BlasComplex,S<:StridedMatrix} + return eigvals!(A, Matrix{T}(B); sortby) +end