diff options
-rw-r--r-- | mdpoly/expressions.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/mdpoly/expressions.py b/mdpoly/expressions.py index 159769e..8836c52 100644 --- a/mdpoly/expressions.py +++ b/mdpoly/expressions.py @@ -6,9 +6,10 @@ from dataclasses import dataclass from functools import wraps from typing import Type, TypeVar, Iterable, Callable, Sequence, Any, Self, cast -from .abc import Expr, Var, Const, Param +from .abc import Expr, Var, Const, Param, Repr from .index import Shape, MatrixIndex, PolyIndex, PolyVarIndex, Number from .errors import MissingParameters, AlgebraicError +from .representations import SparseRepr from .operations.add import MatAdd, MatSub from .operations.mul import MatElemMul @@ -326,7 +327,18 @@ class WithOps: # TODO: implement vector derivatives return PolyPartialDiff(expr, wrt=wrt) - @wrap_result def integrate(self, with_respect_to: WithOps) -> Expr: raise NotImplementedError + + # -- Make representations --- + + def to_sparse(self, state: State) -> tuple[SparseRepr, State]: + """ Make a sparse representation. + + See :py:class:`mdpoly.representations.SparseRepr` + """ + return self.unwrap().to_repr(SparseRepr, state) + + def to_dense(self, state: State) -> tuple[Repr, State]: + raise NotImplementedError |