Skip to content

Commit

Permalink
Fix sorting for purely imag value
Browse files Browse the repository at this point in the history
  • Loading branch information
jishnub committed Aug 27, 2024
1 parent 23c504d commit f666dd1
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2944,16 +2944,18 @@ end
@testset "eigen" begin
sortby = x -> (real(x), imag(x))
@testset "AbstractFill" begin
@testset for val in (2.0, -2, 3+2im, 4 - 5im, 2im), n in (VERSION >= v"1.10" ? (0, 1, 4) : (1, 4))
sizes = VERSION >= v"1.10" ? (0, 1, 4) : (1, 4)
@testset for val in (2.0, -2, 3+2im, 4 - 5im, 2im), n in sizes
sortby_val = iszero(real(val)) ? imag : sortby
F = Fill(val, n, n)
M = Matrix(F)
@test eigvals(F; sortby) eigvals(M; sortby)
λ, V = eigen(F; sortby)
@test λ == eigvals(F; sortby)
@test eigvals(F; sortby = sortby_val) eigvals(M; sortby = sortby_val)
λ, V = eigen(F; sortby = sortby_val)
@test λ == eigvals(F; sortby = sortby_val)
@test V'V I
@test F * V V * Diagonal(λ)
end
@testset for MT in (Ones, Zeros), T in (Float64, Int, ComplexF64), n in (0, 1, 4)
@testset for MT in (Ones, Zeros), T in (Float64, Int, ComplexF64), n in sizes
F = MT{T}(n,n)
M = Matrix(F)
@test eigvals(F; sortby) eigvals(M; sortby)
Expand Down

0 comments on commit f666dd1

Please sign in to comment.