From 6aa0c7b0e8738b26debd930689d83b62fd75e5e3 Mon Sep 17 00:00:00 2001 From: Jutho Date: Thu, 2 Jan 2025 00:02:10 +0100 Subject: [PATCH] Fix bug in fusion tree iterator for multiple fusion case (#193) * fix bug in fusiontree iterator * patch update --- Project.toml | 2 +- src/fusiontrees/iterator.jl | 29 +++++++++++++++++------------ 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/Project.toml b/Project.toml index 8d9a2fd4..6074d4de 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "TensorKit" uuid = "07d1fe3e-3e46-537d-9eac-e9e13d0d4cec" authors = ["Jutho Haegeman"] -version = "0.14" +version = "0.14.1" [deps] LRUCache = "8ac3fa9e-de4c-5943-b1dc-09c6b5f20637" diff --git a/src/fusiontrees/iterator.jl b/src/fusiontrees/iterator.jl index 0f2ac3e4..bd8a95fc 100644 --- a/src/fusiontrees/iterator.jl +++ b/src/fusiontrees/iterator.jl @@ -198,21 +198,26 @@ function _fusiontree_iterate(uncoupledsectors::NTuple{N}, coupled::I, out, lines vertexiterN = c ⊗ dual(b) outstateN = states[end] vertexstateN = states[end - 1] + n = vertices[end] while isnothing(rest) - n = vertices[end] - n < Nsymbol(a, b, c) && return out, lines, (restvertices..., n + 1), states - nextline = iterate(vertexiterN, vertexstateN) - while isnothing(nextline) - nextout = iterate(outiterN, outstateN) - nextout === nothing && return nothing - b, outstateN = nextout - vertexiterN = c ⊗ dual(b) - nextline = iterate(vertexiterN) + if n < Nsymbol(a, b, c) + n += 1 + # reset the first part of the fusion tree + rest = _fusiontree_iterate(Base.front(uncoupledsectors), a) + else + nextline = iterate(vertexiterN, vertexstateN) + while isnothing(nextline) + nextout = iterate(outiterN, outstateN) + nextout === nothing && return nothing + b, outstateN = nextout + vertexiterN = c ⊗ dual(b) + nextline = iterate(vertexiterN) + end + a, vertexstateN = nextline + n = 1 + rest = _fusiontree_iterate(Base.front(uncoupledsectors), a) end - a, vertexstateN = nextline - rest = _fusiontree_iterate(Base.front(uncoupledsectors), a) end - n = 1 restout, restlines, restvertices, reststates = rest out = (restout..., b) lines = (restlines..., a)