Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions src/eigenSelfAdjoint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -633,29 +633,35 @@ eigen2(A::Hermitian, tol = eps(float(real(one(eltype(A)))))) = eigen2!(copy(A),

# First method of each type here is identical to the method defined in
# LinearAlgebra but is needed for disambiguation
const _eigencopy_oftype = if VERSION >= v"1.9"
LinearAlgebra.eigencopy_oftype
else
LinearAlgebra.copy_oftype
end

function LinearAlgebra.eigvals(A::Hermitian{<:Real})
T = typeof(sqrt(zero(eltype(A))))
return eigvals!(LinearAlgebra.copy_oftype(A, T))
return eigvals!(_eigencopy_oftype(A, T))
end
function LinearAlgebra.eigvals(A::Hermitian{<:Complex})
T = typeof(sqrt(zero(eltype(A))))
return eigvals!(LinearAlgebra.copy_oftype(A, T))
return eigvals!(_eigencopy_oftype(A, T))
end
function LinearAlgebra.eigvals(A::Hermitian)
T = typeof(sqrt(zero(eltype(A))))
return eigvals!(LinearAlgebra.copy_oftype(A, T))
return eigvals!(_eigencopy_oftype(A, T))
end
function LinearAlgebra.eigen(A::Hermitian{<:Real})
T = typeof(sqrt(zero(eltype(A))))
return eigen!(LinearAlgebra.copy_oftype(A, T))
return eigen!(_eigencopy_oftype(A, T))
end
function LinearAlgebra.eigen(A::Hermitian{<:Complex})
T = typeof(sqrt(zero(eltype(A))))
return eigen!(LinearAlgebra.copy_oftype(A, T))
return eigen!(_eigencopy_oftype(A, T))
end
function LinearAlgebra.eigen(A::Hermitian)
T = typeof(sqrt(zero(eltype(A))))
return eigen!(LinearAlgebra.copy_oftype(A, T))
return eigen!(_eigencopy_oftype(A, T))
end

# Aux (should go somewhere else at some point)
Expand Down
8 changes: 8 additions & 0 deletions test/eigenselfadjoint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,12 @@ using Test, GenericLinearAlgebra, LinearAlgebra, Quaternions
@test abs.(eigen(A).vectors) == abs.(eigen(T).vectors) == abs.(eigen(A; sortby=LinearAlgebra.eigsortby).vectors) == abs.(eigen(T; sortby=LinearAlgebra.eigsortby).vectors)
end
end

if VERSION >= v"1.9"
@testset "#139" begin
A = Hermitian(Diagonal([1.0, 2.0]))
@test eigvals(A) == diag(A)
@test eigen(A).values == diag(A)
end
end
end