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.

40 lines
1.1KB

  1. from numpy import *
  2. # Some two-qubit matrices
  3. i = matrix(eye(2, dtype=complex))
  4. px = matrix([[0, 1], [1, 0]], dtype=complex)
  5. py = matrix([[0, -1j], [1j, 0]], dtype=complex)
  6. pz = matrix([[1, 0], [0, -1]], dtype=complex)
  7. h = matrix([[1, 1], [1, -1]], dtype=complex) / sqrt(2)
  8. p = matrix([[1, 0], [0, 1j]], dtype=complex)
  9. paulis = (px, py, pz)
  10. def identify_pauli(m):
  11. """ Given a signed Pauli matrix, name it. """
  12. for sign in (+1, -1):
  13. for pauli_label, pauli in zip("xyz", paulis):
  14. if allclose(sign * pauli, m):
  15. return sign, pauli_label
  16. def get_action(u):
  17. """ What does this unitary operator do to the Paulis? """
  18. return [identify_pauli(u * p * u.H) for p in paulis]
  19. def format_action(action):
  20. return "".join("{}{}".format("+" if s>=0 else "-", p) for s, p in action)
  21. #print get_action(i)
  22. #print get_action(px)
  23. #print get_action(py)
  24. #print get_action(pz)
  25. permuters =
  26. print format_action(get_action(i))
  27. print format_action(get_action(h*p*h*pz))
  28. print format_action(get_action(p*h*p*h))
  29. print format_action(get_action(px*p))
  30. print format_action(get_action(p*h))
  31. print format_action(get_action(p*p*h*pz))