Skip to content

Commit 49f71d5

Browse files
committed
More ctor fussiness
1 parent d5880f5 commit 49f71d5

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

src/planar/preprocessors.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ function _construct_braidingtensors!(ex, preargs, indexmap, non_braiding) # ex i
184184
if foundV1 && foundV2
185185
s = gensym()
186186
storageex = Expr(:call, GlobalRef(TensorKit, :promote_storagetype), non_braiding...)
187-
constructex = Expr(:call, GlobalRef(TensorKit, :BraidingTensor), V1, V2, storageex)
187+
constructex = Expr(:call, GlobalRef(TensorKit, :BraidingTensor), storageex, V1, V2)
188188
push!(preargs, Expr(:(=), s, constructex))
189189
obj = _is_adjoint(obj) ? _add_adjoint(s) : s
190190
success = true

src/tensors/braidingtensor.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,23 @@ 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)
5555
end
56+
# 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}
58+
T = eltype(TorA)
59+
TA = storagetype(TorA)
60+
return BraidingTensor{T, S, TA}(V1, V2, adjoint)
61+
end
62+
function BraidingTensor(TorA::Type, V1::IndexSpace, V2::IndexSpace, adjoint::Bool = false)
63+
return BraidingTensor(TorA, promote(V1, V2)..., adjoint)
64+
end
65+
function BraidingTensor(TorA::Type, V::HomSpace, adjoint::Bool = false)
66+
domain(V) == reverse(codomain(V)) ||
67+
throw(SpaceMismatch("Cannot define a braiding on $V"))
68+
T = eltype(TorA)
69+
S = spacetype(V[2])
70+
TA = storagetype(TorA)
71+
return BraidingTensor{T, S, TA}(V[2], V[1], adjoint)
72+
end
5673
function Base.adjoint(b::BraidingTensor{T, S, A}) where {T, S, A}
5774
return BraidingTensor{T, S, A}(b.V1, b.V2, !b.adjoint)
5875
end

0 commit comments

Comments
 (0)