From f666dd1f5ed113819f317d8eab15628de90134a4 Mon Sep 17 00:00:00 2001 From: Jishnu Bhattacharya Date: Wed, 21 Aug 2024 18:00:31 +0530 Subject: [PATCH] Fix sorting for purely imag value --- test/runtests.jl | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index 4d0aa913..e7effea8 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -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)