Skip to content

Commit 15fe8c1

Browse files
Refactor
1 parent 29b70de commit 15fe8c1

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

scripts/tfim_validation.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,10 @@ def main():
391391
bias = bias[::-1]
392392
d_magnetization = -d_magnetization
393393

394+
# Mix in the initial state component.
394395
bias = model * bias + (1 - model) * bias_0
396+
magnetization = model * d_magnetization + (1 - model) * magnetization_0
397+
sqr_magnetization = model * d_sqr_magnetization + (1 - model) * sqr_magnetization_0
395398

396399
# The full 2^n marginal probabilities will be produced in the statistics calculation,
397400
# but notice that the global magnetization value only requires (n+1) dimensions of marginal probability,
@@ -408,10 +411,6 @@ def main():
408411
# Add up the square residuals:
409412
r_squared += result["l2_difference"] ** 2
410413

411-
# Mix in the initial state component.
412-
magnetization = model * d_magnetization + (1 - model) * magnetization_0
413-
sqr_magnetization = model * d_sqr_magnetization + (1 - model) * sqr_magnetization_0
414-
415414
# Calculate the "control-case" magnetization values, from Aer's samples.
416415
c_magnetization, c_sqr_magnetization = 0, 0
417416
for p in range(1 << n_qubits):

0 commit comments

Comments
 (0)