aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNao Pross <np@0hm.ch>2024-03-18 23:03:11 +0100
committerNao Pross <np@0hm.ch>2024-03-18 23:03:11 +0100
commitcf496222b411121882d195d03a1b41bd40428037 (patch)
treeb0e72b8f11dddd650cc919a76e0e14afb0e67b47
parentAllow extensions, see for example mdpoly.test.TestExtension (diff)
downloadmdpoly-cf496222b411121882d195d03a1b41bd40428037.tar.gz
mdpoly-cf496222b411121882d195d03a1b41bd40428037.zip
Add back diff (was missing)
Diffstat (limited to '')
-rw-r--r--mdpoly/expressions.py19
1 files changed, 19 insertions, 0 deletions
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