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.

35 lines
959B

  1. # -*- coding: utf-8 -*-
  2. """
  3. This program generates and caches lookup tables, and handles the Clifford group.
  4. It provides tables for Clifford group multiplication and conjugation,
  5. as well as CZ and decompositions of the 2x2 Cliffords.
  6. """
  7. from tables import *
  8. def conjugate(operator, unitary):
  9. """ Returns transform * vop * transform^dagger and a phase in {+1, -1} """
  10. return measurement_table[operator, unitary]
  11. def use_old_cz():
  12. """ Use the CZ table from A&B's code """
  13. global cz_table
  14. from anders_cz import cz_table
  15. def get_name(i):
  16. """ Get the name of this clifford """
  17. return "IXYZ"[i & 0x03] + "ABCDEF"[i / 4]
  18. def human_name(i):
  19. """ Get the human-readable name of this clifford - slow """
  20. choices = sorted((key for key, value in by_name.items() if value == i), key=len)
  21. return choices[-1]
  22. def is_diagonal(v):
  23. """ TODO: remove this. Checks if a VOP is diagonal or not """
  24. return v in {0, 3, 5, 6}