Anders and Briegel in Python
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
766B

  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)