图片解析应用
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
1.0 KiB

  1. from sympy.holonomic.recurrence import RecurrenceOperators, RecurrenceOperator
  2. from sympy.core.symbol import symbols
  3. from sympy.polys.domains.rationalfield import QQ
  4. def test_RecurrenceOperator():
  5. n = symbols('n', integer=True)
  6. R, Sn = RecurrenceOperators(QQ.old_poly_ring(n), 'Sn')
  7. assert Sn*n == (n + 1)*Sn
  8. assert Sn*n**2 == (n**2+1+2*n)*Sn
  9. assert Sn**2*n**2 == (n**2 + 4*n + 4)*Sn**2
  10. p = (Sn**3*n**2 + Sn*n)**2
  11. q = (n**2 + 3*n + 2)*Sn**2 + (2*n**3 + 19*n**2 + 57*n + 52)*Sn**4 + (n**4 + 18*n**3 + \
  12. 117*n**2 + 324*n + 324)*Sn**6
  13. assert p == q
  14. def test_RecurrenceOperatorEqPoly():
  15. n = symbols('n', integer=True)
  16. R, Sn = RecurrenceOperators(QQ.old_poly_ring(n), 'Sn')
  17. rr = RecurrenceOperator([n**2, 0, 0], R)
  18. rr2 = RecurrenceOperator([n**2, 1, n], R)
  19. assert not rr == rr2
  20. # polynomial comparison issue, see https://github.com/sympy/sympy/pull/15799
  21. # should work once that is solved
  22. # d = rr.listofpoly[0]
  23. # assert rr == d
  24. d2 = rr2.listofpoly[0]
  25. assert not rr2 == d2