Return a set of expressions used as atoms in polynomial self.
(self)
| 743 | return found |
| 744 | |
| 745 | def polynomial_atoms(self): |
| 746 | """Return a set of expressions used as atoms in polynomial self. |
| 747 | """ |
| 748 | found = set() |
| 749 | |
| 750 | def visit(expr, found=found): |
| 751 | if expr.op is Op.FACTORS: |
| 752 | for b in expr.data: |
| 753 | b.traverse(visit) |
| 754 | return expr |
| 755 | if expr.op in (Op.TERMS, Op.COMPLEX): |
| 756 | return |
| 757 | if expr.op is Op.APPLY and isinstance(expr.data[0], ArithOp): |
| 758 | if expr.data[0] is ArithOp.POW: |
| 759 | expr.data[1][0].traverse(visit) |
| 760 | return expr |
| 761 | return |
| 762 | if expr.op in (Op.INTEGER, Op.REAL): |
| 763 | return expr |
| 764 | |
| 765 | found.add(expr) |
| 766 | |
| 767 | if expr.op in (Op.INDEXING, Op.APPLY): |
| 768 | return expr |
| 769 | |
| 770 | self.traverse(visit) |
| 771 | |
| 772 | return found |
| 773 | |
| 774 | def linear_solve(self, symbol): |
| 775 | """Return a, b such that a * symbol + b == self. |