Anders and Briegel in Python
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

30 satır
678B

  1. from abp.graphstate import GraphState
  2. from abp.qi import CircuitModel
  3. from abp import clifford
  4. import numpy as np
  5. import random
  6. def multi_qubit_test():
  7. """ A multi qubit test """
  8. n = 6
  9. g = GraphState(range(n))
  10. c = CircuitModel(n)
  11. for i in range(n):
  12. g.act_hadamard(i)
  13. c.act_hadamard(i)
  14. assert np.allclose(g.to_state_vector().state, c.state)
  15. for i in range(100):
  16. a, b = np.random.randint(0, n-1, 2)
  17. if a != b:
  18. g.act_cz(a, b)
  19. c.act_cz(a, b)
  20. s1 = clifford.normalize_global_phase(g.to_state_vector().state)
  21. s2 = clifford.normalize_global_phase(c.state)
  22. assert np.allclose(s1, s2)