test_shor.py 666 B

123456789101112131415161718192021
  1. from sympy.testing.pytest import XFAIL
  2. from sympy.physics.quantum.qapply import qapply
  3. from sympy.physics.quantum.qubit import Qubit
  4. from sympy.physics.quantum.shor import CMod, getr
  5. @XFAIL
  6. def test_CMod():
  7. assert qapply(CMod(4, 2, 2)*Qubit(0, 0, 1, 0, 0, 0, 0, 0)) == \
  8. Qubit(0, 0, 1, 0, 0, 0, 0, 0)
  9. assert qapply(CMod(5, 5, 7)*Qubit(0, 0, 1, 0, 0, 0, 0, 0, 0, 0)) == \
  10. Qubit(0, 0, 1, 0, 0, 0, 0, 0, 1, 0)
  11. assert qapply(CMod(3, 2, 3)*Qubit(0, 1, 0, 0, 0, 0)) == \
  12. Qubit(0, 1, 0, 0, 0, 1)
  13. def test_continued_frac():
  14. assert getr(513, 1024, 10) == 2
  15. assert getr(169, 1024, 11) == 6
  16. assert getr(314, 4096, 16) == 13