]> gitweb.michael.orlitzky.com - sage.d.git/commitdiff
matrix_algebra: use simpler indices.
authorMichael Orlitzky <michael@orlitzky.com>
Wed, 3 Mar 2021 12:41:24 +0000 (07:41 -0500)
committerMichael Orlitzky <michael@orlitzky.com>
Wed, 3 Mar 2021 12:41:24 +0000 (07:41 -0500)
Using cartesian_product() and FiniteEnumeratedSet for my indices was
obscuring the foo.basis() output.

mjo/matrix_algebra.py

index a695b0b7919edfb243cd96fd2592aa2f9fa916df..668a1c44d839e6b5704aa72acb90970136eca571 100644 (file)
@@ -193,15 +193,15 @@ class MatrixAlgebra(CombinatorialFreeModule):
         # sticking a "1" in each position doesn't give us a basis for
         # the space. We actually need to stick each of e0, e1, ...  (a
         # basis for the entry algebra itself) into each position.
-        from sage.sets.finite_enumerated_set import FiniteEnumeratedSet
-        from sage.categories.sets_cat import cartesian_product
-
-        I = FiniteEnumeratedSet(range(n))
-        J = FiniteEnumeratedSet(range(n))
+        I = range(n)
+        J = range(n)
         self._entry_algebra = entry_algebra
         entry_basis = entry_algebra.gens()
 
-        basis_indices = cartesian_product([I,J,entry_basis])
+        basis_indices = [(i,j,e) for i in range(n)
+                                 for j in range(n)
+                                 for e in entry_algebra.gens()]
+
         super().__init__(scalars,
                          basis_indices,
                          category=category,
@@ -227,13 +227,14 @@ class MatrixAlgebra(CombinatorialFreeModule):
     ncols = nrows
 
     def product_on_basis(self, mon1, mon2):
-        (i,j,oct1) = mon1
-        (k,l,oct2) = mon2
+        (i,j,e1) = mon1
+        (k,l,e2) = mon2
         if j == k:
-            return self.monomial((i,l,oct1*oct2))
+            return self.monomial((i,l,e1*e2))
         else:
             return self.zero()
 
+    # TODO: only makes sense if I'm unital.
     def one(self):
         r"""
         SETUP::