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.

45 lines
1.1KB

  1. from numpy import *
  2. px = matrix([[0, 1], [1, 0]], dtype=complex)
  3. py = matrix([[0, -1j], [1j, 0]], dtype=complex)
  4. pz = matrix([[1, 0], [0, -1]], dtype=complex)
  5. i = matrix(eye(2, dtype=complex))
  6. h = matrix([[1, 1], [1, -1]], dtype=complex) / sqrt(2)
  7. p = matrix([[1, 0], [0, 1j]], dtype=complex)
  8. s_set = [i, p, p*p, p*p*p]
  9. c_set = [i, h, h*p, h*p*p, h*p*p*p, h*p*p*h]
  10. def identify_pauli(m):
  11. for sign in [+1, -1]:
  12. for label, pauli in zip("XYZ", (px, py, pz)):
  13. if allclose(sign*pauli, m):
  14. return "{}{}".format("+" if sign>0 else "-", label)
  15. for p in px, py, pz:
  16. for sign in [+1, -1]:
  17. print identify_pauli(sign*p)
  18. print py
  19. print h*px*h.H
  20. print h*py*h.H
  21. print h*pz*h.H
  22. #names = []
  23. #matrices = []
  24. #for s, s_name in zip(s_set, s_names):
  25. #for c, c_name in zip(c_set, c_names):
  26. #names.append(s_name+c_name)
  27. #matrices.append(s*c)
  28. #print " ".join(names)
  29. #print len(names)
  30. #for m in matrices:
  31. # print (m/abs(amax(m))).round(0).reshape(4)
  32. #print average(abs(array((m/abs(amax(m))).round(0).reshape(4).tolist()[0])))