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