@@ -54,9 +54,22 @@ numind(::Type{T}) where {T<:FusionTreeBlock} = numin(T) + numout(T)
5454fusiontrees (block:: FusionTreeBlock ) = block. trees
5555Base. length (block:: FusionTreeBlock ) = length (fusiontrees (block))
5656
57+ # Within one block, all values of uncoupled and isdual are equal, so avoid hashing these
58+ function treeindex_data ((f₁, f₂))
59+ I = sectortype (f₁)
60+ if FusionStyle (I) isa GenericFusion
61+ return (f₁. coupled, f₁. innerlines... , f₂. innerlines... ),
62+ (f₁. vertices... , f₂. vertices... )
63+ elseif FusionStyle (I) isa MultipleFusion
64+ return (f₁. coupled, f₁. innerlines... , f₂. innerlines... )
65+ else # there should be only a single element anyways
66+ return false
67+ end
68+ end
5769function treeindex_map (fs:: FusionTreeBlock )
5870 I = sectortype (fs)
59- return fusiontreedict (I)(f => ind for (ind, f) in enumerate (fusiontrees (fs)))
71+ return fusiontreedict (I)(treeindex_data (f) => ind
72+ for (ind, f) in enumerate (fusiontrees (fs)))
6073end
6174
6275# Manipulations
@@ -112,7 +125,7 @@ function bendright(src::FusionTreeBlock)
112125 coeff = coeff₀ * Bsymbol (a, b, c)
113126 vertices2 = N₂ > 0 ? (f₂. vertices... , 1 ) : ()
114127 f₂′ = FusionTree (uncoupled2, a, isdual2, inner2, vertices2)
115- row = indexmap[( f₁′, f₂′)]
128+ row = indexmap[treeindex_data (( f₁′, f₂′) )]
116129 @inbounds U[row, col] = coeff
117130 else
118131 Bmat = Bsymbol (a, b, c)
@@ -171,7 +184,7 @@ function bendleft(src::FusionTreeBlock)
171184 coeff = coeff₀ * Bsymbol (a, b, c)
172185 vertices2 = N₂ > 0 ? (f₂. vertices... , 1 ) : ()
173186 f₂′ = FusionTree (uncoupled2, a, isdual2, inner2, vertices2)
174- row = indexmap[( f₂′, f₁′)]
187+ row = indexmap[treeindex_data (( f₂′, f₁′) )]
175188 @inbounds U[row, col] = conj (coeff)
176189 else
177190 Bmat = Bsymbol (a, b, c)
@@ -181,7 +194,7 @@ function bendleft(src::FusionTreeBlock)
181194 iszero (coeff) && continue
182195 vertices2 = N₂ > 0 ? (f₂. vertices... , ν) : ()
183196 f₂′ = FusionTree (uncoupled2, a, isdual2, inner2, vertices2)
184- row = indexmap[( f₂′, f₁′)]
197+ row = indexmap[treeindex_data (( f₂′, f₁′) )]
185198 @inbounds U[row, col] = conj (coeff)
186199 end
187200 end
@@ -198,7 +211,7 @@ function foldright(src::FusionTreeBlock)
198211 N₁ = numout (src)
199212 N₂ = numin (src)
200213 @assert N₁ > 0
201- dst = FusionTreeBlock {sectortype(src) } (uncoupled_dst, isdual_dst)
214+ dst = FusionTreeBlock {I } (uncoupled_dst, isdual_dst)
202215
203216 dst = FusionTreeBlock {I} (uncoupled_dst, isdual_dst)
204217 indexmap = treeindex_map (dst)
@@ -220,7 +233,7 @@ function foldright(src::FusionTreeBlock)
220233 c = first (c1 ⊗ c2)
221234 fl = FusionTree {I} (Base. tail (f₁. uncoupled), c, Base. tail (f₁. isdual))
222235 fr = FusionTree {I} ((c1, f₂. uncoupled... ), c, (! isduala, f₂. isdual... ))
223- row = indexmap[( fl, fr)]
236+ row = indexmap[treeindex_data (( fl, fr) )]
224237 @inbounds U[row, col] = factor
225238 else
226239 if N₁ == 1
@@ -245,7 +258,7 @@ function foldright(src::FusionTreeBlock)
245258 fl = FusionTree {I} (uncoupled, coupled, isdual, inner, vertices)
246259 for (fr, coeff2) in frs_coeffs
247260 coeff = factor * coeff1 * conj (coeff2)
248- row = indexmap[( fl, fr)]
261+ row = indexmap[treeindex_data (( fl, fr) )]
249262 @inbounds U[row, col] = coeff
250263 end
251264 end
@@ -289,7 +302,7 @@ function foldleft(src::FusionTreeBlock)
289302 c = first (c1 ⊗ c2)
290303 fl = FusionTree {I} (Base. tail (f₁. uncoupled), c, Base. tail (f₁. isdual))
291304 fr = FusionTree {I} ((c1, f₂. uncoupled... ), c, (! isduala, f₂. isdual... ))
292- row = indexmap[( fr, fl)]
305+ row = indexmap[treeindex_data (( fr, fl) )]
293306 @inbounds U[row, col] = conj (factor)
294307 else
295308 if N₁ == 1
@@ -314,7 +327,7 @@ function foldleft(src::FusionTreeBlock)
314327 fl = FusionTree {I} (uncoupled, coupled, isdual, inner, vertices)
315328 for (fr, coeff2) in fr_coeffs
316329 coeff = factor * coeff1 * conj (coeff2)
317- row = indexmap[( fr, fl)]
330+ row = indexmap[treeindex_data (( fr, fl) )]
318331 @inbounds U[row, col] = conj (coeff)
319332 end
320333 end
@@ -477,7 +490,7 @@ function artin_braid(src::FusionTreeBlock{I,N,0}, i; inv::Bool=false) where {I,N
477490 vertices′ = TupleTools. setindex (vertices′, vertices[i - 1 ], i)
478491 end
479492 f′ = FusionTree {I} (uncoupled′, coupled′, isdual′, inner′, vertices′)
480- row = indexmap[( f′, f₂)]
493+ row = indexmap[treeindex_data (( f′, f₂) )]
481494 @inbounds U[row, col] = oneT
482495 continue
483496 end
@@ -490,18 +503,17 @@ function artin_braid(src::FusionTreeBlock{I,N,0}, i; inv::Bool=false) where {I,N
490503 if FusionStyle (I) isa MultiplicityFreeFusion
491504 R = oftype (oneT, (inv ? conj (Rsymbol (b, a, c)) : Rsymbol (a, b, c)))
492505 f′ = FusionTree {I} (uncoupled′, coupled′, isdual′, inner, vertices)
493- row = indexmap[( f′, f₂)]
506+ row = indexmap[treeindex_data (( f′, f₂) )]
494507 @inbounds U[row, col] = R
495508 else # GenericFusion
496509 μ = vertices[1 ]
497510 Rmat = inv ? Rsymbol (b, a, c)' : Rsymbol (a, b, c)
498- local newtrees
499511 for ν in axes (Rmat, 2 )
500512 R = oftype (oneT, Rmat[μ, ν])
501513 iszero (R) && continue
502514 vertices′ = TupleTools. setindex (vertices, ν, 1 )
503515 f′ = FusionTree {I} (uncoupled′, coupled′, isdual′, inner, vertices′)
504- row = indexmap[( f′, f₂)]
516+ row = indexmap[treeindex_data (( f′, f₂) )]
505517 @inbounds U[row, col] = R
506518 end
507519 end
@@ -525,7 +537,7 @@ function artin_braid(src::FusionTreeBlock{I,N,0}, i; inv::Bool=false) where {I,N
525537 end )
526538 inner′ = TupleTools. setindex (inner, c′, i - 1 )
527539 f′ = FusionTree {I} (uncoupled′, coupled′, isdual′, inner′)
528- row = indexmap[( f′, f₂)]
540+ row = indexmap[treeindex_data (( f′, f₂) )]
529541 @inbounds U[row, col] = coeff
530542 elseif FusionStyle (I) isa SimpleFusion
531543 cs = collect (I, intersect (a ⊗ d, e ⊗ conj (b)))
@@ -541,7 +553,7 @@ function artin_braid(src::FusionTreeBlock{I,N,0}, i; inv::Bool=false) where {I,N
541553 iszero (coeff) && continue
542554 inner′ = TupleTools. setindex (inner, c′, i - 1 )
543555 f′ = FusionTree {I} (uncoupled′, coupled′, isdual′, inner′)
544- row = indexmap[( f′, f₂)]
556+ row = indexmap[treeindex_data (( f′, f₂) )]
545557 @inbounds U[row, col] = coeff
546558 end
547559 else # GenericFusion
@@ -564,7 +576,7 @@ function artin_braid(src::FusionTreeBlock{I,N,0}, i; inv::Bool=false) where {I,N
564576 vertices′ = TupleTools. setindex (vertices′, λ, i)
565577 inner′ = TupleTools. setindex (inner, c′, i - 1 )
566578 f′ = FusionTree {I} (uncoupled′, coupled′, isdual′, inner′, vertices′)
567- row = indexmap[( f′, f₂)]
579+ row = indexmap[treeindex_data (( f′, f₂) )]
568580 @inbounds U[row, col] = coeff
569581 end
570582 end
0 commit comments