Skip to content

Commit 2586ad7

Browse files
committed
Fix conversion logic for SparseBlockTensorMap
1 parent 5cadd59 commit 2586ad7

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/operators/jordanmpotensor.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,10 @@ function SparseBlockTensorMap(W::JordanMPOTensor)
155155
τ = BraidingTensor{scalartype(W)}(eachspace(W)[1])
156156
W′ = SparseBlockTensorMap{AbstractTensorMap{scalartype(W),spacetype(W),2,2}}(undef_blocks,
157157
space(W))
158-
if size(W, 1) > 1
158+
if size(W, 4) > 1
159159
W′[1, 1, 1, 1] = τ
160160
end
161-
if size(W, 4) > 1
161+
if size(W, 1) > 1
162162
W′[end, 1, 1, end] = τ
163163
end
164164

@@ -174,7 +174,9 @@ function SparseBlockTensorMap(W::JordanMPOTensor)
174174
for (I, v) in nonzero_pairs(W.C)
175175
W′[1, I + Ic] = insertleftunit(v, 1)
176176
end
177-
W′[1, 1, 1, end] = insertrightunit(insertleftunit(only(W.D), 1), 3)
177+
if nonzero_length(W.D) > 0
178+
W′[1, 1, 1, end] = insertrightunit(insertleftunit(only(W.D), 1), 3)
179+
end
178180

179181
return W′
180182
end

0 commit comments

Comments
 (0)