Anders and Briegel in Python
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

40 lignes
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))