Skip to content

Commit fd56d78

Browse files
authored
Use eigencopy_oftype instead of copy_oftype (#140)
Fixes #139
1 parent 713250b commit fd56d78

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

src/eigenSelfAdjoint.jl

+12-6
Original file line numberDiff line numberDiff line change
@@ -633,29 +633,35 @@ eigen2(A::Hermitian, tol = eps(float(real(one(eltype(A)))))) = eigen2!(copy(A),
633633

634634
# First method of each type here is identical to the method defined in
635635
# LinearAlgebra but is needed for disambiguation
636+
const _eigencopy_oftype = if VERSION >= v"1.9"
637+
LinearAlgebra.eigencopy_oftype
638+
else
639+
LinearAlgebra.copy_oftype
640+
end
641+
636642
function LinearAlgebra.eigvals(A::Hermitian{<:Real})
637643
T = typeof(sqrt(zero(eltype(A))))
638-
return eigvals!(LinearAlgebra.copy_oftype(A, T))
644+
return eigvals!(_eigencopy_oftype(A, T))
639645
end
640646
function LinearAlgebra.eigvals(A::Hermitian{<:Complex})
641647
T = typeof(sqrt(zero(eltype(A))))
642-
return eigvals!(LinearAlgebra.copy_oftype(A, T))
648+
return eigvals!(_eigencopy_oftype(A, T))
643649
end
644650
function LinearAlgebra.eigvals(A::Hermitian)
645651
T = typeof(sqrt(zero(eltype(A))))
646-
return eigvals!(LinearAlgebra.copy_oftype(A, T))
652+
return eigvals!(_eigencopy_oftype(A, T))
647653
end
648654
function LinearAlgebra.eigen(A::Hermitian{<:Real})
649655
T = typeof(sqrt(zero(eltype(A))))
650-
return eigen!(LinearAlgebra.copy_oftype(A, T))
656+
return eigen!(_eigencopy_oftype(A, T))
651657
end
652658
function LinearAlgebra.eigen(A::Hermitian{<:Complex})
653659
T = typeof(sqrt(zero(eltype(A))))
654-
return eigen!(LinearAlgebra.copy_oftype(A, T))
660+
return eigen!(_eigencopy_oftype(A, T))
655661
end
656662
function LinearAlgebra.eigen(A::Hermitian)
657663
T = typeof(sqrt(zero(eltype(A))))
658-
return eigen!(LinearAlgebra.copy_oftype(A, T))
664+
return eigen!(_eigencopy_oftype(A, T))
659665
end
660666

661667
# Aux (should go somewhere else at some point)

test/eigenselfadjoint.jl

+8
Original file line numberDiff line numberDiff line change
@@ -156,4 +156,12 @@ using Test, GenericLinearAlgebra, LinearAlgebra, Quaternions
156156
@test abs.(eigen(A).vectors) == abs.(eigen(T).vectors) == abs.(eigen(A; sortby=LinearAlgebra.eigsortby).vectors) == abs.(eigen(T; sortby=LinearAlgebra.eigsortby).vectors)
157157
end
158158
end
159+
160+
if VERSION >= v"1.9"
161+
@testset "#139" begin
162+
A = Hermitian(Diagonal([1.0, 2.0]))
163+
@test eigvals(A) == diag(A)
164+
@test eigen(A).values == diag(A)
165+
end
166+
end
159167
end

0 commit comments

Comments
 (0)