@@ -1003,21 +1003,26 @@ end
10031003
10041004""" 
10051005    hermitianpart(A::AbstractMatrix, uplo::Symbol=:U) -> Hermitian 
1006-     hermitianpart(x::Number) -> Real  
1006+     hermitianpart(x::Number) -> Number  
10071007
10081008Return the Hermitian part of the square matrix `A`, defined as `(A + A') / 2`, as a 
10091009[`Hermitian`](@ref) matrix. For real matrices `A`, this is also known as the symmetric part 
10101010of `A`; it is also sometimes called the "operator real part". The optional argument `uplo` controls the corresponding argument of the 
10111011[`Hermitian`](@ref) view. For real matrices, the latter is equivalent to a 
10121012[`Symmetric`](@ref) view. 
10131013
1014+ For scalar inputs `x`, the function returns the real part of `x`. Standard integer scalars 
1015+ are promoted to `Float64` to align with the behavior of 1×1 Hermitian matrices, while other numeric types 
1016+ (`Float32`, `BigInt`, `Rational`, `BigFloat`) are preserved. 
1017+ 
10141018See also [`hermitianpart!`](@ref) for the corresponding in-place operation. 
10151019
10161020!!! compat "Julia 1.10" 
10171021    This function requires Julia 1.10 or later. 
10181022""" 
1023+ 
10191024hermitianpart (A:: AbstractMatrix , uplo:: Symbol = :U ) =  Hermitian (_hermitianpart (A), uplo)
1020- hermitianpart (x:: Number ) =  real (x)
1025+ hermitianpart (x:: Number ) =  float ( real (x) )
10211026
10221027""" 
10231028    hermitianpart!(A::AbstractMatrix, uplo::Symbol=:U) -> Hermitian 
@@ -1054,4 +1059,4 @@ function Base.replace_in_print_matrix(A::HermOrSym,i::Integer,j::Integer,s::Abst
10541059    ijminmax =  minmax (i, j)
10551060    inds =  A. uplo ==  ' U' ?  ijminmax :  reverse (ijminmax)
10561061    Base. replace_in_print_matrix (parent (A), inds... , s)
1057- end 
1062+ end 
0 commit comments