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.

dummy.py 1020B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. from abp import GraphState, clifford
  2. from anders_briegel import graphsim
  3. import numpy as np
  4. def random_state(N=10, messy=True):
  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. if not messy: return a, b
  17. for i in range(10):
  18. j = np.random.choice(range(N))
  19. k = np.random.choice(range(24))
  20. a.act_local_rotation(j, k)
  21. b.local_op(j, graphsim.LocCliffOp(k))
  22. for i in range(10):
  23. j, k= np.random.choice(range(N), 2, replace=False)
  24. a.act_cz(j, k)
  25. b.cphase(j, k)
  26. return a, b
  27. def bell():
  28. a = GraphState(range(2))
  29. b = graphsim.GraphRegister(2)
  30. a.act_hadamard(0); a.act_hadamard(1);
  31. b.hadamard(0); b.hadamard(1);
  32. a.act_cz(0,1)
  33. b.cphase(0,1)
  34. return a, b