File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change 974974
975975"""
976976 hermitianpart(A::AbstractMatrix, uplo::Symbol=:U) -> Hermitian
977+ hermitianpart(x::Number) -> Real
977978
978979Return the Hermitian part of the square matrix `A`, defined as `(A + A') / 2`, as a
979980[`Hermitian`](@ref) matrix. For real matrices `A`, this is also known as the symmetric part
@@ -987,6 +988,7 @@ See also [`hermitianpart!`](@ref) for the corresponding in-place operation.
987988 This function requires Julia 1.10 or later.
988989"""
989990hermitianpart (A:: AbstractMatrix , uplo:: Symbol = :U ) = Hermitian (_hermitianpart (A), uplo)
991+ hermitianpart (x:: Number ) = real (x)
990992
991993"""
992994 hermitianpart!(A::AbstractMatrix, uplo::Symbol=:U) -> Hermitian
Original file line number Diff line number Diff line change @@ -1035,6 +1035,14 @@ 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
1041+ @test hermitianpart (2.5 ) == 2.5
1042+ @test hermitianpart (- 1 + 0im ) == - 1
1043+ @test typeof (hermitianpart (3 + 4im )) == Int
1044+ @test typeof (hermitianpart (2.5 + 3im )) == Float64
1045+ end
10381046end
10391047
10401048@testset " Structured display" begin
You can’t perform that action at this time.
0 commit comments