]> gitweb.michael.orlitzky.com - sage.d.git/commitdiff
mjo/matrix_algebra.py: support OctonionAlgebra in entry_algebra_gens()
authorMichael Orlitzky <michael@orlitzky.com>
Tue, 7 Apr 2026 15:07:07 +0000 (11:07 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Tue, 7 Apr 2026 15:07:07 +0000 (11:07 -0400)
We need a special case for algebras that have a basis(), since that's
really what we want, and "generators" is technically incorrect when
multiplication is involved.

mjo/matrix_algebra.py

index eff1835a4d9f0d9f14ec02159e885d7e9a944490..affafc3570cd1344af8fcf503beec4b01fb9c5a8 100644 (file)
@@ -271,7 +271,13 @@ class MatrixAlgebra(CombinatorialFreeModule):
         inconsistency in the ``gens()`` methods of the various
         entry algebras.
         """
-        return self.entry_algebra().gens()
+        A = self.entry_algebra()
+        if hasattr(A, "basis"):
+            # In the OctonionAlgebra, "gens" contains only four
+            # elements because multiplication generates the others.
+            return A.basis()
+        else:
+            return A.gens()
 
     def _entry_algebra_element_to_vector(self, entry):
         r"""
@@ -322,13 +328,11 @@ class MatrixAlgebra(CombinatorialFreeModule):
             sage: A._entry_algebra_element_to_vector(e[7])
             (0, 0, 0, 0, 0, 0, 0, 1)
 
-        Sage OctonionAlgebra. Eventually this should use
-        ``_entry_algebra_gens()`` once we migrate
-        :cls:`OctonionMatrixAlgebra` to Sage's octonions::
+        Sage OctonionAlgebra::
 
             sage: O = OctonionAlgebra(QQ)
             sage: A = MatrixAlgebra(1, O, QQ)
-            sage: e = A.entry_algebra().basis()
+            sage: e = A.entry_algebra_gens()
             sage: A._entry_algebra_element_to_vector(e[0])
             (1, 0, 0, 0, 0, 0, 0, 0)
             sage: A._entry_algebra_element_to_vector(e[1])