Skip to content

Commit 6aa0c7b

Browse files
authored
Fix bug in fusion tree iterator for multiple fusion case (#193)
* fix bug in fusiontree iterator * patch update
1 parent 00eb107 commit 6aa0c7b

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "TensorKit"
22
uuid = "07d1fe3e-3e46-537d-9eac-e9e13d0d4cec"
33
authors = ["Jutho Haegeman"]
4-
version = "0.14"
4+
version = "0.14.1"
55

66
[deps]
77
LRUCache = "8ac3fa9e-de4c-5943-b1dc-09c6b5f20637"

src/fusiontrees/iterator.jl

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -198,21 +198,26 @@ function _fusiontree_iterate(uncoupledsectors::NTuple{N}, coupled::I, out, lines
198198
vertexiterN = c dual(b)
199199
outstateN = states[end]
200200
vertexstateN = states[end - 1]
201+
n = vertices[end]
201202
while isnothing(rest)
202-
n = vertices[end]
203-
n < Nsymbol(a, b, c) && return out, lines, (restvertices..., n + 1), states
204-
nextline = iterate(vertexiterN, vertexstateN)
205-
while isnothing(nextline)
206-
nextout = iterate(outiterN, outstateN)
207-
nextout === nothing && return nothing
208-
b, outstateN = nextout
209-
vertexiterN = c dual(b)
210-
nextline = iterate(vertexiterN)
203+
if n < Nsymbol(a, b, c)
204+
n += 1
205+
# reset the first part of the fusion tree
206+
rest = _fusiontree_iterate(Base.front(uncoupledsectors), a)
207+
else
208+
nextline = iterate(vertexiterN, vertexstateN)
209+
while isnothing(nextline)
210+
nextout = iterate(outiterN, outstateN)
211+
nextout === nothing && return nothing
212+
b, outstateN = nextout
213+
vertexiterN = c dual(b)
214+
nextline = iterate(vertexiterN)
215+
end
216+
a, vertexstateN = nextline
217+
n = 1
218+
rest = _fusiontree_iterate(Base.front(uncoupledsectors), a)
211219
end
212-
a, vertexstateN = nextline
213-
rest = _fusiontree_iterate(Base.front(uncoupledsectors), a)
214220
end
215-
n = 1
216221
restout, restlines, restvertices, reststates = rest
217222
out = (restout..., b)
218223
lines = (restlines..., a)

0 commit comments

Comments
 (0)