@@ -27,29 +27,29 @@ _sectortuple(s::Sector) = (s,)
2727# select the entries at compile-time positions, which keeps heterogeneous tuples inferable
2828@generated _getentries (t:: Tuple , :: Val{P} ) where {P} = Expr (:tuple , (:(t[$ i]) for i in P). .. )
2929
30- function productparts (s:: ProductSector )
30+ function deconstructsector (s:: ProductSector )
3131 positions₁, positions₂ = _partpositions (typeof (s))
3232 return _sectorproduct (_getentries (s. sectors, Val (positions₁))),
3333 _sectorproduct (_getentries (s. sectors, Val (positions₂)))
3434end
35- Base. @assume_effects :foldable function productpartstypes (:: Type{ProductSector{T}} ) where {T}
35+ Base. @assume_effects :foldable function deconstructsectortype (:: Type{ProductSector{T}} ) where {T}
3636 return map (_partpositions (ProductSector{T})) do positions
3737 return length (positions) == 1 ? fieldtype (T, only (positions)) :
3838 ProductSector{Tuple{map (i -> fieldtype (T, i), positions)... }}
3939 end
4040end
41- function _joinparts (:: Type{ProductSector{T}} , s₁:: Sector , s₂:: Sector ) where {T}
41+ function reconstructsector (:: Type{ProductSector{T}} , s₁:: Sector , s₂:: Sector ) where {T}
4242 sectors = (_sectortuple (s₁)... , _sectortuple (s₂)... )
4343 positions = TupleTools. invperm (TupleTools. vcat (_partpositions (ProductSector{T})... ))
4444 return ProductSector {T} (_getentries (sectors, Val (positions)))
4545end
4646
4747# named products are split and joined as the corresponding `ProductSector`
4848_productsectortype (:: Type{NamedSector{NamedTuple{K, T}}} ) where {K, T} = ProductSector{T}
49- productparts (s:: NamedSector ) = productparts (ProductSector (s))
50- productpartstypes (:: Type{I} ) where {I <: NamedSector } = productpartstypes (_productsectortype (I))
51- _joinparts (:: Type{I} , s₁:: Sector , s₂:: Sector ) where {I <: NamedSector } =
52- I (_joinparts (_productsectortype (I), s₁, s₂))
49+ deconstructsector (s:: NamedSector ) = deconstructsector (ProductSector (s))
50+ deconstructsectortype (:: Type{I} ) where {I <: NamedSector } = deconstructsectortype (_productsectortype (I))
51+ reconstructsector (:: Type{I} , s₁:: Sector , s₂:: Sector ) where {I <: NamedSector } =
52+ I (reconstructsector (_productsectortype (I), s₁, s₂))
5353
5454# the vertex labels of a product are the linear indices of the labels of its parts, with the second
5555# part running fastest, such that a `UniqueFusion` second part leaves the labels of the first unchanged
@@ -60,24 +60,25 @@ _vertexmultiplicities(f::FusionTree) =
6060_maptree (proj, f:: FusionTree , vertices) = FusionTree (
6161 map (proj, f. uncoupled), proj (f. coupled), f. isdual, map (proj, f. innerlines), vertices
6262)
63- function productparts (f:: FusionTree )
63+ function deconstructtree (f:: FusionTree )
6464 vertices₁ = vertices₂ = f. vertices
65- if FusionStyle (last (productpartstypes (sectortype (f)))) isa UniqueFusion
65+ if FusionStyle (last (deconstructsectortype (sectortype (f)))) isa UniqueFusion
6666 vertices₂ = map (Returns (1 ), f. vertices)
6767 elseif FusionStyle (f) isa GenericFusion && length (f) > 1
68- ns = _vertexmultiplicities (_maptree (last ∘ productparts , f, map (Returns (1 ), f. vertices)))
68+ ns = _vertexmultiplicities (_maptree (last ∘ deconstructsector , f, map (Returns (1 ), f. vertices)))
6969 vertices₁ = map ((μ, n) -> div (μ - 1 , n) + 1 , f. vertices, ns)
7070 vertices₂ = map ((μ, n) -> mod (μ - 1 , n) + 1 , f. vertices, ns)
7171 end
72- return _maptree (first ∘ productparts, f, vertices₁), _maptree (last ∘ productparts, f, vertices₂)
72+ return _maptree (first ∘ deconstructsector, f, vertices₁),
73+ _maptree (last ∘ deconstructsector, f, vertices₂)
7374end
74- function _joinparts (:: Type{I} , f₁:: FusionTree , f₂:: FusionTree ) where {I}
75+ function reconstructtree (:: Type{I} , f₁:: FusionTree , f₂:: FusionTree ) where {I}
7576 vertices = if FusionStyle (I) isa GenericFusion && length (f₁) > 1 && ! (FusionStyle (f₂) isa UniqueFusion)
7677 map ((μ, ν, n) -> ν + (μ - 1 ) * n, f₁. vertices, f₂. vertices, _vertexmultiplicities (f₂))
7778 else
7879 f₁. vertices
7980 end
80- join (a, b) = _joinparts (I, a, b)
81+ join (a, b) = reconstructsector (I, a, b)
8182 return fusiontreetype (I, length (f₁))(
8283 map (join, f₁. uncoupled, f₂. uncoupled), join (f₁. coupled, f₂. coupled), f₁. isdual,
8384 map (join, f₁. innerlines, f₂. innerlines), vertices
8889# parts, with the first part running fastest
8990function productblock (:: Type{I} , block₁:: FusionTreeBlock , block₂:: FusionTreeBlock ) where {I}
9091 trees = [
91- (_joinparts (I, f₁, g₁), _joinparts (I, f₂, g₂))
92+ (reconstructtree (I, f₁, g₁), reconstructtree (I, f₂, g₂))
9293 for (f₁, f₂) in fusiontrees (block₁), (g₁, g₂) in fusiontrees (block₂)
9394 ]
9495 return FusionTreeBlock (vec (trees))
@@ -103,11 +104,11 @@ function FusionTreeBlock{I}(
103104 FusionStyle (I) isa UniqueFusion && return fusiontreeblock (I, uncoupled, isdual; sizehint)
104105
105106 # the second part holds the `UniqueFusion` sectors of a mixed product, which are cheaper to construct
106- I₁, I₂ = productpartstypes (I)
107- block₂ = FusionTreeBlock {I₂} (map .(last ∘ productparts , uncoupled), isdual)
107+ I₁, I₂ = deconstructsectortype (I)
108+ block₂ = FusionTreeBlock {I₂} (map .(last ∘ deconstructsector , uncoupled), isdual)
108109 isempty (block₂) && return FusionTreeBlock (Vector {fusiontreetype(I, N₁, N₂)} ())
109110
110- block₁ = FusionTreeBlock {I₁} (map .(first ∘ productparts , uncoupled), isdual)
111+ block₁ = FusionTreeBlock {I₁} (map .(first ∘ deconstructsector , uncoupled), isdual)
111112 return productblock (I, block₁, block₂)
112113end
113114
@@ -117,7 +118,7 @@ function _distincttrees(trees)
117118 return distinct, indexin (trees, distinct)
118119end
119120# the tree pairs of the two parts of a tree pair
120- _partstrees ((f₁, f₂)) = map (tuple, productparts (f₁), productparts (f₂))
121+ _deconstructtrees ((f₁, f₂)) = map (tuple, deconstructtree (f₁), deconstructtree (f₂))
121122
122123# apply `transform` to the block `src`, where every tree pair of a `UniqueFusion` block maps to a
123124# single tree pair
@@ -131,19 +132,19 @@ end
131132function product_transform (transform:: F , :: Type{T} , src:: FusionTreeBlock{I} ) where {F, T, I}
132133 if FusionStyle (I) isa UniqueFusion
133134 return _unique_transform (transform, T, src)
134- elseif FusionStyle (last (productpartstypes (I))) isa UniqueFusion && numind (src) > 0
135+ elseif FusionStyle (last (deconstructsectortype (I))) isa UniqueFusion && numind (src) > 0
135136 # the second part holds the `UniqueFusion` sectors of a mixed product, with a single tree pair
136- (g₁, g₂), coeff = transform (last (_partstrees (first (fusiontrees (src)))))
137- dst₁, U₁ = transform (FusionTreeBlock (map (first ∘ _partstrees , fusiontrees (src))))
137+ (g₁, g₂), coeff = transform (last (_deconstructtrees (first (fusiontrees (src)))))
138+ dst₁, U₁ = transform (FusionTreeBlock (map (first ∘ _deconstructtrees , fusiontrees (src))))
138139 dst = FusionTreeBlock (
139- map (((f₁, f₂),) -> (_joinparts (I, f₁, g₁), _joinparts (I, f₂, g₂)), fusiontrees (dst₁))
140+ map (((f₁, f₂),) -> (reconstructtree (I, f₁, g₁), reconstructtree (I, f₂, g₂)), fusiontrees (dst₁))
140141 )
141142 U = Matrix {T} (undef, size (U₁))
142143 U .= coeff .* U₁
143144 return dst => U
144145 end
145- src₁, cols₁ = _distincttrees (map (first ∘ _partstrees , fusiontrees (src)))
146- src₂, cols₂ = _distincttrees (map (last ∘ _partstrees , fusiontrees (src)))
146+ src₁, cols₁ = _distincttrees (map (first ∘ _deconstructtrees , fusiontrees (src)))
147+ src₂, cols₂ = _distincttrees (map (last ∘ _deconstructtrees , fusiontrees (src)))
147148 dst₁, U₁ = _unique_transform (transform, T, FusionTreeBlock (src₁))
148149 dst₂, U₂ = _unique_transform (transform, T, FusionTreeBlock (src₂))
149150
0 commit comments