@@ -255,35 +255,13 @@ function planarcontract!(
255255 throw (SpaceMismatch (" $(space (C)) ≠ permute($(space (A)) [$oindA , $cindA ] * $(space (B)) [$cindB , $oindB ], ($p1 , $p2 )" ))
256256 end
257257
258- if BraidingStyle (sectortype (B)) isa Bosonic
259- return add_permute! (C, B, (reverse (cindB), oindB), α, β, backend)
260- end
261-
262258 τ_levels = A. adjoint ? (1 , 2 , 2 , 1 ) : (2 , 1 , 1 , 2 )
263- scale! (C, β)
264-
265- inv_braid = τ_levels[cindA[1 ]] > τ_levels[cindA[2 ]]
266- for (f₁, f₂) in fusiontrees (B)
267- local newtrees
268- for ((f₁′, f₂′), coeff′) in transpose ((f₁, f₂), (cindB, oindB))
269- for (f₁′′, coeff′′) in artin_braid (f₁′, 1 ; inv = inv_braid)
270- f12 = (f₁′′, f₂′)
271- coeff = coeff′ * coeff′′
272- if @isdefined newtrees
273- newtrees[f12] = get (newtrees, f12, zero (coeff)) + coeff
274- else
275- newtrees = Dict (f12 => coeff)
276- end
277- end
278- end
279- for ((f₁′, f₂′), coeff) in newtrees
280- TO. tensoradd! (
281- C[f₁′, f₂′], B[f₁, f₂], (reverse (cindB), oindB), false ,
282- α * coeff, One (), backend, allocator
283- )
284- end
285- end
286- return C
259+ p = (reverse (cindB), oindB)
260+ nB = numind (B)
261+ levels = ntuple (i -> i + 2 , nB)
262+ levels = TupleTools. setindex (levels, τ_levels[cindA[1 ]], cindB[1 ])
263+ levels = TupleTools. setindex (levels, τ_levels[cindA[2 ]], cindB[2 ])
264+ return add_braid! (C, B, p, levels, α, β, backend)
287265end
288266function planarcontract! (
289267 C:: AbstractTensorMap ,
@@ -310,9 +288,16 @@ function planarcontract!(
310288 throw (SpaceMismatch (" $(space (C)) ≠ permute($(space (A)) [$oindA , $cindA ] * $(space (B)) [$cindB , $oindB ], ($p1 , $p2 )" ))
311289 end
312290
291+ if BraidingStyle (sectortype (A)) isa Bosonic
292+ return add_permute! (C, A, (oindA, reverse (cindA)), α, β, backend)
293+ end
294+
295+ τ_levels = B. adjoint ? (1 , 2 , 2 , 1 ) : (2 , 1 , 1 , 2 )
313296 p = (oindA, reverse (cindA))
314- N = length (oindA)
315- levels = (ntuple (identity, N)... , (B. adjoint ? (N + 1 , N + 2 ) : (N + 2 , N + 1 )). .. )
297+ nA = numind (A)
298+ levels = ntuple (i -> i + 2 , nA)
299+ levels = TupleTools. setindex (levels, τ_levels[cindB[1 ]], cindA[1 ])
300+ levels = TupleTools. setindex (levels, τ_levels[cindB[2 ]], cindA[2 ])
316301 return add_braid! (C, A, p, levels, α, β, backend)
317302end
318303
0 commit comments