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::
n = ZZ.random_element(cls._max_random_instance_size() + 1)
return cls(n, **kwargs)
-class OctonionHermitianEJA(FiniteDimensionalEJA, MatrixEJA):
+class OctonionHermitianEJA(ConcreteEJA, MatrixEJA):
r"""
SETUP::
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.
SETUP::
- sage: from mjo.eja.eja_algebra import (JordanSpinEJA,
+ sage: from mjo.eja.eja_algebra import (HadamardEJA,
+ ....: JordanSpinEJA,
+ ....: OctonionHermitianEJA,
....: RealSymmetricEJA)
EXAMPLES:
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