Anders and Briegel in Python
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

87 行
2.5KB

  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. # Aliases
  40. identity = by_name["identity"]
  41. hadamard = by_name["hadamard"]
  42. px = by_name["px"]
  43. py = by_name["py"]
  44. pz = by_name["pz"]
  45. msqx_h = by_name["msqx_h"]
  46. sqz_h = by_name["sqz_h"]
  47. def conjugate(operator, unitary):
  48. """ Returns transform * vop * transform^dagger and a phase in {+1, -1} """
  49. return measurement_table[operator, unitary]
  50. def use_old_cz():
  51. """ Use the CZ lookup table from A&B's code, rather than our own. Useful for testing. """
  52. global cz_table
  53. from .anders_cz import cz_table
  54. def get_name(i):
  55. """ Get the name of this clifford """
  56. return "IXYZ"[i & 0x03] + "ABCDEF"[i / 4]
  57. def human_name(i):
  58. """ Get the human-readable name of this clifford - slow """
  59. choices = sorted((key for key, value in list(by_name.items()) if value == i), key=len)
  60. return choices[-1]
  61. def is_diagonal(v):
  62. """ Checks if a VOP is diagonal or not """
  63. return v in {0, 3, 5, 6}
  64. if __name__ == '__main__':
  65. from itertools import groupby
  66. for i in range(24):
  67. members = [key for key, value in list(by_name.items()) if value == i and str(key)!=str(i)]
  68. members = sorted(members, key=len)
  69. print("* {}: {}".format(i, ", ".join(members)))