Anders and Briegel in Python
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.2KB

  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(N):
  20. a.act_hadamard(i)
  21. b.hadamard(i)
  22. for i in range(N):
  23. j, k= np.random.choice(range(N), 2, replace=False)
  24. a.act_cz(j, k)
  25. b.cphase(j, k)
  26. for i in range(N):
  27. j = np.random.choice(range(N))
  28. k = np.random.choice(range(24))
  29. a.act_local_rotation(j, k)
  30. b.local_op(j, graphsim.LocCliffOp(k))
  31. return a, b
  32. def bell():
  33. a = GraphState(range(2))
  34. b = graphsim.GraphRegister(2)
  35. a.act_hadamard(0); a.act_hadamard(1);
  36. b.hadamard(0); b.hadamard(1);
  37. a.act_cz(0,1)
  38. b.cphase(0,1)
  39. return a, b
  40. def onequbit():
  41. a = GraphState(range(1))
  42. b = graphsim.GraphRegister(1)
  43. return a, b