From 4d0aae306aa9f80009cbbea9088382e30df919af Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Tue, 2 Mar 2021 10:20:02 -0500 Subject: [PATCH] octonions: add matrix_space() method for elements and _repr_ for parents. --- mjo/octonions.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/mjo/octonions.py b/mjo/octonions.py index 352c4c5..73acf2d 100644 --- a/mjo/octonions.py +++ b/mjo/octonions.py @@ -445,6 +445,24 @@ class OctonionMatrix(IndexedFreeModuleElement): zero = self.parent().octonions().zero() return sum( (self[i,i] for i in range(self.nrows())), zero ) + def matrix_space(self): + r""" + + SETUP:: + + sage: from mjo.octonions import OctonionMatrixAlgebra + + TESTS:: + + sage: set_random_seed() + sage: MS = OctonionMatrixAlgebra(2) + sage: MS.random_element().matrix_space() + Module of 2 by 2 matrices with octonion entries over the + scalar ring Algebraic Real Field + + """ + return self.parent() + class OctonionMatrixAlgebra(CombinatorialFreeModule): r""" @@ -483,6 +501,11 @@ class OctonionMatrixAlgebra(CombinatorialFreeModule): prefix=prefix, bracket='(') + def _repr_(self): + return ("Module of %d by %d matrices with octonion entries" + " over the scalar ring %s" % + (self.nrows(), self.ncols(), self.base_ring()) ) + def octonions(self): r""" Return the Octonion algebra that our elements' entries come from. -- 2.43.2