Skip to content

Commit e096a03

Browse files
authored
Don't mutate arrays in symmetric trig functions (#1206)
1 parent c234bed commit e096a03

File tree

1 file changed

+0
-12
lines changed

1 file changed

+0
-12
lines changed

src/symmetric.jl

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -900,9 +900,6 @@ for func in (:exp, :cos, :sin, :tan, :cosh, :sinh, :tanh, :atan, :asinh, :atanh,
900900
function ($func)(A::Hermitian{<:Complex})
901901
F = eigen(A)
902902
retmat = (F.vectors * Diagonal(($func).(F.values))) * F.vectors'
903-
for i in diagind(retmat, IndexStyle(retmat))
904-
retmat[i] = real(retmat[i])
905-
end
906903
return Hermitian(retmat)
907904
end
908905
end
@@ -932,9 +929,6 @@ for func in (:acos, :asin)
932929
F = eigen(A)
933930
if all-> -1 λ 1, F.values)
934931
retmat = (F.vectors * Diagonal(($func).(F.values))) * F.vectors'
935-
for i in diagind(retmat, IndexStyle(retmat))
936-
retmat[i] = real(retmat[i])
937-
end
938932
return Hermitian(retmat)
939933
else
940934
return (F.vectors * Diagonal(($func).(complex.(F.values)))) * F.vectors'
@@ -955,9 +949,6 @@ function acosh(A::Hermitian{<:Complex})
955949
F = eigen(A)
956950
if all-> λ 1, F.values)
957951
retmat = (F.vectors * Diagonal(acosh.(F.values))) * F.vectors'
958-
for i in diagind(retmat, IndexStyle(retmat))
959-
retmat[i] = real(retmat[i])
960-
end
961952
return Hermitian(retmat)
962953
else
963954
return (F.vectors * Diagonal(acosh.(complex.(F.values)))) * F.vectors'
@@ -1011,9 +1002,6 @@ for func in (:log, :sqrt)
10111002
λ₀ = $rtolval # treat λ ≥ λ₀ as "zero" eigenvalues up to roundoff
10121003
if all-> λ λ₀, F.values)
10131004
retmat = (F.vectors * Diagonal(($func).(max.(0, F.values)))) * F.vectors'
1014-
for i in diagind(retmat, IndexStyle(retmat))
1015-
retmat[i] = real(retmat[i])
1016-
end
10171005
return Hermitian(retmat)
10181006
else
10191007
retmat = (F.vectors * Diagonal(($func).(complex.(F.values)))) * F.vectors'

0 commit comments

Comments
 (0)