Skip to content

Commit

Permalink
ishermitian(::Diagonal) now checks elementwise for nonreals
Browse files Browse the repository at this point in the history
Fix #10036
  • Loading branch information
jiahao committed Feb 3, 2015
1 parent 55d7f87 commit 881719b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion base/linalg/diagonal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ function getindex(D::Diagonal, i::Integer)
zero(eltype(D.diag))
end

ishermitian(D::Diagonal) = true
ishermitian{T<:Real}(D::Diagonal{T}) = true
ishermitian(D::Diagonal) = all(D.diag .== real(D.diag))
issym(D::Diagonal) = true
isposdef(D::Diagonal) = all(D.diag .> 0)

Expand Down
10 changes: 10 additions & 0 deletions test/linalg4.jl
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,16 @@ for relty in (Float32, Float64, BigFloat), elty in (relty, Complex{relty})
for op in (+, -, *)
@test_approx_eq full(op(D, D2)) op(DM, DM2)
end

#10036
@test issym(D2)
@test ishermitian(D2)
if elty <: Complex
dc = d + im*convert(Vector{elty}, ones(n))
D3 = Diagonal(dc)
@test issym(D3)
@test !ishermitian(D3)
end
end


Expand Down

0 comments on commit 881719b

Please sign in to comment.