@@ -5,10 +5,20 @@ Calculate the Von Neumann entanglement entropy of a given MPS. If an integer `si
55given, the entropy is across the entanglement cut to the right of site `site`. Otherwise, a
66vector of entropies is returned, one for each site.
77"""
8- entropy (state:: InfiniteMPS ) = map (c -> - tr ( safe_xlogx (c * c ' )), state. C);
8+ entropy (state:: InfiniteMPS ) = map (Base . Fix1 (entropy, state), 1 : length ( state))
99function entropy (state:: Union{FiniteMPS,WindowMPS,InfiniteMPS} , loc:: Int )
10- return - tr (safe_xlogx (state. C[loc] * state. C[loc]' ))
11- end ;
10+ S = zero (real (scalartype (state)))
11+ tol = eps (typeof (S))
12+ for (c, b) in entanglement_spectrum (state, loc)
13+ s = zero (S)
14+ for x in b
15+ x < tol && break
16+ s += (x * log (x))^ 2
17+ end
18+ S += oftype (S, dim (c) * s)
19+ end
20+ return S
21+ end
1222
1323# function infinite_temperature(H::MPOHamiltonian)
1424# return [permute(isomorphism(storagetype(H[1, 1, 1]), oneunit(sp) * sp,
@@ -84,9 +94,8 @@ matrix to the right of a given site. This is a dictionary mapping the charge to
8494values.
8595"""
8696function entanglement_spectrum (st:: Union{InfiniteMPS,FiniteMPS,WindowMPS} , site:: Int = 0 )
87- @assert site <= length (st)
88- _, S, = tsvd (st. C[site])
89- return TensorKit. SectorDict (c => real (diag (b)) for (c, b) in blocks (S))
97+ checkbounds (st, site)
98+ return LinearAlgebra. svdvals (st. C[site])
9099end
91100
92101"""
0 commit comments