@@ -141,23 +141,21 @@ end
141141# matrix breaks the hermiticity, if the UniformScaling is non-real.
142142# However, to preserve type stability, we do not special-case a
143143# UniformScaling{<:Complex} that happens to be real.
144- function (+ )(A:: Hermitian{T,S} , J:: UniformScaling{<:Complex} ) where {T,S}
145- A_ = copytri! ( copy ( parent (A)), A . uplo )
146- B = convert (AbstractMatrix{Base . _return_type ( + , Tuple{ eltype (A), typeof (J)})}, A_ )
147- @inbounds for i in diagind (B)
148- B[i] += J
144+ function (+ )(A:: Hermitian , J:: UniformScaling{<:Complex} )
145+ TS = Base . _return_type ( + , Tuple{ eltype (A), typeof (J)} )
146+ B = copytri! ( copy_oftype ( parent (A), TS), A . uplo, true )
147+ for i in diagind (B)
148+ B[i] = A[i] + J
149149 end
150150 return B
151151end
152152
153- function (- )(J:: UniformScaling{<:Complex} , A:: Hermitian{T,S} ) where {T,S}
154- A_ = copytri! (copy (parent (A)), A. uplo)
155- B = convert (AbstractMatrix{Base. _return_type (+ , Tuple{eltype (A), typeof (J)})}, A_)
156- @inbounds for i in eachindex (B)
157- B[i] = - B[i]
158- end
159- @inbounds for i in diagind (B)
160- B[i] += J
153+ function (- )(J:: UniformScaling{<:Complex} , A:: Hermitian )
154+ TS = Base. _return_type (+ , Tuple{eltype (A), typeof (J)})
155+ B = copytri! (copy_oftype (parent (A), TS), A. uplo, true )
156+ B .= .- B
157+ for i in diagind (B)
158+ B[i] = J - A[i]
161159 end
162160 return B
163161end
0 commit comments