Anders and Briegel in Python
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

31 lignes
917B

  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)