aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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