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.

test_local_complementation.py 538B

8 anni fa
123456789101112131415161718192021222324
  1. from abp.fancy import GraphState
  2. from abp import qi
  3. def test_local_comp():
  4. """ Test that local complementation works okay """
  5. psi = GraphState()
  6. psi.add_node(0)
  7. psi.add_node(1)
  8. psi.add_node(2)
  9. psi.add_node(3)
  10. for n in psi.node:
  11. psi.act_hadamard(n)
  12. psi.act_cz(0, 1)
  13. psi.act_cz(0, 3)
  14. psi.act_cz(1, 3)
  15. psi.act_cz(1, 2)
  16. before = psi.copy()
  17. psi.local_complementation(1)
  18. assert before.edgelist() != psi.edgelist()
  19. assert before.to_state_vector() == psi.to_state_vector()