11# Deligne tensor product of different sectors: ⊠
2- #= ============================================================================ = #
2+ # ------------------------------------------------------------------------------ #
33const SectorTuple = Tuple{Vararg{Sector}}
44
55"""
@@ -79,12 +79,24 @@ _tailsector(x::ProductSector) = ProductSector(Base.tail(x.sectors))
7979function Fsymbol (a:: P , b:: P , c:: P , d:: P , e:: P , f:: P ) where {P<: ProductSector }
8080 heads = map (_firstsector, (a, b, c, d, e, f))
8181 tails = map (_tailsector, (a, b, c, d, e, f))
82- f₁ = Fsymbol (heads... )
83- f₂ = Fsymbol (tails... )
84- if f₁ isa Number || f₂ isa Number
85- f₁ * f₂
82+ F₁ = Fsymbol (heads... )
83+ F₂ = Fsymbol (tails... )
84+ if F₁ isa Number && F₂ isa Number
85+ return F₁ * F₂
86+ elseif F₁ isa Number
87+ a₁, b₁, c₁, d₁, e₁, f₁ = heads
88+ sz₁ = (Nsymbol (a₁, b₁, e₁), Nsymbol (e₁, c₁, d₁), Nsymbol (b₁, c₁, f₁),
89+ Nsymbol (a₁, f₁, d₁))
90+ F₁′ = fill (F₁, sz₁)
91+ return _kron (F₁′, F₂)
92+ elseif F₂ isa Number
93+ a₂, b₂, c₂, d₂, e₂, f₂ = tails
94+ sz₂ = (Nsymbol (a₂, b₂, e₂), Nsymbol (e₂, c₂, d₂), Nsymbol (b₂, c₂, f₂),
95+ Nsymbol (a₂, f₂, d₂))
96+ F₂′ = fill (F₂, sz₂)
97+ return _kron (F₁, F₂′)
8698 else
87- _kron (f ₁, f ₂)
99+ return _kron (F ₁, F ₂)
88100 end
89101end
90102function Fsymbol (a:: P , b:: P , c:: P , d:: P , e:: P ,
95107function Rsymbol (a:: P , b:: P , c:: P ) where {P<: ProductSector }
96108 heads = map (_firstsector, (a, b, c))
97109 tails = map (_tailsector, (a, b, c))
98- r1 = Rsymbol (heads... )
99- r2 = Rsymbol (tails... )
100- if r1 isa Number || r2 isa Number
101- r1 * r2
110+ R₁ = Rsymbol (heads... )
111+ R₂ = Rsymbol (tails... )
112+ if R₁ isa Number && R₂ isa Number
113+ R₁ * R₂
114+ elseif R₁ isa Number
115+ a₁, b₁, c₁ = heads
116+ sz₁ = (Nsymbol (a₁, b₁, c₁), Nsymbol (b₁, a₁, c₁)) # 0 x 0 or 1 x 1
117+ R₁′ = fill (R₁, sz₁)
118+ return _kron (R₁′, R₂)
119+ elseif R₂ isa Number
120+ a₂, b₂, c₂ = tails
121+ sz₂ = (Nsymbol (a₂, b₂, c₂), Nsymbol (b₂, a₂, c₂)) # 0 x 0 or 1 x 1
122+ R₂′ = fill (R₂, sz₂)
123+ return _kron (R₁, R₂′)
102124 else
103- _kron (r1, r2 )
125+ return _kron (R₁, R₂ )
104126 end
105127end
106128function Rsymbol (a:: P , b:: P , c:: P ) where {P<: ProductSector{<:Tuple{Sector}} }
@@ -110,12 +132,22 @@ end
110132function Bsymbol (a:: P , b:: P , c:: P ) where {P<: ProductSector }
111133 heads = map (_firstsector, (a, b, c))
112134 tails = map (_tailsector, (a, b, c))
113- b1 = Bsymbol (heads... )
114- b2 = Bsymbol (tails... )
115- if b1 isa Number || b2 isa Number
116- b1 * b2
135+ B₁ = Bsymbol (heads... )
136+ B₂ = Bsymbol (tails... )
137+ if B₁ isa Number && B₂ isa Number
138+ B₁ * B₂
139+ elseif B₁ isa Number
140+ a₁, b₁, c₁ = heads
141+ sz₁ = (Nsymbol (a₁, b₁, c₁), Nsymbol (c₁, dual (b₁), a₁)) # 0 x 0 or 1 x 1
142+ B₁′ = fill (B₁, sz₁)
143+ return _kron (B₁′, B₂)
144+ elseif B₂ isa Number
145+ a₂, b₂, c₂ = tails
146+ sz₂ = (Nsymbol (a₂, b₂, c₂), Nsymbol (c₂, dual (b₂), a₂)) # 0 x 0 or 1 x 1
147+ B₂′ = fill (B₂, sz₂)
148+ return _kron (B₁, B₂′)
117149 else
118- _kron (b1, b2 )
150+ return _kron (B₁, B₂ )
119151 end
120152end
121153function Bsymbol (a:: P , b:: P , c:: P ) where {P<: ProductSector{<:Tuple{Sector}} }
@@ -125,12 +157,22 @@ end
125157function Asymbol (a:: P , b:: P , c:: P ) where {P<: ProductSector }
126158 heads = map (_firstsector, (a, b, c))
127159 tails = map (_tailsector, (a, b, c))
128- a1 = Asymbol (heads... )
129- a2 = Asymbol (tails... )
130- if a1 isa Number || a2 isa Number
131- a1 * a2
160+ A₁ = Asymbol (heads... )
161+ A₂ = Asymbol (tails... )
162+ if A₁ isa Number && A₂ isa Number
163+ A₁ * A₂
164+ elseif A₁ isa Number
165+ a₁, b₁, c₁ = heads
166+ sz₁ = (Nsymbol (a₁, b₁, c₁), Nsymbol (dual (a₁), c₁, b₁)) # 0 x 0 or 1 x 1
167+ A₁′ = fill (A₁, sz₁)
168+ return _kron (A₁′, A₂)
169+ elseif A₂ isa Number
170+ a₂, b₂, c₂ = tails
171+ sz₂ = (Nsymbol (a₂, b₂, c₂), Nsymbol (dual (a₂), c₂, b₂)) # 0 x 0 or 1 x 1
172+ A₂′ = fill (A₂, sz₂)
173+ return _kron (A₁, A₂′)
132174 else
133- _kron (a1, a2 )
175+ return _kron (A₁, A₂ )
134176 end
135177end
136178function Asymbol (a:: P , b:: P , c:: P ) where {P<: ProductSector{<:Tuple{Sector}} }
0 commit comments