aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNao Pross <np@0hm.ch>2024-03-08 14:15:04 +0100
committerNao Pross <np@0hm.ch>2024-03-08 14:15:04 +0100
commit306fadf272f532600e62d34c5929a8dcbeebeabf (patch)
treeac783fd9279a7745325a31191b6815aac63a046c
parentAdd tree rotations to Expr (diff)
downloadmdpoly-306fadf272f532600e62d34c5929a8dcbeebeabf.tar.gz
mdpoly-306fadf272f532600e62d34c5929a8dcbeebeabf.zip
Implement MatScalarMul.to_repr
Diffstat (limited to '')
-rw-r--r--mdpoly/algebra.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/mdpoly/algebra.py b/mdpoly/algebra.py
index d087785..81fae18 100644
--- a/mdpoly/algebra.py
+++ b/mdpoly/algebra.py
@@ -640,15 +640,19 @@ class MatScalarMul(BinaryOp, MatrixExpr):
def to_repr(self, repr_type: type, state: State) -> tuple[Repr, State]:
""" See :py:meth:`mdpoly.abc.Expr.to_repr`. """
- raise NotImplementedError
r = repr_type()
scalar_repr, state = self.left.to_repr(repr_type, state)
mat_repr, state = self.right.to_repr(repr_type, state)
for entry in mat_repr.entries():
- for term in mat_repr.terms(entry):
- ...
+ scalar_terms = scalar_repr.terms(MatrixIndex.scalar())
+ mat_terms = mat_repr.terms(entry)
+ for scalar_term, mat_term in product(scalar_terms, mat_terms):
+ term = PolyIndex.product(scalar_term, mat_term)
+
+ p = r.at(entry, term) + scalar_repr.at(entry, scalar_term) + mat_repr.at(entry, mat_term)
+ r.set(entry, term, p)
return r, state