Skip to content

Commit c0dfa9f

Browse files
Micro-optimization
1 parent ada2a19 commit c0dfa9f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

pyqrackising/maxcut_tfim_util.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,9 +280,10 @@ def convert_bool_to_uint(samples):
280280
def compute_energy(sample, G_m, n_qubits):
281281
energy = 0
282282
for u in range(n_qubits):
283+
u_bit = sample[u]
283284
for v in range(u + 1, n_qubits):
284285
val = G_m[u, v]
285-
energy += val if sample[u] == sample[v] else -val
286+
energy += val if u_bit == sample[v] else -val
286287

287288
return -energy
288289

0 commit comments

Comments
 (0)