Skip to content
This repository has been archived by the owner on Jul 7, 2024. It is now read-only.

Commit

Permalink
Format code
Browse files Browse the repository at this point in the history
  • Loading branch information
jofrevalles committed May 2, 2024
1 parent 35e6117 commit b126744
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/Ansatz/Chain.jl
Original file line number Diff line number Diff line change
Expand Up @@ -663,15 +663,21 @@ function evolve(ψ::Chain, mpo::Chain)
L = nsites(ψ)

for i in 1:L
t = contract(select(ψ, :tensor, Site(i)), select(mpo, :tensor, Site(i)); dims=(select(ψ, :index, Site(i)),))
t = contract(select(ψ, :tensor, Site(i)), select(mpo, :tensor, Site(i)); dims = (select(ψ, :index, Site(i)),))
physicalind = select(mpo, :index, Site(i))

# Fuse the two right legs of t into one
if i == 1
wanted_inds = (physicalind, rightindex(ψ, Site(i)), rightindex(mpo, Site(i)))
new_inds = (physicalind, rightindex(ψ, Site(i)))
elseif i < L
wanted_inds = (physicalind, leftindex(ψ, Site(i)), leftindex(mpo, Site(i)), rightindex(ψ, Site(i)), rightindex(mpo, Site(i)))
wanted_inds = (
physicalind,
leftindex(ψ, Site(i)),
leftindex(mpo, Site(i)),
rightindex(ψ, Site(i)),
rightindex(mpo, Site(i)),
)
new_inds = (physicalind, leftindex(ψ, Site(i)), rightindex(ψ, Site(i)))
else
wanted_inds = (physicalind, leftindex(ψ, Site(i)), leftindex(mpo, Site(i)))
Expand All @@ -681,7 +687,10 @@ function evolve(ψ::Chain, mpo::Chain)
perm = Tenet.__find_index_permutation(wanted_inds, inds(t))
t = PermutedDimsArray(parent(t), perm)

t = Tensor(reshape(t, tuple(size(t, 1), [size(t, k) * size(t, k + 1) for k in 2:2:length(wanted_inds)]...)), new_inds)
t = Tensor(
reshape(t, tuple(size(t, 1), [size(t, k) * size(t, k + 1) for k in 2:2:length(wanted_inds)]...)),
new_inds,
)
push!(updated_tensors, t)

if i < L
Expand Down

0 comments on commit b126744

Please sign in to comment.