Skip to content

Commit 8bb9a61

Browse files
Fix zero gate returned by get_gateterm (#300)
1 parent feae2fc commit 8bb9a61

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

src/algorithms/time_evolution/evoltools.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,13 @@ function get_gateterm(gate::LocalOperator, bond::NTuple{2, CartesianIndex{2}})
8585
if length(bonds) == 1
8686
return permute(gate.terms[bonds[1]].second, ((2, 1), (4, 3)))
8787
elseif length(bonds) == 0
88-
# if term not found, return the zero operator
89-
dtype = scalartype(gate.terms[1].second)
90-
V = space(gate.terms[1].second, 1)
91-
return zeros(dtype, V V V V)
88+
# if term not found, return the zero operator on this bond
89+
dtype = scalartype(gate)
90+
r1, c1 = (mod1(bond[1][i], n) for (i, n) in zip(1:2, size(gate)))
91+
r2, c2 = (mod1(bond[2][i], n) for (i, n) in zip(1:2, size(gate)))
92+
V1 = physicalspace(gate)[r1, c1]
93+
V2 = physicalspace(gate)[r2, c2]
94+
return zeros(dtype, V1 V2 V1 V2)
9295
else
9396
error("There are multiple terms in `gate` corresponding to the bond $(bond).")
9497
end

0 commit comments

Comments
 (0)