Advertisement
Guest User

Untitled

a guest
Jul 27th, 2013
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. >>> d1 = BaseDyadic(a, b)
  2. >>> 3 * d1
  3. 3*(a|b)
  4. >>> type(_)
  5. <class '__main__.DyadicMul'>
  6. >>> d1 + c * BaseDyadic(m, n)
  7. c*(m|n) + (a|b)
  8. >>> type(_)
  9. <class '__main__.DyadicAdd'>
  10. >>> type(d1 + d1)
  11. <class '__main__.DyadicMul'>
  12. >>> d2 = 4 * BaseDyadic(a, b) + 5 * BaseDyadic(m, n)
  13. >>> d2.expand()
  14. 4*(a|b) + 5*(m|n)
  15. >>> type(_)
  16. <class '__main__.DyadicAdd'>
  17. >>> d2 * 0
  18. 0
  19. >>> type(_)
  20. <class 'sympy.core.numbers.Zero'>
  21. >>> 3 * d2
  22. 12*(a|b) + 15*(m|n)
  23. >>> d2.factor()
  24.  
  25. Traceback (most recent call last):
  26. File "<pyshell#126>", line 1, in <module>
  27. d2.factor()
  28. File "/home/sachin/dyadic.py", line 57, in factor
  29. raise TypeError("Factoring not supported for dyadics")
  30. TypeError: Factoring not supported for dyadics
  31. >>> d2 & V
  32. 4*(b.V)*a + 5*(n.V)*m
  33. >>> d2 * d2
  34.  
  35. Traceback (most recent call last):
  36. File "<pyshell#128>", line 1, in <module>
  37. d2 * d2
  38. File "/home/sachin/pythlibs/sympy/core/decorators.py", line 115, in binary_op_wrapper
  39. return func(self, other)
  40. File "/home/sachin/dyadic.py", line 39, in __mul__
  41. return DyadicMul(self, other)
  42. File "/home/sachin/dyadic.py", line 147, in __new__
  43. raise ValueError("Cannot multiple two dyadics")
  44. ValueError: Cannot multiple two dyadics
  45. >>> d2 & d2
  46. 16*(b.a)*(a|b) + 20*(b.m)*(a|n) + 20*(n.a)*(m|b) + 25*(n.m)*(m|n)
  47. >>> d3 = 5 * BaseDyadic(a, b)
  48. >>> d3/5
  49. (a|b)
  50. >>> type(_)
  51. <class '__main__.BaseDyadic'>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement