Skip to content

Commit ed01ea5

Browse files
committed
Suggestions
1 parent a17b39b commit ed01ea5

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/tensor_operations/matrix_decomposition.jl

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -592,14 +592,10 @@ end
592592

593593
# Take the square root of T assuming it is Hermitian
594594
# TODO: add more general index structures
595-
function Base.sqrt(T::ITensor; ishermitian=true, atol=1e-15)
595+
function Base.sqrt(T::ITensor; ishermitian=true, atol=eps(real(eltype(T))))
596596
@assert ishermitian
597-
# TODO diagonal version
598-
#if isdiag(T) && order(T) == 2
599-
# return itensor(sqrt(tensor(T)))
600-
#end
601-
D, U = eigen(T; ishermitian=ishermitian)
602-
sqrtD = map_diag(x -> x < 0 && abs(x) < atol ? 0 : sqrt(x), D)
597+
D, U = eigen(T; ishermitian)
598+
sqrtD = map_diag(x -> x < 0 && abs(x) < atol ? zero(real(eltype(T))) : sqrt(Complex(x)), D)
603599
return U' * sqrtD * dag(U)
604600
end
605601

0 commit comments

Comments
 (0)