Anders and Briegel in Python
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

test_cphase_table.py 784B

123456789101112131415161718192021222324252627
  1. import numpy as np
  2. from abp import clifford, qi, build_tables
  3. import itertools as it
  4. def test_cz_table():
  5. """ Does the CZ code work good? """
  6. state_table = build_tables.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)