Anders and Briegel in Python
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627
  1. import numpy as np
  2. from abp import clifford, qi
  3. import itertools as it
  4. def test_cz_table():
  5. """ Does the CZ code work good? """
  6. state_table = clifford.get_state_table(clifford.unitaries)
  7. rows = it.product([0, 1], it.combinations_with_replacement(range(24), 2))
  8. for bond, (c1, c2) in rows:
  9. # Pick the input state
  10. input_state = state_table[bond, c1, c2]
  11. # Go and compute the output
  12. computed_output = np.dot(qi.cz, input_state)
  13. computed_output = qi.normalize_global_phase(computed_output)
  14. # Now look up the answer in the table
  15. bondp, c1p, c2p = clifford.cz_table[bond, c1, c2]
  16. table_output = state_table[bondp, c1p, c2p]
  17. assert np.allclose(computed_output, table_output)