Anders and Briegel in Python
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

před 8 roky
před 8 roky
před 8 roky
před 8 roky
před 8 roky
před 8 roky
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. import numpy as np
  13. from qi import *
  14. from tqdm import tqdm
  15. import cPickle,os
  16. def find_up_to_phase(u):
  17. """ Find the index of a given u within a list of unitaries, up to a global phase """
  18. global unitaries
  19. for i, t in enumerate(unitaries):
  20. for phase in range(8):
  21. if np.allclose(t, np.exp(1j*phase*np.pi/4.)*u):
  22. return i, phase
  23. raise IndexError
  24. def construct_tables():
  25. """ Constructs multiplication and conjugation tables """
  26. conjugation_table = [find_up_to_phase(u.H)[0] for i, u in enumerate(unitaries)]
  27. times_table = [[find_up_to_phase(u*v)[0] for v in unitaries]
  28. for u in tqdm(unitaries, "Building times-table")]
  29. with open("tables.pkl", "w") as f:
  30. cPickle.dump((conjugation_table, times_table), f)
  31. permutations = (id, ha, ph, ha*ph, ha*ph*ha, ha*ph*ha*ph)
  32. signs = (id, px, py, pz)
  33. unitaries = [p*s for p in permutations for s in signs]
  34. # Build / reload lookup tables
  35. if not os.path.exists("tables.pkl"):
  36. construct_tables()
  37. with open("tables.pkl") as f:
  38. conjugation_table, times_table = cPickle.load(f)