Anders and Briegel in Python
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

test_against_circuit_model.py 612B

12345678910111213141516171819202122232425262728
  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 = 3
  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. g.act_cz(0, 1)
  16. c.act_cz(0, 1)
  17. g.act_cz(1, 2)
  18. c.act_cz(1, 2)
  19. s1 = clifford.normalize_global_phase(g.to_state_vector().state)
  20. s2 = clifford.normalize_global_phase(c.state)
  21. assert np.allclose(s1, s2)