aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--mdpoly/algebra.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/mdpoly/algebra.py b/mdpoly/algebra.py
index a715b7e..d603eee 100644
--- a/mdpoly/algebra.py
+++ b/mdpoly/algebra.py
@@ -206,7 +206,7 @@ class PolyVar(Var, PolyRingExpr):
def to_repr(self, repr_type: type, state: State) -> tuple[Repr, State]:
r = repr_type()
- idx = PolyVarIndex.from_var(self, state),
+ idx = PolyVarIndex.from_var(self, state), # important comma!
r.set(MatrixIndex.scalar(), PolyIndex(idx), 1)
return r, state
@@ -491,20 +491,21 @@ class MatVar(Var, MatrixExpr):
shape: Shape
algebra: Algebra = Algebra.matrix_ring
- def to_scalars(self, scalar_type: Type[T]) -> Iterable[tuple[MatrixIndex, T]]:
+ def to_scalars(self, scalar_var_type: Type[T]) -> Iterable[tuple[MatrixIndex, T]]:
for row in range(self.shape.rows):
for col in range(self.shape.cols):
- var = scalar_type(name=f"{self.name}_[{row},{col}]")
- idx = MatrixIndex(row, col)
+ var = scalar_var_type(name=f"{self.name}_[{row},{col}]")
+ entry = MatrixIndex(row, col)
- yield idx, var
+ yield entry, var
def to_repr(self, repr_type: type, state: State) -> tuple[Repr, State]:
r = repr_type()
# FIXME: do not hardcode scalar type
- for idx, var in self.to_scalars(Var):
- ...
+ for entry, var in self.to_scalars(PolyVar):
+ idx = PolyVarIndex.from_var(var, state), # important comma!
+ r.set(entry, PolyIndex(idx), 1)
return r, state