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.

54 lines
1.9KB

  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. """
  4. Generates and enumerates the 24 elements of the local Clifford group
  5. Following the prescription of Anders (thesis pg. 26):
  6. > Table 2.1: The 24 elements of the local Clifford group. The row index (here called the “sign symbol”) shows how the operator
  7. > U permutes the Pauli operators σ = X, Y, Z under the conjugation σ = ±UσU† . The column index (the “permutation
  8. > symbol”) indicates the sign obtained under the conjugation: For operators U in the I column it is the sign of the permutation
  9. > (indicated on the left). For elements in the X, Y and Z columns, it is this sign only if the conjugated Pauli operator is the one
  10. > indicated by the column header and the opposite sign otherwise.
  11. """
  12. from numpy import *
  13. # Some two-qubit matrices
  14. i = matrix(eye(2, dtype=complex))
  15. px = matrix([[0, 1], [1, 0]], dtype=complex)
  16. py = matrix([[0, -1j], [1j, 0]], dtype=complex)
  17. pz = matrix([[1, 0], [0, -1]], dtype=complex)
  18. h = matrix([[1, 1], [1, -1]], dtype=complex) / sqrt(2)
  19. p = matrix([[1, 0], [0, 1j]], dtype=complex)
  20. paulis = (px, py, pz)
  21. # More two-qubit matrices
  22. s_rotations = [i, p, p*p, p*p*p]
  23. s_names = ["i", "p", "pp", "ppp"]
  24. c_rotations = [i, h, h*p, h*p*p, h*p*p*p, h*p*p*h]
  25. c_names = ["i", "h", "hp", "hpp", "hppp", "hpph"]
  26. def identify_pauli(m):
  27. """ Given a signed Pauli matrix, name it. """
  28. for sign in [+1, -1]:
  29. for label, pauli in zip("xyz", paulis):
  30. if allclose(sign*pauli, m):
  31. return "{}{}".format("+" if sign>0 else "-", label)
  32. def get_action(u):
  33. """ Get the action of a Pauli matrix on three qubits """
  34. return tuple(identify_pauli(u*p*u.H) for p in paulis)
  35. if __name__ == '__main__':
  36. permutations = ["xyz", "yxz", "zyx", "xzy", "yzx", "zxy"]
  37. #for s, sn in zip(s_rotations, s_names):
  38. #for c, cn in zip(c_rotations, c_names):
  39. #print sn, "\t", cn, "\t", get_action(s*c)