We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a17b39b commit ed01ea5Copy full SHA for ed01ea5
src/tensor_operations/matrix_decomposition.jl
@@ -592,14 +592,10 @@ end
592
593
# Take the square root of T assuming it is Hermitian
594
# TODO: add more general index structures
595
-function Base.sqrt(T::ITensor; ishermitian=true, atol=1e-15)
+function Base.sqrt(T::ITensor; ishermitian=true, atol=eps(real(eltype(T))))
596
@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)
+ D, U = eigen(T; ishermitian)
+ sqrtD = map_diag(x -> x < 0 && abs(x) < atol ? zero(real(eltype(T))) : sqrt(Complex(x)), D)
603
return U' * sqrtD * dag(U)
604
end
605
0 commit comments