summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Schneeberger <michael.schneeberger@fhnw.ch>2024-03-12 17:46:53 +0100
committerMichael Schneeberger <michael.schneeberger@fhnw.ch>2024-03-12 17:46:53 +0100
commite520902fd6f9991ffb75d8bc48f5f5ba144b91b3 (patch)
tree14e3eae5a10181845156e9b64deabbf5ff909521
parentadd integrate expression, improve variable naming (diff)
downloadpolymatrix-upstream.tar.gz
polymatrix-upstream.zip
add minimal documentation to the expression mixinsupstream
Diffstat (limited to '')
-rw-r--r--polymatrix/expression/mixins/additionexprmixin.py10
-rw-r--r--polymatrix/expression/mixins/blockdiagexprmixin.py6
-rw-r--r--polymatrix/expression/mixins/filterexprmixin.py4
-rw-r--r--polymatrix/expression/mixins/integrateexprmixin.py2
-rw-r--r--polymatrix/expression/mixins/linearmatrixinexprmixin.py1
-rw-r--r--polymatrix/expression/mixins/maxexprmixin.py1
-rw-r--r--polymatrix/expression/mixins/parametrizematrixexprmixin.py1
-rw-r--r--polymatrix/expression/mixins/quadraticinexprmixin.py5
-rw-r--r--polymatrix/expression/mixins/subtractmonomialsexprmixin.py4
-rw-r--r--polymatrix/expression/mixins/toquadraticexprmixin.py6
-rw-r--r--polymatrix/expression/mixins/transposeexprmixin.py5
11 files changed, 39 insertions, 6 deletions
diff --git a/polymatrix/expression/mixins/additionexprmixin.py b/polymatrix/expression/mixins/additionexprmixin.py
index e3580f0..0ba8a2e 100644
--- a/polymatrix/expression/mixins/additionexprmixin.py
+++ b/polymatrix/expression/mixins/additionexprmixin.py
@@ -10,6 +10,16 @@ from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin
class AdditionExprMixin(ExpressionBaseMixin):
+ """
+ Adds two polymatrices
+
+ [[2*x1+x2], [x1**2]] + [[3*x2], [x1]] -> [[2*x1+4*x2], [x1+x1**2]].
+
+ If one summand is of size (1, 1), then perform broadcast:
+
+ [[2*x1+x2], [x1**2]] + [[x1]] -> [[3*x1+x2], [x1+x1**2]].
+ """
+
@property
@abc.abstractmethod
def left(self) -> ExpressionBaseMixin:
diff --git a/polymatrix/expression/mixins/blockdiagexprmixin.py b/polymatrix/expression/mixins/blockdiagexprmixin.py
index 4754d53..be8e78a 100644
--- a/polymatrix/expression/mixins/blockdiagexprmixin.py
+++ b/polymatrix/expression/mixins/blockdiagexprmixin.py
@@ -10,6 +10,12 @@ from polymatrix.expressionstate.abc import ExpressionState
class BlockDiagExprMixin(ExpressionBaseMixin):
+ """
+ Create a block diagonal polymatrix from provided polymatrices
+
+ [[x1]], [[x2], [x3]] -> [[x1, 0], [0, x2], [0, x3]].
+ """
+
@property
@abc.abstractmethod
def underlying(self) -> tuple[ExpressionBaseMixin, ...]:
diff --git a/polymatrix/expression/mixins/filterexprmixin.py b/polymatrix/expression/mixins/filterexprmixin.py
index a240102..657191b 100644
--- a/polymatrix/expression/mixins/filterexprmixin.py
+++ b/polymatrix/expression/mixins/filterexprmixin.py
@@ -8,6 +8,9 @@ from polymatrix.expressionstate.abc import ExpressionState
class FilterExprMixin(ExpressionBaseMixin):
+ """
+ [[x1, x2, x3]], [[1, 0, 1]] -> [[x1, x3]].
+ """
@property
@abc.abstractmethod
@@ -32,6 +35,7 @@ class FilterExprMixin(ExpressionBaseMixin):
state, underlying = self.underlying.apply(state=state)
state, predicator = self.predicator.apply(state=state)
+ # todo: generalize to nxn matrix
assert underlying.shape[1] == 1
assert predicator.shape[1] == 1
assert underlying.shape[0] == predicator.shape[0]
diff --git a/polymatrix/expression/mixins/integrateexprmixin.py b/polymatrix/expression/mixins/integrateexprmixin.py
index 4104995..4844fcd 100644
--- a/polymatrix/expression/mixins/integrateexprmixin.py
+++ b/polymatrix/expression/mixins/integrateexprmixin.py
@@ -1,8 +1,6 @@
import abc
-import collections
import itertools
-import typing
from polymatrix.polymatrix.init import init_poly_matrix
from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin
diff --git a/polymatrix/expression/mixins/linearmatrixinexprmixin.py b/polymatrix/expression/mixins/linearmatrixinexprmixin.py
index a7d5f34..620d0fd 100644
--- a/polymatrix/expression/mixins/linearmatrixinexprmixin.py
+++ b/polymatrix/expression/mixins/linearmatrixinexprmixin.py
@@ -10,6 +10,7 @@ from polymatrix.expressionstate.abc import ExpressionState
from polymatrix.expression.utils.getvariableindices import get_variable_indices_from_variable
+# is this class needed?
class LinearMatrixInExprMixin(ExpressionBaseMixin):
@property
@abc.abstractmethod
diff --git a/polymatrix/expression/mixins/maxexprmixin.py b/polymatrix/expression/mixins/maxexprmixin.py
index fa1155e..e0cdcad 100644
--- a/polymatrix/expression/mixins/maxexprmixin.py
+++ b/polymatrix/expression/mixins/maxexprmixin.py
@@ -7,6 +7,7 @@ from polymatrix.expressionstate.mixins import ExpressionStateMixin
from polymatrix.polymatrix.mixins import PolyMatrixMixin
+# remove?
class MaxExprMixin(ExpressionBaseMixin):
@property
@abc.abstractclassmethod
diff --git a/polymatrix/expression/mixins/parametrizematrixexprmixin.py b/polymatrix/expression/mixins/parametrizematrixexprmixin.py
index c51bcf0..4eda9bf 100644
--- a/polymatrix/expression/mixins/parametrizematrixexprmixin.py
+++ b/polymatrix/expression/mixins/parametrizematrixexprmixin.py
@@ -8,6 +8,7 @@ from polymatrix.expressionstate.mixins import ExpressionStateMixin
from polymatrix.polymatrix.mixins import PolyMatrixMixin
+# remove?
class ParametrizeMatrixExprMixin(ExpressionBaseMixin):
@property
@abc.abstractclassmethod
diff --git a/polymatrix/expression/mixins/quadraticinexprmixin.py b/polymatrix/expression/mixins/quadraticinexprmixin.py
index 95d3a2d..8869903 100644
--- a/polymatrix/expression/mixins/quadraticinexprmixin.py
+++ b/polymatrix/expression/mixins/quadraticinexprmixin.py
@@ -14,6 +14,11 @@ from polymatrix.utils.tooperatorexception import to_operator_exception
class QuadraticInExprMixin(ExpressionBaseMixin):
+ """
+ [[4 + 2*x1 + 3*x1**2]] -> [[4, 1], [1, 3]]
+ """
+
+
@property
@abc.abstractmethod
def underlying(self) -> ExpressionBaseMixin:
diff --git a/polymatrix/expression/mixins/subtractmonomialsexprmixin.py b/polymatrix/expression/mixins/subtractmonomialsexprmixin.py
index a01b5e7..5baddd1 100644
--- a/polymatrix/expression/mixins/subtractmonomialsexprmixin.py
+++ b/polymatrix/expression/mixins/subtractmonomialsexprmixin.py
@@ -12,6 +12,10 @@ from polymatrix.polymatrix.utils.subtractmonomialindices import SubtractError, s
class SubtractMonomialsExprMixin(ExpressionBaseMixin):
+ """
+ [[1], [x], [x**3]], [[x]] -> [[1], [x**2]]
+ """
+
@property
@abc.abstractclassmethod
def underlying(self) -> ExpressionBaseMixin:
diff --git a/polymatrix/expression/mixins/toquadraticexprmixin.py b/polymatrix/expression/mixins/toquadraticexprmixin.py
index c6b692b..1234606 100644
--- a/polymatrix/expression/mixins/toquadraticexprmixin.py
+++ b/polymatrix/expression/mixins/toquadraticexprmixin.py
@@ -10,6 +10,12 @@ from polymatrix.expressionstate.abc import ExpressionState
class ToQuadraticExprMixin(ExpressionBaseMixin):
+ """
+ [[1 + x1**2 + x1**3]] -> [[1 + x1**2 + x2*x1]]
+
+ with auxilliary equation: x1**2 - x2
+ """
+
@property
@abc.abstractmethod
def underlying(self) -> ExpressionBaseMixin:
diff --git a/polymatrix/expression/mixins/transposeexprmixin.py b/polymatrix/expression/mixins/transposeexprmixin.py
index ce435e9..99fc247 100644
--- a/polymatrix/expression/mixins/transposeexprmixin.py
+++ b/polymatrix/expression/mixins/transposeexprmixin.py
@@ -1,11 +1,8 @@
import abc
-import dataclasses
-import typing
import dataclassabc
-from polymatrix.polymatrix.mixins import PolyMatrixMixin
-from polymatrix.polymatrix.init import init_poly_matrix
+from polymatrix.polymatrix.mixins import PolyMatrixMixin
from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin
from polymatrix.polymatrix.abc import PolyMatrix
from polymatrix.expressionstate.abc import ExpressionState