From 8b44f537a2961b04ef4b42183bb42e6eaee9bd60 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Tue, 7 Apr 2026 11:07:07 -0400 Subject: [PATCH] mjo/matrix_algebra.py: support OctonionAlgebra in entry_algebra_gens() 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 | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/mjo/matrix_algebra.py b/mjo/matrix_algebra.py index eff1835..affafc3 100644 --- a/mjo/matrix_algebra.py +++ b/mjo/matrix_algebra.py @@ -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]) -- 2.53.0