]> gitweb.michael.orlitzky.com - sage.d.git/commitdiff
eja: enable (dimension one) Octonion algebras in random_eja().
authorMichael Orlitzky <michael@orlitzky.com>
Sat, 6 Mar 2021 22:40:53 +0000 (17:40 -0500)
committerMichael Orlitzky <michael@orlitzky.com>
Sat, 6 Mar 2021 22:40:53 +0000 (17:40 -0500)
mjo/eja/eja_algebra.py

index 43f8021706fdeaa20033043ae31d808b00bc007a..6750f228451b5ec2052efc3974ddee72cd0d0c12 100644 (file)
@@ -1542,7 +1542,7 @@ class FiniteDimensionalEJA(CombinatorialFreeModule):
 
 class RationalBasisEJA(FiniteDimensionalEJA):
     r"""
-    New class for algebras whose supplied basis elements have all rational entries.
+    Algebras whose supplied basis elements have all rational entries.
 
     SETUP::
 
@@ -2584,7 +2584,7 @@ class QuaternionHermitianEJA(ConcreteEJA,
         n = ZZ.random_element(cls._max_random_instance_size() + 1)
         return cls(n, **kwargs)
 
-class OctonionHermitianEJA(FiniteDimensionalEJA, MatrixEJA):
+class OctonionHermitianEJA(ConcreteEJA, MatrixEJA):
     r"""
     SETUP::
 
@@ -2667,7 +2667,23 @@ class OctonionHermitianEJA(FiniteDimensionalEJA, MatrixEJA):
         sage: J.rank.clear_cache()                           # long time
         sage: J.rank()                                       # long time
         2
+
     """
+    @staticmethod
+    def _max_random_instance_size():
+        r"""
+        The maximum rank of a random QuaternionHermitianEJA.
+        """
+        return 1 # Dimension 1
+
+    @classmethod
+    def random_instance(cls, **kwargs):
+        """
+        Return a random instance of this type of algebra.
+        """
+        n = ZZ.random_element(cls._max_random_instance_size() + 1)
+        return cls(n, **kwargs)
+
     def __init__(self, n, field=AA, **kwargs):
         if n > 3:
             # Otherwise we don't get an EJA.
@@ -3641,7 +3657,9 @@ class RationalBasisCartesianProductEJA(CartesianProductEJA,
 
     SETUP::
 
-        sage: from mjo.eja.eja_algebra import (JordanSpinEJA,
+        sage: from mjo.eja.eja_algebra import (HadamardEJA,
+        ....:                                  JordanSpinEJA,
+        ....:                                  OctonionHermitianEJA,
         ....:                                  RealSymmetricEJA)
 
     EXAMPLES:
@@ -3658,15 +3676,32 @@ class RationalBasisCartesianProductEJA(CartesianProductEJA,
         sage: J.rank()
         5
 
+    TESTS:
+
+    The ``cartesian_product()`` function only uses the first factor to
+    decide where the result will live; thus we have to be careful to
+    check that all factors do indeed have a `_rational_algebra` member
+    before we try to access it::
+
+        sage: J1 = OctonionHermitianEJA(1) # no rational basis
+        sage: J2 = HadamardEJA(2)
+        sage: cartesian_product([J1,J2])
+        Euclidean Jordan algebra of dimension 1 over Algebraic Real Field
+        (+) Euclidean Jordan algebra of dimension 2 over Algebraic Real Field
+        sage: cartesian_product([J2,J1])
+        Euclidean Jordan algebra of dimension 2 over Algebraic Real Field
+        (+) Euclidean Jordan algebra of dimension 1 over Algebraic Real Field
+
     """
     def __init__(self, algebras, **kwargs):
         CartesianProductEJA.__init__(self, algebras, **kwargs)
 
         self._rational_algebra = None
         if self.vector_space().base_field() is not QQ:
-            self._rational_algebra = cartesian_product([
-                r._rational_algebra for r in algebras
-            ])
+            if all( hasattr(r, "_rational_algebra") for r in algebras ):
+                self._rational_algebra = cartesian_product([
+                    r._rational_algebra for r in algebras
+                ])
 
 
 RationalBasisEJA.CartesianProduct = RationalBasisCartesianProductEJA