From cf496222b411121882d195d03a1b41bd40428037 Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Mon, 18 Mar 2024 23:03:11 +0100 Subject: Add back diff (was missing) --- mdpoly/expressions.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/mdpoly/expressions.py b/mdpoly/expressions.py index 6d855a3..9fa07f2 100644 --- a/mdpoly/expressions.py +++ b/mdpoly/expressions.py @@ -296,3 +296,22 @@ class WithOps: def __rtruediv__(self, other: Any) -> Self: raise NotImplementedError + + # --- More operations --- + + @wrap_result + def diff(self, with_respect_to: WithOps) -> Expr: + with self as expr, with_respect_to as wrt: + if not isinstance(wrt, Var): + raise AlgebraicError( + f"Cannot differentate {str(self.expr)} with respect to " + f"{str(wrt)}. We can only differentiate with respect to " + f"variables (type {Var}).") + + # TODO: implement vector derivatives + return PolyPartialDiff(expr, wrt=wrt) + + + @wrap_result + def integrate(self, with_respect_to: WithOps) -> Expr: + raise NotImplementedError -- cgit v1.2.1