From 309fc28265693c9abd51780ea76f8beec39ce27f Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Sat, 7 Nov 2020 13:00:38 -0500 Subject: [PATCH] eja: let random_eja() return zero-dimensional algebras of all types. --- mjo/eja/TODO | 6 ------ mjo/eja/eja_algebra.py | 11 +++++++++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/mjo/eja/TODO b/mjo/eja/TODO index a915812..e02257f 100644 --- a/mjo/eja/TODO +++ b/mjo/eja/TODO @@ -10,9 +10,3 @@ 5. Factor out the unit-norm basis (and operator symmetry) tests once all of the algebras pass. - -6. Can we make the minimal and characteristic polynomial tests work - for trivial algebras, too? Then we wouldn't need the "nontrivial" - argument to random_eja(). This would also allow us to potentially - pass a "size" of zero to the other constructors in random_eja() -- - a code path that is basically untested right now. diff --git a/mjo/eja/eja_algebra.py b/mjo/eja/eja_algebra.py index 055bbbd..4e66b2d 100644 --- a/mjo/eja/eja_algebra.py +++ b/mjo/eja/eja_algebra.py @@ -438,8 +438,15 @@ class FiniteDimensionalEuclideanJordanAlgebra(CombinatorialFreeModule): """ Return the matrix space in which this algebra's natural basis elements live. + + Generally this will be an `n`-by-`1` column-vector space, + except when the algebra is trivial. There it's `n`-by-`n` + (where `n` is zero), to ensure that two elements of the + natural basis space (empty matrices) can be multiplied. """ - if self._natural_basis is None or len(self._natural_basis) == 0: + if self.is_trivial(): + return MatrixSpace(self.base_ring(), 0) + elif self._natural_basis is None or len(self._natural_basis) == 0: return MatrixSpace(self.base_ring(), self.dimension(), 1) else: return self._natural_basis[0].matrix_space() @@ -666,7 +673,7 @@ class FiniteDimensionalEuclideanJordanAlgebra(CombinatorialFreeModule): # there's only one. return cls(field) - n = ZZ.random_element(cls._max_test_case_size()) + 1 + n = ZZ.random_element(cls._max_test_case_size() + 1) return cls(n, field, **kwargs) @cached_method -- 2.44.2