]> gitweb.michael.orlitzky.com - sage.d.git/commitdiff
eja: improve projection/inclusion implementation for DirectSumEJA.
authorMichael Orlitzky <michael@orlitzky.com>
Fri, 20 Nov 2020 05:16:31 +0000 (00:16 -0500)
committerMichael Orlitzky <michael@orlitzky.com>
Tue, 24 Nov 2020 13:08:03 +0000 (08:08 -0500)
mjo/eja/eja_algebra.py

index 3b5828fed55098dfd3f4c95bf2354ac4e38efc87..7857190a2e458f0d955a49de8df7e7a9052bfe4a 100644 (file)
@@ -33,6 +33,7 @@ from sage.rings.all import (ZZ, QQ, AA, QQbar, RR, RLF, CLF,
 from mjo.eja.eja_element import FiniteDimensionalEuclideanJordanAlgebraElement
 lazy_import('mjo.eja.eja_subalgebra',
             'FiniteDimensionalEuclideanJordanSubalgebra')
+from mjo.eja.eja_operator import FiniteDimensionalEuclideanJordanAlgebraOperator
 from mjo.eja.eja_utils import _mat2vec
 
 class FiniteDimensionalEuclideanJordanAlgebra(CombinatorialFreeModule):
@@ -2418,7 +2419,8 @@ class DirectSumEJA(FiniteDimensionalEuclideanJordanAlgebra):
 
     SETUP::
 
-        sage: from mjo.eja.eja_algebra import (HadamardEJA,
+        sage: from mjo.eja.eja_algebra import (random_eja,
+        ....:                                  HadamardEJA,
         ....:                                  RealSymmetricEJA,
         ....:                                  DirectSumEJA)
 
@@ -2432,8 +2434,25 @@ class DirectSumEJA(FiniteDimensionalEuclideanJordanAlgebra):
         sage: J.rank()
         5
 
+    TESTS:
+
+    The external direct sum construction is only valid when the two factors
+    have the same base ring; an error is raised otherwise::
+
+        sage: set_random_seed()
+        sage: J1 = random_eja(AA)
+        sage: J2 = random_eja(QQ)
+        sage: J = DirectSumEJA(J1,J2)
+        Traceback (most recent call last):
+        ...
+        ValueError: algebras must share the same base field
+
     """
-    def __init__(self, J1, J2, field=AA, **kwargs):
+    def __init__(self, J1, J2, **kwargs):
+        if J1.base_ring() != J2.base_ring():
+            raise ValueError("algebras must share the same base field")
+        field = J1.base_ring()
+
         self._factors = (J1, J2)
         n1 = J1.dimension()
         n2 = J2.dimension()
@@ -2506,8 +2525,11 @@ class DirectSumEJA(FiniteDimensionalEuclideanJordanAlgebra):
         """
         (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:])
+        V_basis = self.vector_space().basis()
+        P1 = matrix(self.base_ring(), V_basis[:n])
+        P2 = matrix(self.base_ring(), V_basis[n:])
+        pi_left = FiniteDimensionalEuclideanJordanAlgebraOperator(self,J1,P1)
+        pi_right = FiniteDimensionalEuclideanJordanAlgebraOperator(self,J2,P2)
         return (pi_left, pi_right)
 
     def inclusions(self):
@@ -2516,7 +2538,8 @@ class DirectSumEJA(FiniteDimensionalEuclideanJordanAlgebra):
 
         SETUP::
 
-            sage: from mjo.eja.eja_algebra import (JordanSpinEJA,
+            sage: from mjo.eja.eja_algebra import (random_eja,
+            ....:                                  JordanSpinEJA,
             ....:                                  RealSymmetricEJA,
             ....:                                  DirectSumEJA)
 
@@ -2541,14 +2564,35 @@ class DirectSumEJA(FiniteDimensionalEuclideanJordanAlgebra):
             sage: J.one().to_vector()
             (1, 0, 0, 1, 0, 1)
 
+        TESTS:
+
+        Composing a projection with the corresponding inclusion should
+        produce the identity map, and mismatching them should produce
+        the zero map::
+
+            sage: set_random_seed()
+            sage: J1 = random_eja()
+            sage: J2 = random_eja()
+            sage: J = DirectSumEJA(J1,J2)
+            sage: (iota_left, iota_right) = J.inclusions()
+            sage: (pi_left, pi_right) = J.projections()
+            sage: pi_left*iota_left == J1.one().operator()
+            True
+            sage: pi_right*iota_right == J2.one().operator()
+            True
+            sage: (pi_left*iota_right).is_zero()
+            True
+            sage: (pi_right*iota_left).is_zero()
+            True
+
         """
         (J1,J2) = self.factors()
         n = J1.dimension()
         V_basis = self.vector_space().basis()
         I1 = matrix.column(self.base_ring(), V_basis[:n])
         I2 = matrix.column(self.base_ring(), V_basis[n:])
-        iota_left = lambda x: self.from_vector(I1*x.to_vector())
-        iota_right = lambda x: self.from_vector(I2*+x.to_vector())
+        iota_left = FiniteDimensionalEuclideanJordanAlgebraOperator(J1,self,I1)
+        iota_right = FiniteDimensionalEuclideanJordanAlgebraOperator(J2,self,I2)
         return (iota_left, iota_right)
 
     def inner_product(self, x, y):
@@ -2567,7 +2611,7 @@ class DirectSumEJA(FiniteDimensionalEuclideanJordanAlgebra):
 
         EXAMPLE::
 
-            sage: J1 = HadamardEJA(3)
+            sage: J1 = HadamardEJA(3,QQ)
             sage: J2 = QuaternionHermitianEJA(2,QQ,normalize_basis=False)
             sage: J = DirectSumEJA(J1,J2)
             sage: x1 = J1.one()