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.

30 lines
552B

  1. import chp
  2. from abp import qi
  3. import numpy as np
  4. n = 10
  5. def get_chp_state():
  6. """ Convert CHP to CircuitModel """
  7. output = qi.CircuitModel(n)
  8. ket = chp.get_ket()
  9. nonzero = np.sqrt(len(ket))
  10. for key, phase in ket.items():
  11. output.state[key] = np.exp(1j*phase*np.pi/2)/nonzero
  12. return output
  13. def test1():
  14. chp.init(5)
  15. chp.act_hadamard(0)
  16. chp.act_cnot(0, 1)
  17. yy = qi.CircuitModel(n)
  18. yy.act_hadamard(0)
  19. yy.act_hadamard(1)
  20. yy.act_cz(0, 1)
  21. yy.act_hadamard(1)
  22. assert yy == get_chp_state()