]> gitweb.michael.orlitzky.com - sage.d.git/blobdiff - mjo/eja/eja_algebra.py
eja: add DirectSumEJA constructor (and not much else).
[sage.d.git] / mjo / eja / eja_algebra.py
index 91088a2eb799ce616bfffc5ee3e3980afe17f4ac..f327bf51aada40b33fd05fb0d1c38c124d4b545e 100644 (file)
@@ -698,12 +698,16 @@ class FiniteDimensionalEuclideanJordanAlgebra(CombinatorialFreeModule):
         if self.base_ring() is AA:
             # The "random element" method of the algebraic reals is
             # stupid at the moment, and only returns integers between
-            # -2 and 2, inclusive. Instead, we implement our own
-            # "random vector" method, and then coerce that into the
-            # algebra. We use the vector space degree here instead of
-            # the dimension because a subalgebra could (for example) be
-            # spanned by only two vectors, each with five coordinates.
-            # We need to generate all five coordinates.
+            # -2 and 2, inclusive:
+            #
+            #   https://trac.sagemath.org/ticket/30875
+            #
+            # Instead, we implement our own "random vector" method,
+            # and then coerce that into the algebra. We use the vector
+            # space degree here instead of the dimension because a
+            # subalgebra could (for example) be spanned by only two
+            # vectors, each with five coordinates.  We need to
+            # generate all five coordinates.
             if thorough:
                 v *= QQbar.random_element().real()
             else:
@@ -2130,3 +2134,50 @@ class TrivialEJA(FiniteDimensionalEuclideanJordanAlgebra):
         # largest subalgebra generated by any element.
         fdeja.__init__(field, mult_table, **kwargs)
         self.rank.set_cache(0)
+
+
+class DirectSumEJA(FiniteDimensionalEuclideanJordanAlgebra):
+    r"""
+    The external (orthogonal) direct sum of two other Euclidean Jordan
+    algebras. Essentially the Cartesian product of its two factors.
+    Every Euclidean Jordan algebra decomposes into an orthogonal
+    direct sum of simple Euclidean Jordan algebras, so no generality
+    is lost by providing only this construction.
+
+    SETUP::
+
+        sage: from mjo.eja.eja_algebra import (HadamardEJA,
+        ....:                                  RealSymmetricEJA,
+        ....:                                  DirectSumEJA)
+
+    EXAMPLES::
+
+        sage: J1 = HadamardEJA(2)
+        sage: J2 = RealSymmetricEJA(3)
+        sage: J = DirectSumEJA(J1,J2)
+        sage: J.dimension()
+        8
+        sage: J.rank()
+        5
+
+    """
+    def __init__(self, J1, J2, field=AA, **kwargs):
+        n1 = J1.dimension()
+        n2 = J2.dimension()
+        n = n1+n2
+        V = VectorSpace(field, n)
+        mult_table = [ [ V.zero() for j in range(n) ]
+                       for i in range(n) ]
+        for i in range(n1):
+            for j in range(n1):
+                p = (J1.monomial(i)*J1.monomial(j)).to_vector()
+                mult_table[i][j] = V(p.list() + [field.zero()]*n2)
+
+        for i in range(n2):
+            for j in range(n2):
+                p = (J2.monomial(i)*J2.monomial(j)).to_vector()
+                mult_table[n1+i][n1+j] = V([field.zero()]*n1 + p.list())
+
+        fdeja = super(DirectSumEJA, self)
+        fdeja.__init__(field, mult_table, **kwargs)
+        self.rank.set_cache(J1.rank() + J2.rank())