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

RFC: sort eigenvalues in a canonical order #21598

Merged
merged 15 commits into from
Feb 5, 2019
Prev Previous commit
Next Next commit
simplify lapack test fixes
  • Loading branch information
stevengj committed Feb 1, 2019
commit c3fc98dac50db8f06220bca4e97a93f835a34019
17 changes: 7 additions & 10 deletions stdlib/LinearAlgebra/test/lapack.jl
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,7 @@ end
@testset for elty in (ComplexF32, ComplexF64)
A = rand(elty,10,10)
Aw, Avl, Avr = LAPACK.geev!('N','V',copy(A))
LinearAlgebra.sorteig!(Aw,Avr)
fA = eigen(A)
fA = eigen(A, sortby=nothing)
@test fA.values ≈ Aw
@test fA.vectors ≈ Avr
end
Expand Down Expand Up @@ -562,20 +561,18 @@ end
@testset "trrfs & trevc" begin
@testset for elty in (Float32, Float64, ComplexF32, ComplexF64)
T = triu(rand(elty,10,10))
i = sortperm(diag(T), by=LinearAlgebra.eigsortby)[1]
v = eigvecs(Matrix(T))[:,1]
kmax = sortperm(v, by=abs)[end]
v = eigvecs(T, sortby=nothing)[:,1]
select = zeros(LinearAlgebra.BlasInt,10)
select[i] = 1
select[1] = 1
select,Vr = LAPACK.trevc!('R','S',select,copy(T))
@test Vr ≈ v * Vr[kmax] / v[kmax]
@test Vr ≈ v
select = zeros(LinearAlgebra.BlasInt,10)
select[i] = 1
select[1] = 1
select,Vl = LAPACK.trevc!('L','S',select,copy(T))
select = zeros(LinearAlgebra.BlasInt,10)
select[i] = 1
select[1] = 1
select,Vln,Vrn = LAPACK.trevc!('B','S',select,copy(T))
@test Vrn ≈ v * Vrn[kmax] / v[kmax]
@test Vrn ≈ v
@test Vln ≈ Vl
@test_throws ArgumentError LAPACK.trevc!('V','S',select,copy(T))
@test_throws DimensionMismatch LAPACK.trrfs!('U','N','N',T,rand(elty,10,10),rand(elty,10,11))
Expand Down