Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove some pirated methods for the symmetric eigenvalue problem. #142

Merged
merged 2 commits into from
Oct 27, 2024
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
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ jobs:
fail-fast: false
matrix:
version:
- 'min'
- 'lts'
- 'nightly'
- '1'
- 'pre'
os:
- ubuntu-latest
# - macos-latest
Expand Down
53 changes: 29 additions & 24 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,29 +642,31 @@ 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))
if VERSION < v"1.7"
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
end

# Aux (should go somewhere else at some point)
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