def __mul__(self, other): """The product of two expressions. """ # Cannot multiply two non-constant expressions. if not self.is_constant() and \ not other.is_constant(): raise TypeError("Cannot multiply two non-constants.") # The constant term must always be on the left. elif not self.is_constant(): # If other is a scalar, simply move it left. if other.is_scalar(): return types.mul_expr()(other, self) else: return (other.T * self.T).T else: return types.mul_expr()(self, other)
def __mul__(self, other): """The product of two expressions. """ # Cannot multiply two non-constant expressions. if not self.is_constant() and \ not other.is_constant(): # TODO replace with special exception. raise Exception("Cannot multiply two non-constants.") # The constant term must always be on the left. elif not self.is_constant(): return (other.T * self.T).T else: return types.mul_expr()(self, other)
def __mul__(self, other): """The product of two expressions. """ # Cannot multiply two non-constant expressions. if not self.is_constant() and \ not other.is_constant(): raise TypeError("Cannot multiply two non-constants.") # Multiplying by a constant on the right is handled differently # from multiplying by a constant on the left. elif not self.is_constant(): return types.rmul_expr()(self, other) else: return types.mul_expr()(self, other)
def __mul__(self, other): # Cannot multiply two non-constant expressions. if not self.curvature.is_constant() and \ not other.curvature.is_constant(): raise Exception("Cannot multiply two non-constants.") return types.mul_expr()(self, other)