@@ -53,25 +53,30 @@ function BraidingTensor{T}(V::HomSpace, adjoint::Bool = false) where {T}
5353 throw (SpaceMismatch (" Cannot define a braiding on $V " ))
5454 return BraidingTensor {T} (V[2 ], V[1 ], adjoint)
5555end
56+
57+ function Base. adjoint (b:: BraidingTensor{T, S, A} ) where {T, S, A}
58+ return BraidingTensor {T, S, A} (b. V1, b. V2, ! b. adjoint)
59+ end
60+
5661# these are here to make the preprocessing for `@planar` expressions less painful
57- function BraidingTensor (TorA :: Type , V1 :: S , V2 :: S , adjoint :: Bool = false ) where {S <: IndexSpace }
62+ function braidingtensortype ( :: Type{S} , :: Type{TorA} ) where {S <: IndexSpace , TorA }
5863 T = eltype (TorA)
5964 TA = similarstoragetype (TorA)
60- return BraidingTensor {T, S, TA} (V1, V2, adjoint)
65+ return BraidingTensor{T, S, TA}
6166end
62- function BraidingTensor (TorA:: Type , V1:: IndexSpace , V2:: IndexSpace , adjoint:: Bool = false )
63- return BraidingTensor (TorA, promote (V1, V2)... , adjoint)
67+ braidingtensortype (V:: S , :: Type{TorA} ) where {S <: IndexSpace , TorA} = braidingtensortype (S, TorA)
68+ braidingtensortype (V1:: S , V2:: S , :: Type{TorA} ) where {S <: IndexSpace , TorA} = braidingtensortype (S, TorA)
69+ function braidingtensortype (V1:: IndexSpace , V2:: IndexSpace , :: Type{TorA} ) where {TorA}
70+ S = promote (V1, V2)
71+ return braidingtensortype (S... , TorA)
6472end
65- function BraidingTensor (TorA :: Type , V:: HomSpace , adjoint :: Bool = false )
73+ function braidingtensortype ( V:: HomSpace , :: Type{TorA} ) where {TorA}
6674 domain (V) == reverse (codomain (V)) ||
6775 throw (SpaceMismatch (" Cannot define a braiding on $V " ))
6876 T = eltype (TorA)
6977 S = spacetype (V[2 ])
70- TA = storagetype (TorA)
71- return BraidingTensor {T, S, TA} (V[2 ], V[1 ], adjoint)
72- end
73- function Base. adjoint (b:: BraidingTensor{T, S, A} ) where {T, S, A}
74- return BraidingTensor {T, S, A} (b. V1, b. V2, ! b. adjoint)
78+ TA = similarstoragetype (TorA)
79+ return braidingtensortype (S, TA)
7580end
7681
7782storagetype (:: Type{BraidingTensor{T, S, A}} ) where {T, S, A} = A
0 commit comments