diff options
author | Nao Pross <np@0hm.ch> | 2024-03-08 14:15:04 +0100 |
---|---|---|
committer | Nao Pross <np@0hm.ch> | 2024-03-08 14:15:04 +0100 |
commit | 306fadf272f532600e62d34c5929a8dcbeebeabf (patch) | |
tree | ac783fd9279a7745325a31191b6815aac63a046c | |
parent | Add tree rotations to Expr (diff) | |
download | mdpoly-306fadf272f532600e62d34c5929a8dcbeebeabf.tar.gz mdpoly-306fadf272f532600e62d34c5929a8dcbeebeabf.zip |
Implement MatScalarMul.to_repr
-rw-r--r-- | mdpoly/algebra.py | 10 |
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 |