Ejemplo n.º 1
0
 def matches(self, expr, repl_dict={}):
     expr = sympify(expr)
     if self.is_commutative and expr.is_commutative:
         return AssocOp._matches_commutative(self, expr, repl_dict)
     elif self.is_commutative is not expr.is_commutative:
         return None
     c1, nc1 = self.args_cnc()
     c2, nc2 = expr.args_cnc()
     repl_dict = repl_dict.copy()
     if c1:
         if not c2:
             c2 = [1]
         a = Mul(*c1)
         if isinstance(a, AssocOp):
             repl_dict = a._matches_commutative(Mul(*c2), repl_dict)
         else:
             repl_dict = a.matches(Mul(*c2), repl_dict)
     if repl_dict:
         a = Mul(*nc1)
         if isinstance(a, Mul):
             repl_dict = a._matches(Mul(*nc2), repl_dict)
         else:
             repl_dict = a.matches(Mul(*nc2), repl_dict)
     return repl_dict or None
Ejemplo n.º 2
0
 def matches(self, expr, repl_dict={}, old=False):
     return AssocOp._matches_commutative(self, expr, repl_dict, old)
Ejemplo n.º 3
0
 def matches(self, expr, repl_dict={}, old=False):
     return AssocOp._matches_commutative(self, expr, repl_dict, old)