Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/generic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1350,7 +1350,7 @@ function issymmetric(A::AbstractMatrix)
return true
end

issymmetric(x::Number) = x == x
issymmetric(x::Number) = true

"""
ishermitian(A) -> Bool
Expand Down Expand Up @@ -1389,7 +1389,7 @@ function ishermitian(A::AbstractMatrix)
return true
end

ishermitian(x::Number) = (x == conj(x))
ishermitian(x::Number) = isreal(x)

# helper function equivalent to `iszero(v)`, but potentially without the fast exit feature
# of `all` if this improves performance
Expand Down
8 changes: 8 additions & 0 deletions test/generic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -943,4 +943,12 @@ end
@test B == A2
end

@testset "issymmetric/ishermitian for Numbers" begin
fsym(x) = Val(issymmetric(x))
@test @inferred(fsym(2)) isa Val{true}
@test @inferred(fsym(2im)) isa Val{true}
fherm(x) = Val(ishermitian(x))
@test @inferred(fherm(2)) isa Val{true}
end

end # module TestGeneric