Skip to content

Commit

Permalink
Fix braidingtensors not added to searchable tensors
Browse files Browse the repository at this point in the history
  • Loading branch information
lkdvos committed Nov 29, 2023
1 parent 04eb6b7 commit 6e49c93
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/planar/preprocessors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ _add_adjoint(ex) = Expr(TO.prime, ex)

# used by `@planar`: realize explicit braiding tensors
function _construct_braidingtensors(ex::Expr)
# create a list of all tensors
if TO.isdefinition(ex) || TO.isassignment(ex)
lhs, rhs = TO.getlhs(ex), TO.getrhs(ex)
if TO.istensorexpr(rhs)
Expand Down Expand Up @@ -103,12 +104,10 @@ function _construct_braidingtensors(ex::Expr)
end

# loop over the braiding tensors and try to figure out the correct spaces
unresolved = Any[] # list of indices that we couldn't yet figure out
ischanged = true
pre = Expr(:block)
while ischanged
ischanged = false
unresolved = Any[]
for (t, construct_expr) in translatebraidings
obj, leftind, rightind = TO.decomposetensor(t)
length(leftind) == length(rightind) == 2 ||
Expand All @@ -129,7 +128,6 @@ function _construct_braidingtensors(ex::Expr)
elseif !isnothing(obj_and_pos1b)
V_i1b = Expr(TO.prime, Expr(:call, :space, obj_and_pos1b...))
else
push!(unresolved, (i1a, i1b))
continue
end

Expand All @@ -141,7 +139,6 @@ function _construct_braidingtensors(ex::Expr)
elseif !isnothing(obj_and_pos2b)
V_i2b = Expr(TO.prime, Expr(:call, :space, obj_and_pos2b...))
else
push!(unresolved, (i2a, i2b))
continue
end

Expand All @@ -151,21 +148,24 @@ function _construct_braidingtensors(ex::Expr)
s = gensym()
push!(pre.args, :(@notensor $s = $construct_expr))

# and insert into tensor expression
# and insert into tensor expression and tensorlist
ex = TO.replacetensorobjects(ex) do o, l, r
if o == obj && l == leftind && r == rightind
return obj == ? s : Expr(TO.prime, s)
else
return o
end
end
push!(list, Expr(:typed_vcat, s, Expr(:tuple, leftind...),
Expr(:tuple, rightind...)))

delete!(translatebraidings, t)
ischanged = true
end
end

@assert isempty(unresolved) "could not figure out all spaces"
@assert isempty(translatebraidings) "could not figure out all spaces \n $ex"

return Expr(:block, pre, ex)
end
_construct_braidingtensors(x) = x
Expand Down

0 comments on commit 6e49c93

Please sign in to comment.