5353unpartition (:: Type{ProductSector{T}} , g, a) where {T} =
5454 ProductSector {T} (interleave (T, factortuple (g), factortuple (a)))
5555
56- headsector (s:: ProductSector ) =
57- ismixedproduct (typeof (s)) ? first (partitionfactors (s)) : firstfactor (s)
58- tailsector (s:: ProductSector ) =
59- ismixedproduct (typeof (s)) ? last (partitionfactors (s)) : otherfactors (s)
60- headsectortype (:: Type{I} ) where {I <: ProductSector } =
61- ismixedproduct (I) ? first (partitionfactortypes (I)) : firstfactortype (I)
62- tailsectortype (:: Type{I} ) where {I <: ProductSector } =
63- ismixedproduct (I) ? last (partitionfactortypes (I)) : otherfactorstype (I)
64- joinsectors (:: Type{I} , h, t) where {I <: ProductSector } =
65- ismixedproduct (I) ? unpartition (I, h, t) : h ⊠ t
56+ headsector (s:: ProductSector ) = ismixedproduct (typeof (s)) ? first (partitionfactors (s)) : firstfactor (s)
57+ tailsector (s:: ProductSector ) = ismixedproduct (typeof (s)) ? last (partitionfactors (s)) : otherfactors (s)
58+ headsectortype (:: Type{I} ) where {I <: ProductSector } = ismixedproduct (I) ? first (partitionfactortypes (I)) : firstfactortype (I)
59+ tailsectortype (:: Type{I} ) where {I <: ProductSector } = ismixedproduct (I) ? last (partitionfactortypes (I)) : otherfactorstype (I)
60+ joinsectors (:: Type{I} , h, t) where {I <: ProductSector } = ismixedproduct (I) ? unpartition (I, h, t) : h ⊠ t
6661
6762# named products are split and joined as the corresponding `ProductSector`
6863productsectortype (:: Type{NamedSector{NamedTuple{K, T}}} ) where {K, T} = ProductSector{T}
@@ -90,9 +85,10 @@ function headtail(f::FusionTree)
9085 return maptree (headsector, f, vertices_h), maptree (tailsector, f, vertices_t)
9186end
9287function jointree (:: Type{I} , h:: FusionTree , t:: FusionTree ) where {I}
93- vertices = h. vertices
94- if FusionStyle (I) isa GenericFusion && length (h) > 1
88+ vertices = if FusionStyle (I) isa GenericFusion && length (h) > 1
9589 vertices = map ((μ, ν, n) -> ν + (μ - 1 ) * n, h. vertices, t. vertices, vertexmultiplicities (t))
90+ else
91+ h. vertices
9692 end
9793 lift (a, b) = joinsectors (I, a, b)
9894 return fusiontreetype (I, length (h))(
10399
104100# the canonical order of a product block is that of the Kronecker product of the head and tail
105101# blocks, with the head running fastest
106- productblock (:: Type{I} , head:: FusionTreeBlock , tail:: FusionTreeBlock ) where {I} = FusionTreeBlock (
107- vec (
108- [
109- (jointree (I, h₁, t₁), jointree (I, h₂, t₂))
110- for (h₁, h₂) in fusiontrees (head), (t₁, t₂) in fusiontrees (tail)
111- ]
112- )
113- )
102+ function productblock (:: Type{I} , head:: FusionTreeBlock , tail:: FusionTreeBlock ) where {I}
103+ trees = [(jointree (I, h₁, t₁), jointree (I, h₂, t₂)) for (h₁, h₂) in fusiontrees (head), (t₁, t₂) in fusiontrees (tail)]
104+ return FusionTreeBlock (vec (trees))
105+ end
106+
114107function FusionTreeBlock {I} (
115108 uncoupled:: Tuple{NTuple{N₁, I}, NTuple{N₂, I}} ,
116109 isdual:: Tuple{NTuple{N₁, Bool}, NTuple{N₂, Bool}} ;
117110 sizehint:: Int = 0
118111 ) where {I <: ProductSectorType , N₁, N₂}
119112 # a block of `UniqueFusion` sectors has a single tree pair, in any order
120113 FusionStyle (I) isa UniqueFusion && return fusiontreeblock (I, uncoupled, isdual; sizehint)
114+
121115 # the tail holds the `UniqueFusion` factors of a mixed product, which are cheaper to construct
122116 tail = FusionTreeBlock {tailsectortype(I)} (map .(tailsector, uncoupled), isdual)
123117 isempty (tail) && return FusionTreeBlock (Vector {fusiontreetype(I, N₁, N₂)} ())
118+
124119 head = FusionTreeBlock {headsectortype(I)} (map .(headsector, uncoupled), isdual)
125120 return productblock (I, head, tail)
126121end
@@ -141,8 +136,7 @@ function factor_transform(transform::F, ::Type{T}, src::FusionTreeBlock) where {
141136 return FusionTreeBlock (map (first, dst)) => LinearAlgebra. diagm (T[last (d) for d in dst])
142137end
143138
144- # apply `transform` to the block `src` through its head and tail, with the recoupling
145- # matrix with scalar type `T`
139+ # apply `transform` to the block `src` through its head and tail, with the recoupling matrix with scalar type `T`
146140function product_transform (transform:: F , :: Type{T} , src:: FusionTreeBlock{I} ) where {F, T, I}
147141 if FusionStyle (I) isa UniqueFusion
148142 return factor_transform (transform, T, src)
0 commit comments