Skip to content

Commit cdf66fb

Browse files
authored
Small fix for ignored adjoint flag in BraidingTensor (#392)
* fix braiding factor with adjoint * add tests that capture this * use `subblock`
1 parent 0fa5c49 commit cdf66fb

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

src/tensors/braidingtensor.jl

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ function _braiding_factor(f₁, f₂, inv::Bool = false)
9999
return r
100100
end
101101

102-
@inline function Base.getindex(
103-
b::BraidingTensor, f₁::FusionTree{I, 2}, f₂::FusionTree{I, 2}
102+
@inline function subblock(
103+
b::BraidingTensor, (f₁, f₂)::Tuple{FusionTree{I, 2}, FusionTree{I, 2}}
104104
) where {I <: Sector}
105105
I == sectortype(b) || throw(SectorMismatch())
106106
c = f₁.coupled
@@ -126,10 +126,6 @@ end
126126
end
127127
return data
128128
end
129-
@inline function Base.getindex(b::BraidingTensor, ::Nothing, ::Nothing)
130-
sectortype(b) === Trivial || throw(SectorMismatch())
131-
return getindex(b)
132-
end
133129

134130
# efficient copy constructor
135131
Base.copy(b::BraidingTensor) = b
@@ -169,7 +165,7 @@ function block(b::BraidingTensor, s::Sector)
169165

170166
for ((f₁, f₂), (sz, str, off)) in pairs(subblockstructure(space(b)))
171167
(f₁.coupled == f₂.coupled == s) || continue
172-
r = _braiding_factor(f₁, f₂)
168+
r = _braiding_factor(f₁, f₂, b.adjoint)
173169
isnothing(r) && continue
174170
# change offset to account for single block
175171
subblock = StridedView(data, sz, str, off - base_offset)

test/tensors/planar.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,16 @@ using .TestSetup
4040
for (f1, f2) in fusiontrees(t1)
4141
@test t1[f1, f2] t3[f1, f2]
4242
end
43+
44+
t5 = @inferred TensorMap(t2')
45+
t6 = braid(id(storagetype(t2), domain(t2')), ((2, 1), (3, 4)), (4, 3, 2, 1))
46+
@test t5 t6
47+
for (c, b) in blocks(t1')
48+
@test block(t1', c) b block(t5, c)
49+
end
50+
for (f1, f2) in fusiontrees(t1')
51+
@test t1'[f1, f2] t5[f1, f2]
52+
end
4353
end
4454
end
4555

0 commit comments

Comments
 (0)