Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/algorithms/changebonds/svdcut.jl
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@
ψ = if space(ncr, 1) != space(copied[1], 1)
InfiniteMPS(copied)
else
InfiniteMPS(copied, complex(ncr))
C₀ = TensorMap(complex(ncr))
InfiniteMPS(copied, C₀)

Check warning on line 95 in src/algorithms/changebonds/svdcut.jl

View check run for this annotation

Codecov / codecov/patch

src/algorithms/changebonds/svdcut.jl#L94-L95

Added lines #L94 - L95 were not covered by tests
end
return normalize!(ψ)
end
Expand Down
21 changes: 15 additions & 6 deletions src/algorithms/toolbox.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,20 @@ Calculate the Von Neumann entanglement entropy of a given MPS. If an integer `si
given, the entropy is across the entanglement cut to the right of site `site`. Otherwise, a
vector of entropies is returned, one for each site.
"""
entropy(state::InfiniteMPS) = map(c -> -tr(safe_xlogx(c * c')), state.C);
entropy(state::InfiniteMPS) = map(Base.Fix1(entropy, state), 1:length(state))
function entropy(state::Union{FiniteMPS,WindowMPS,InfiniteMPS}, loc::Int)
return -tr(safe_xlogx(state.C[loc] * state.C[loc]'))
end;
S = zero(real(scalartype(state)))
tol = eps(typeof(S))
for (c, b) in entanglement_spectrum(state, loc)
s = zero(S)
for x in b
x < tol && break
s += (x * log(x))^2
end
S += oftype(S, dim(c) * s)
end
return S
end

# function infinite_temperature(H::MPOHamiltonian)
# return [permute(isomorphism(storagetype(H[1, 1, 1]), oneunit(sp) * sp,
Expand Down Expand Up @@ -84,9 +94,8 @@ matrix to the right of a given site. This is a dictionary mapping the charge to
values.
"""
function entanglement_spectrum(st::Union{InfiniteMPS,FiniteMPS,WindowMPS}, site::Int=0)
@assert site <= length(st)
_, S, = tsvd(st.C[site])
return TensorKit.SectorDict(c => real(diag(b)) for (c, b) in blocks(S))
checkbounds(st, site)
return LinearAlgebra.svdvals(st.C[site])
end

"""
Expand Down
5 changes: 0 additions & 5 deletions src/utility/utility.jl
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,6 @@ function randomize!(a::AbstractBlockTensorMap)
return a
end

function safe_xlogx(t::AbstractTensorMap, eps=eps(real(scalartype(t))))
(U, S, V) = tsvd(t; alg=SVD(), trunc=truncbelow(eps))
return U * S * log(S) * V
end

"""
tensorexpr(name::Symbol, ind_out, [ind_in])

Expand Down
Loading