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.

78 lines
2.4KB

  1. # -*- coding: utf-8 -*-
  2. """
  3. This module handles operations on the Clifford group. It makes extensive use of the lookup tables in ``abp.tables``.
  4. The code to generate those tables is included in this distribution as ``abp/build_tables.py``
  5. This package emumerates and labels the single-qubit Clifford group, and provides methods for matrix multiplication and conjugation.
  6. It also includes the look-up table for the CZ gate.
  7. There are 24 members of the single-qubit Clifford group. You can refer to some of them by multiple names.
  8. The complete set of aliases for single-qubit Cliffords is as follows:
  9. ======= =========================
  10. Index Aliases
  11. ======= =========================
  12. 0 ``IA, identity, identity_h``
  13. 1 ``XA, px, px_h``
  14. 2 ``YA, py, py_h``
  15. 3 ``ZA, pz, pz_h``
  16. 4 ``IB``
  17. 5 ``XB, sqz, msqz_h, phase_h``
  18. 6 ``YB, msqz, sqz_h, phase``
  19. 7 ``ZB``
  20. 8 ``IC``
  21. 9 ``XC, msqy, sqy_h``
  22. 10 ``YC, hadamard, hadamard_h``
  23. 11 ``ZC, sqy, msqy_h``
  24. 12 ``ID``
  25. 13 ``XD``
  26. 14 ``YD, sqx, msqx_h``
  27. 15 ``ZD, msqx, sqx_h``
  28. 16 ``IE``
  29. 17 ``XE``
  30. 18 ``YE``
  31. 19 ``ZE``
  32. 20 ``IF``
  33. 21 ``XF``
  34. 22 ``YF``
  35. 23 ``ZF``
  36. ======= =========================
  37. """
  38. from tables import *
  39. def conjugate(operator, unitary):
  40. """ Returns transform * vop * transform^dagger and a phase in {+1, -1} """
  41. return measurement_table[operator, unitary]
  42. def use_old_cz():
  43. """ Use the CZ lookup table from A&B's code, rather than our own. Useful for testing. """
  44. global cz_table
  45. from anders_cz import cz_table
  46. def get_name(i):
  47. """ Get the name of this clifford """
  48. return "IXYZ"[i & 0x03] + "ABCDEF"[i / 4]
  49. def human_name(i):
  50. """ Get the human-readable name of this clifford - slow """
  51. choices = sorted((key for key, value in by_name.items() if value == i), key=len)
  52. return choices[-1]
  53. def is_diagonal(v):
  54. """ Checks if a VOP is diagonal or not """
  55. return v in {0, 3, 5, 6}
  56. if __name__ == '__main__':
  57. from itertools import groupby
  58. for i in range(24):
  59. members = [key for key, value in by_name.items() if value == i and str(key)!=str(i)]
  60. members = sorted(members, key=len)
  61. print "* {}: {}".format(i, ", ".join(members))