Skip to content

missing hermitianpart(x::Number) = real(x) #1438

@stevengj

Description

@stevengj

It seems like this should be defined for numbers, since hermitianpart is just a generalization of the real part (indeed, in some literature it is called the "operator real part"):

julia> hermitianpart(3+4im)
ERROR: MethodError: no method matching hermitianpart(::Complex{Int64})

Should be easy for someone to add a hermitianpart(x::Number) = real(x), update the docstring, and add a test.

(This came up in #1437 for generic code on Hermitian(::Diagonal). Note that the original PR for hermitianpart included a ::Number method, but it was removed by @dkarrasch at the time because the application was unclear, but with the option of adding it back: JuliaLang/julia#31836 (comment))

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions