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.

43 lines
1.2KB

  1. import qi
  2. import numpy as np
  3. import tables
  4. from tqdm import tqdm
  5. import itertools as it
  6. def get_krontable():
  7. table = np.zeros((24,24,4,4), dtype=complex)
  8. for i, j in it.product(range(24), range(24)):
  9. u1 = tables.unitaries[i]
  10. u2 = tables.unitaries[j]
  11. table[i, j, :, :] = np.kron(u1, u2)
  12. return table
  13. def find(bond, c1, c2, z, krontable):
  14. # Figure out the target state
  15. state = qi.bond if bond else qi.nobond
  16. target = qi.cz * krontable[c1, c2] * state
  17. # Choose the sets to search over
  18. s1 = z if c1 in z else xrange(24)
  19. s2 = z if c2 in z else xrange(24)
  20. for bond, c1p, c2p in it.product([0,1], s1, s2):
  21. state = qi.bond if bond else qi.nobond
  22. trial = krontable[c1p, c2p] * state
  23. for phase in range(8):
  24. if np.allclose(target, np.exp(1j * phase * np.pi / 4.) * trial):
  25. return bond, c1p, c2p
  26. raise IndexError
  27. z = [tables.find(u, tables.unitaries) for u in qi.id, qi.px, qi.pz, qi.ph, qi.ph.H]
  28. krontable = get_krontable()
  29. cz_table = np.zeros((2, 24, 24, 3))
  30. for bond, c1, c2 in tqdm(list(it.product([0,1], range(24), range(24)))):
  31. cz_table[bond, c1, c2] = find(bond, c1, c2, z, krontable)
  32. np.save("cz_table.npy", cz_table)