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.

47 lignes
1.5KB

  1. from abp import clifford, qi
  2. import numpy as np
  3. import itertools as it
  4. def conj_hack(operator, unitary):
  5. """ TODO: make this meaningful / legible """
  6. assert operator in set(xrange(4))
  7. op = clifford.times_table[unitary, operator]
  8. op = clifford.times_table[op, clifford.conjugation_table[unitary]]
  9. is_id_or_operator = (unitary % 4 == 0) or (unitary % 4 == operator)
  10. is_non_pauli = (unitary >= 4) and (unitary <= 15)
  11. phase = ((-1, 1), (1, -1))[is_id_or_operator][is_non_pauli]
  12. if operator == 0:
  13. phase = 1
  14. return op, phase
  15. def conj(operator, unitary):
  16. """ Better """
  17. matrices = ({"x": qi.msqx, "z": qi.sqz}[c] for c in clifford.decompositions[unitary])
  18. unitary = reduce(np.dot, matrices, np.eye(2, dtype=complex))
  19. operator = qi.operators[operator]
  20. new_operator = reduce(np.dot, (unitary, operator, qi.hermitian_conjugate(unitary)))
  21. for i, o in enumerate(qi.operators):
  22. if np.allclose(o, new_operator):
  23. return i, 1
  24. elif np.allclose(o, -new_operator):
  25. return i, -1
  26. raise IndexError
  27. for operator, unitary in it.product(range(4), range(24)):
  28. assert conj(operator, unitary) == conj_hack(operator, unitary)
  29. #new = np.dot(u, np.dot(o, qi.hermitian_conjugate(u)))
  30. #which = clifford.find_clifford(new, clifford.unitaries[:4])
  31. #assert which in xrange(4)
  32. #whichm = [qi.id, qi.px, qi.py, qi.pz][which]
  33. #if np.allclose(new, whichm):
  34. #return which, 1
  35. #elif np.allclose(new, -whichm):
  36. #return which, -1
  37. #else:
  38. #raise IndexError