Anders and Briegel in Python
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

36 lignes
790B

  1. from abp import GraphState, clifford
  2. from abp.fancy import GraphState as Fancy
  3. from anders_briegel import graphsim
  4. import random
  5. import time
  6. import numpy as np
  7. from tqdm import tqdm
  8. REPEATS = 100000
  9. def assert_equal(a, b, debug=""):
  10. assert a.to_json() == b.to_json(), "\n\n" + debug + "\n\n" + str(a.to_json()) + "\n\n" + str(b.to_json())
  11. def test_cz_hadamard(N=9):
  12. """ Test CZs and Hadamards at random """
  13. clifford.use_old_cz()
  14. a = graphsim.GraphRegister(N)
  15. b = Fancy(range(N))
  16. while a.to_json() == b.to_json():
  17. if random.random()>0.5:
  18. j = random.randint(0, N-1)
  19. a.hadamard(j)
  20. b.act_hadamard(j)
  21. else:
  22. q = random.randint(0, N-2)
  23. a.cphase(q, q+1)
  24. b.act_cz(q, q+1)