File tree Expand file tree Collapse file tree 2 files changed +8
-0
lines changed Expand file tree Collapse file tree 2 files changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -1003,6 +1003,7 @@ end
10031003
10041004"""
10051005 hermitianpart(A::AbstractMatrix, uplo::Symbol=:U) -> Hermitian
1006+ hermitianpart(x::Number) -> Number
10061007
10071008Return the Hermitian part of the square matrix `A`, defined as `(A + A') / 2`, as a
10081009[`Hermitian`](@ref) matrix. For real matrices `A`, this is also known as the symmetric part
@@ -1016,6 +1017,7 @@ See also [`hermitianpart!`](@ref) for the corresponding in-place operation.
10161017 This function requires Julia 1.10 or later.
10171018"""
10181019hermitianpart (A:: AbstractMatrix , uplo:: Symbol = :U ) = Hermitian (_hermitianpart (A), uplo)
1020+ hermitianpart (x:: Number ) = real (x)
10191021
10201022"""
10211023 hermitianpart!(A::AbstractMatrix, uplo::Symbol=:U) -> Hermitian
Original file line number Diff line number Diff line change @@ -1035,6 +1035,12 @@ end
10351035 @test Aherm isa Hermitian
10361036 @test Aherm. uplo == LinearAlgebra. char_uplo (uplo)
10371037 end
1038+ @testset " hermitianpart for numbers" begin
1039+ @test hermitianpart (3 + 4im ) == 3
1040+ @test hermitianpart (5 ) == 5.0
1041+ @test hermitianpart (2.5 + 4.3im ) == 2.5
1042+ @test hermitianpart (- 1 + 0im ) == - 1
1043+ end
10381044end
10391045
10401046@testset " Structured display" begin
You can’t perform that action at this time.
0 commit comments