Skip to content

Commit

Permalink
Merge pull request #24055 from JuliaLang/ksh/cleansymm
Browse files Browse the repository at this point in the history
Some consolidation for symmetric tests
  • Loading branch information
kshyatt authored Oct 10, 2017
2 parents 19bce95 + f622689 commit 258736c
Showing 1 changed file with 16 additions and 19 deletions.
35 changes: 16 additions & 19 deletions test/linalg/symmetric.jl
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ end
@test asym === parent(Symmetric(asym))
@test aherm === parent(Hermitian(aherm))
end
# Unary minus for Symmetric/Hermitian matrices
@testset "Unary minus for Symmetric/Hermitian matrices" begin
@test (-Symmetric(asym))::typeof(Symmetric(asym)) == -asym
@test (-Hermitian(aherm))::typeof(Hermitian(aherm)) == -aherm
end

@testset "getindex and unsafe_getindex" begin
@test aherm[1,1] == Hermitian(aherm)[1,1]
Expand Down Expand Up @@ -186,6 +191,17 @@ end
@test inv(Hermitian(a, uplo))::Hermitian inv(Matrix(Hermitian(a, uplo)))
end
end
if eltya <: Base.LinAlg.BlasComplex
@testset "inverse edge case with complex Hermitian" begin
# Hermitian matrix, where inv(lufact(A)) generates non-real diagonal elements
for T in (Complex64, Complex128)
A = T[0.650488+0.0im 0.826686+0.667447im; 0.826686-0.667447im 1.81707+0.0im]
H = Hermitian(A)
@test inv(H) inv(A)
@test ishermitian(Matrix(inv(H)))
end
end
end
end

# Revisit when implemented in julia
Expand Down Expand Up @@ -354,15 +370,6 @@ end
@test_throws ArgumentError Hermitian(A)
end

# Unary minus for Symmetric/Hermitian matrices
@testset "Unary minus for Symmetric/Hermitian matrices" begin
A = randn(5, 5)
for SH in (Symmetric(A), Hermitian(A))
F = Matrix(SH)
@test (-SH)::typeof(SH) == -F
end
end

@testset "Issue #17780" begin
a = randn(2,2)
a = a'a
Expand Down Expand Up @@ -437,13 +444,3 @@ end
@test norm(inv(Hermitian(H))*(H*ones(8)) .- 1) 0 atol = 1e-5
end
end

@testset "inverse edge case with complex Hermitian" begin
# Hermitian matrix, where inv(lufact(A)) generates non-real diagonal elements
for T in (Complex64, Complex128)
A = T[0.650488+0.0im 0.826686+0.667447im; 0.826686-0.667447im 1.81707+0.0im]
H = Hermitian(A)
@test inv(H) inv(A)
@test ishermitian(Matrix(inv(H)))
end
end

0 comments on commit 258736c

Please sign in to comment.