Anders and Briegel in Python
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

test_cphase_against_anders.py 917B

123456789101112131415161718192021222324252627282930
  1. import json
  2. import numpy as np
  3. import sys
  4. import os
  5. import itertools as it
  6. from string import maketrans
  7. from abp import clifford, qi, anders_cz, build_tables
  8. def test_cz_table():
  9. """ Does our clifford code work with anders & briegel's table? """
  10. state_table = build_tables.get_state_table(clifford.unitaries)
  11. ab_cz_table = anders_cz.cz_table
  12. rows = it.product([0, 1], it.combinations_with_replacement(range(24), 2))
  13. for bond, (c1, c2) in rows:
  14. # Pick the input state
  15. input_state = state_table[bond, c1, c2]
  16. # Go and compute the output
  17. computed_output = np.dot(qi.cz, input_state)
  18. computed_output = qi.normalize_global_phase(computed_output)
  19. # Now look up the answer in the table
  20. bondp, c1p, c2p = ab_cz_table[bond, c1, c2]
  21. table_output = state_table[bondp, c1p, c2p]
  22. assert np.allclose(computed_output, table_output)