Anders and Briegel in Python
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

28 行
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)