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.

50 lines
1.1KB

  1. from abp import GraphState, clifford
  2. from anders_briegel import graphsim
  3. import numpy as np
  4. def clean_random_state(N=10):
  5. """ A state to test on """
  6. a = GraphState(range(N))
  7. b = graphsim.GraphRegister(N)
  8. clifford.use_old_cz()
  9. for i in range(N):
  10. a.act_hadamard(i)
  11. b.hadamard(i)
  12. for i in range(10):
  13. j, k= np.random.choice(range(N), 2, replace=False)
  14. a.act_cz(j, k)
  15. b.cphase(j, k)
  16. return a, b
  17. def messy_random_state(N=10):
  18. a, b = clean_random_state(N)
  19. for i in range(10):
  20. j = np.random.choice(range(N))
  21. k = np.random.choice(range(24))
  22. a.act_local_rotation(j, k)
  23. b.local_op(j, graphsim.LocCliffOp(k))
  24. for i in range(10):
  25. j, k= np.random.choice(range(N), 2, replace=False)
  26. a.act_cz(j, k)
  27. b.cphase(j, k)
  28. return a, b
  29. def bell():
  30. a = GraphState(range(2))
  31. b = graphsim.GraphRegister(2)
  32. a.act_hadamard(0); a.act_hadamard(1);
  33. b.hadamard(0); b.hadamard(1);
  34. a.act_cz(0,1)
  35. b.cphase(0,1)
  36. return a, b
  37. def onequbit():
  38. a = GraphState(range(1))
  39. b = graphsim.GraphRegister(1)
  40. return a, b