Skip to content

Commit

Permalink
add more degenerate tests for 2x2 eigen
Browse files Browse the repository at this point in the history
  • Loading branch information
tfgast committed Dec 12, 2019
1 parent 90d0151 commit de286f6
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions test/eigen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,25 @@ using StaticArrays, Test, LinearAlgebra
@test vals::SVector sort(m_d)
@test eigvals(m_c) sort(m_d)
@test eigvals(Hermitian(m_c)) sort(m_d)
end

# issue #523
for (i, j) in ((1, 2), (2, 1)), uplo in (:U, :L)
A = SMatrix{2,2,Float64}((i, 0, 0, j))
E = eigen(Symmetric(A, uplo))
@test eigvecs(E) * SDiagonal(eigvals(E)) * eigvecs(E)' A
end
# issue #523
@testset "2×2 degenerate cases" for (i, j) in ((1 , 1), (1, 2), (2, 1)), uplo in (:U, :L)
fmin = floatmin(Float64)
pfmin = prevfloat(fmin)
nfmin = nextfloat(fmin)
A = SMatrix{2,2,Float64}((i, 0, 0, j))
E = eigen(Symmetric(A, uplo))
@test eigvecs(E) * SDiagonal(eigvals(E)) * eigvecs(E)' A
A = SMatrix{2,2,Float64}((i, pfmin, pfmin, j))
E = eigen(Symmetric(A, uplo))
@test eigvecs(E) * SDiagonal(eigvals(E)) * eigvecs(E)' A
A = SMatrix{2,2,Float64}((i, fmin, fmin, j))
E = eigen(Symmetric(A, uplo))
@test eigvecs(E) * SDiagonal(eigvals(E)) * eigvecs(E)' A
A = SMatrix{2,2,Float64}((i, nfmin, nfmin, j))
E = eigen(Symmetric(A, uplo))
@test eigvecs(E) * SDiagonal(eigvals(E)) * eigvecs(E)' A
end

@testset "3×3" for i = 1:100
Expand Down

0 comments on commit de286f6

Please sign in to comment.