Skip to content

Commit

Permalink
Additional tests for #49533: Hermitian symmetric matrices.
Browse files Browse the repository at this point in the history
  • Loading branch information
aravindh-krishnamoorthy committed May 7, 2023
1 parent 4701fbc commit 556627e
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions stdlib/LinearAlgebra/test/symmetric.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit 556627e

Please sign in to comment.