]> gitweb.michael.orlitzky.com - sage.d.git/commitdiff
eja: add projections for DirectSumEJA.
authorMichael Orlitzky <michael@orlitzky.com>
Fri, 13 Nov 2020 14:05:55 +0000 (09:05 -0500)
committerMichael Orlitzky <michael@orlitzky.com>
Fri, 13 Nov 2020 14:05:55 +0000 (09:05 -0500)
mjo/eja/eja_algebra.py

index b9389da25e69722f04633c8324998d8d4834608a..3f91ee3ae72c6281c9238804f146944d2c431f1e 100644 (file)
@@ -2324,6 +2324,7 @@ class DirectSumEJA(FiniteDimensionalEuclideanJordanAlgebra):
 
     """
     def __init__(self, J1, J2, field=AA, **kwargs):
+        self._factors = (J1, J2)
         n1 = J1.dimension()
         n2 = J2.dimension()
         n = n1+n2
@@ -2345,3 +2346,56 @@ class DirectSumEJA(FiniteDimensionalEuclideanJordanAlgebra):
                                            check_axioms=False,
                                            **kwargs)
         self.rank.set_cache(J1.rank() + J2.rank())
+
+
+    def factors(self):
+        r"""
+        Return the pair of this algebra's factors.
+
+        SETUP::
+
+            sage: from mjo.eja.eja_algebra import (HadamardEJA,
+            ....:                                  JordanSpinEJA,
+            ....:                                  DirectSumEJA)
+
+        EXAMPLES::
+
+            sage: J1 = HadamardEJA(2,QQ)
+            sage: J2 = JordanSpinEJA(3,QQ)
+            sage: J = DirectSumEJA(J1,J2)
+            sage: J.factors()
+            (Euclidean Jordan algebra of dimension 2 over Rational Field,
+             Euclidean Jordan algebra of dimension 3 over Rational Field)
+
+        """
+        return self._factors
+
+    def projections(self):
+        r"""
+        Return a pair of projections onto this algebra's factors.
+
+        SETUP::
+
+            sage: from mjo.eja.eja_algebra import (JordanSpinEJA,
+            ....:                                  ComplexHermitianEJA,
+            ....:                                  DirectSumEJA)
+
+        EXAMPLES::
+
+            sage: J1 = JordanSpinEJA(2)
+            sage: J2 = ComplexHermitianEJA(2)
+            sage: J = DirectSumEJA(J1,J2)
+            sage: (pi_left, pi_right) = J.projections()
+            sage: J.one().to_vector()
+            (1, 0, 1, 0, 0, 1)
+            sage: pi_left(J.one()).to_vector()
+            (1, 0)
+            sage: pi_right(J.one()).to_vector()
+            (1, 0, 0, 1)
+
+        """
+        (J1,J2) = self.factors()
+        n = J1.dimension()
+        pi_left  = lambda x: J1.from_vector(x.to_vector()[:n])
+        pi_right = lambda x: J2.from_vector(x.to_vector()[n:])
+        return (pi_left, pi_right)