Anders and Briegel in Python
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

31 linhas
899B

  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
  8. def test_cz_table():
  9. """ Does our clifford code work with anders & briegel's table? """
  10. state_table = clifford.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)