diff --git a/stdlib/LinearAlgebra/test/symmetric.jl b/stdlib/LinearAlgebra/test/symmetric.jl index 8a5efa21ec4a7..1a3fcea592a57 100644 --- a/stdlib/LinearAlgebra/test/symmetric.jl +++ b/stdlib/LinearAlgebra/test/symmetric.jl @@ -825,6 +825,7 @@ end end @testset "issue #49533" begin + # Real valued A = Float64[1 1 0 0; 1 2 1 0; 0 1 3 1; 0 0 1 4] ; B = Matrix(Diagonal(Float64[1:4;])) ; # eigen @@ -836,6 +837,21 @@ end # eigvals @test eigvals(A, B) ≈ eigvals(A, Symmetric(B)) @test eigvals(A, B) ≈ eigvals(Symmetric(A), B) + # Complex valued + A = [1.0+im 1.0+1.0im 0 0; 1.0+1.0im 2.0+3.0im 1.0+1.0im 0; 0 1.0+2.0im 3.0+4.0im 1.0+5.0im; 0 0 1.0+1.0im 4.0+4.0im] ; + A = (A+A')/2 ; + B = [2.0+2.0im 1.0+1.0im 4.0+4.0im 3.0+3.0im; 0 3.0+2.0im 1.0+1.0im 3.0+4.0im; 3.0+3.0im 1.0+4.0im 0 0; 0 1.0+2.0im 3.0+1.0im 1.0+1.0im]; + B = (B+B')/2 ; + # eigen + sf = x->(real(x),imag(x)) + e0,v0 = eigen(A, B; sortby=sf) + e1,v1 = eigen(A, Hermitian(B); sortby=sf) + e2,v2 = eigen(Hermitian(A), B; sortby=sf) + @test e0 ≈ e1 && v0 ≈ v1 + @test e0 ≈ e2 && v0 ≈ v2 + # eigvals + @test eigvals(A, B; sortby=sf) ≈ eigvals(A, Hermitian(B); sortby=sf) + @test eigvals(A, B; sortby=sf) ≈ eigvals(Hermitian(A), B; sortby=sf) end end # module TestSymmetric