Skip to content

Commit cae170a

Browse files
lkdvosJutho
authored andcommitted
Fix braidingtensor block implementation
1 parent 4078f30 commit cae170a

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/tensors/braidingtensor.jl

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ end
8181
d = (dims(V2 V1, f₁.uncoupled)..., dims(V1 V2, f₂.uncoupled)...)
8282
n1 = d[1] * d[2]
8383
n2 = d[3] * d[4]
84-
data = fill!(storagetype(b)(undef, (n1, n2)), zero(scalartype(b)))
84+
data = storagetype(b)(undef, (n1, n2))
85+
fill!(data, zero(eltype(b)))
8586
a1, a2 = f₂.uncoupled
8687
if f₁.uncoupled == (a2, a1)
8788
braiddict = artin_braid(f₂, 1; inv=b.adjoint)
@@ -138,20 +139,22 @@ function block(b::BraidingTensor, s::Sector)
138139

139140
length(data) == 0 && return data # s ∉ blocksectors(b)
140141

141-
data = fill!(data, zero(scalartype(b)))
142+
data = fill!(data, zero(eltype(b)))
142143

143144
V1, V2 = domain(b)
144145
if sectortype(b) === Trivial
145146
d1, d2 = dim(V1), dim(V2)
146147
subblock = sreshape(StridedView(data), (d1, d2, d2, d1))
147148
@inbounds for i in axes(subblock, 1), j in axes(subblock, 2)
148-
subblock[i, j, j, i] = one(scalartype(b))
149+
subblock[i, j, j, i] = one(eltype(b))
149150
end
150151
return data
151152
end
152153

153154
structure = fusionblockstructure(b)
154-
for ((f1, f2), (sz, str, _)) in
155+
base_offset = first(structure.blockstructure[s][2]) - 1
156+
157+
for ((f1, f2), (sz, str, off)) in
155158
zip(structure.fusiontreelist, structure.fusiontreestructure)
156159
if (f1.uncoupled != reverse(f2.uncoupled)) || !(f1.coupled == f2.coupled == s)
157160
continue
@@ -161,8 +164,8 @@ function block(b::BraidingTensor, s::Sector)
161164
haskey(braiddict, f1) || continue
162165
r = braiddict[f1]
163166

164-
# discard offset because single block
165-
subblock = StridedView(data, sz, str)
167+
# change offset to account for single block
168+
subblock = StridedView(data, sz, str, off - base_offset)
166169
@inbounds for i in axes(subblock, 1), j in axes(subblock, 2)
167170
subblock[i, j, j, i] = r
168171
end

0 commit comments

Comments
 (0)