]> gitweb.michael.orlitzky.com - sage.d.git/blobdiff - mjo/eja/eja_algebra.py
eja: let random_eja() return zero-dimensional algebras of all types.
[sage.d.git] / mjo / eja / eja_algebra.py
index 055bbbda83d7576fda8f5e1794d759c2eee467bc..4e66b2db251274d3091875a20056692f33849513 100644 (file)
@@ -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