Skip to content

Commit

Permalink
Remove some pirated methods for the symmetric eigenvalue problem.
Browse files Browse the repository at this point in the history
They don't seem to be needed anymore and avoid an ambiguity introduced
by Julia 1.11. Also, sort the eigenvalues of the symmetric problem
when nothing is passed.
  • Loading branch information
andreasnoack committed Oct 27, 2024
1 parent d766949 commit 92e76d8
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 25 deletions.
53 changes: 28 additions & 25 deletions src/eigenSelfAdjoint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,10 @@ function eigvalsPWK!(S::SymTridiagonal{T}; tol = eps(T), sortby::Union{Function,
end
end
end
LinearAlgebra.sorteig!(d, sortby)

# LinearAlgebra.eigvals will pass sortby=nothing but LAPACK always sort the symmetric
# eigenvalue problem so we'll will do the same here
LinearAlgebra.sorteig!(d, sortby === nothing ? LinearAlgebra.eigsortby : sortby)
end

function eigQL!(
Expand Down Expand Up @@ -639,30 +642,30 @@ else
LinearAlgebra.copy_oftype
end

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

# Aux (should go somewhere else at some point)
function LinearAlgebra.givensAlgorithm(f::Real, g::Real)
Expand Down
7 changes: 7 additions & 0 deletions test/eigenselfadjoint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,11 @@ using Test, GenericLinearAlgebra, LinearAlgebra, Quaternions
@test eigen(A).values == diag(A)
end
end

if VERSION >= v"1.11"
@testset "Method ambiguity in eigen with Julia 1.11 #141" begin
M = Hermitian(Tridiagonal(ones(ComplexF64, 2), ones(ComplexF64, 3), ones(ComplexF64, 2)))
@test eigen(M).values Float64.(eigen(big.(M)).values)
end
end
end

0 comments on commit 92e76d8

Please sign in to comment.