From 8b8f556d7095452e14a3bc7c46c4bc2f34d6bb9d Mon Sep 17 00:00:00 2001 From: Aravindh Krishnamoorthy Date: Mon, 10 Jul 2023 14:39:09 +0200 Subject: [PATCH] Incorporate first round of comments from @dkarrasch --- stdlib/LinearAlgebra/src/symmetriceigen.jl | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/stdlib/LinearAlgebra/src/symmetriceigen.jl b/stdlib/LinearAlgebra/src/symmetriceigen.jl index 35886e2357e98..2d7f2a0d1ac21 100644 --- a/stdlib/LinearAlgebra/src/symmetriceigen.jl +++ b/stdlib/LinearAlgebra/src/symmetriceigen.jl @@ -185,10 +185,10 @@ function eigen!(A::AbstractMatrix, C::Cholesky; sortby::Union{Function,Nothing}= end # Bunch-Kaufmann (LDLT) based solution for generalized eigenvalues and eigenvectors -function eigen(A::AbstractMatrix{T}, B::BunchKaufman{T,<:StridedMatrix}; sortby::Union{Function,Nothing}=nothing) where {T<:Number} +function eigen(A::StridedMatrix{T}, B::BunchKaufman{T,<:StridedMatrix}; sortby::Union{Function,Nothing}=nothing) where {T<:BlasFloat} eigen!(copy(A), copy(B); sortby) end -function eigen!(A::AbstractMatrix{T}, B::BunchKaufman{T,<:StridedMatrix}; sortby::Union{Function,Nothing}=nothing) where {T<:Number} +function eigen!(A::StridedMatrix{T}, B::BunchKaufman{T,<:StridedMatrix}; sortby::Union{Function,Nothing}=nothing) where {T<:BlasFloat} # NOTE: getproperty(B, :D) and getproperty(B, :L/U) are not in-place. Hence, in the following, sysconvf/_rook is # directly utilized to obtain M, du, d = diag(LUD), and dl. See bunchkaufman.jl/getproperty for details. if B.rook @@ -200,12 +200,12 @@ function eigen!(A::AbstractMatrix{T}, B::BunchKaufman{T,<:StridedMatrix}; sortby M = UnitUpperTriangular(LUD) du = od[2:end] # Aliasing of dl and du is not allowed for gtsv! below. - dl = B.symmetric ? copy(du) : conj.(copy(du)) + dl = B.symmetric ? copy(du) : conj.(du) else M = UnitLowerTriangular(LUD) dl = od[1:end-1] # Aliasing of dl and du is not allowed for gtsv! below. - du = B.symmetric ? copy(dl) : conj.(copy(dl)) + du = B.symmetric ? copy(dl) : conj.(dl) end # In-place permutation of A, A .= A[B.p, B.p] LAPACK.lapmt!(A, B.p, true) @@ -264,10 +264,10 @@ function eigvals!(A::AbstractMatrix{T}, C::Cholesky{T, <:AbstractMatrix}; sortby end # Bunch-Kaufmann (LDLT) based solution for generalized eigenvalues -function eigvals(A::AbstractMatrix{T}, B::BunchKaufman{T,<:StridedMatrix}; sortby::Union{Function,Nothing}=nothing) where {T<:Number} +function eigvals(A::StridedMatrix{T}, B::BunchKaufman{T,<:StridedMatrix}; sortby::Union{Function,Nothing}=nothing) where {T<:BlasFloat} eigvals!(copy(A), copy(B); sortby) end -function eigvals!(A::AbstractMatrix{T}, B::BunchKaufman{T,<:StridedMatrix}; sortby::Union{Function,Nothing}=nothing) where {T<:Number} +function eigvals!(A::StridedMatrix{T}, B::BunchKaufman{T,<:StridedMatrix}; sortby::Union{Function,Nothing}=nothing) where {T<:BlasFloat} # NOTE: getproperty(B, :D) and getproperty(B, :L/U) are not in-place. Hence, in the following, sysconvf/_rook is # directly utilized to obtain M, du, d = diag(LUD), and dl. See bunchkaufman.jl/getproperty for details. if B.rook @@ -279,12 +279,12 @@ function eigvals!(A::AbstractMatrix{T}, B::BunchKaufman{T,<:StridedMatrix}; sort M = UnitUpperTriangular(LUD) du = od[2:end] # Aliasing of dl and du is not allowed for gtsv! below. - dl = B.symmetric ? copy(du) : conj.(copy(du)) + dl = B.symmetric ? copy(du) : conj.(du) else M = UnitLowerTriangular(LUD) dl = od[1:end-1] # Aliasing of dl and du is not allowed for gtsv! below. - du = B.symmetric ? copy(dl) : conj.(copy(dl)) + du = B.symmetric ? copy(dl) : conj.(dl) end # In-place permutation of A, A .= A[B.p, B.p] LAPACK.lapmt!(A, B.p, true)