Anders and Briegel in Python
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
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)