]> gitweb.michael.orlitzky.com - sage.d.git/commitdiff
eja: allow addition of EJA morphisms.
authorMichael Orlitzky <michael@orlitzky.com>
Fri, 26 Jul 2019 16:31:01 +0000 (12:31 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Mon, 29 Jul 2019 03:19:01 +0000 (23:19 -0400)
mjo/eja/euclidean_jordan_algebra.py

index 72e167e6811912c3b19a71b27432d052800d3051..b239dc7287326f95815708ca3b80fd2c64d99b1a 100644 (file)
@@ -17,7 +17,7 @@ from sage.algebras.finite_dimensional_algebras.finite_dimensional_algebra_morphi
 class FiniteDimensionalEuclideanJordanAlgebraMorphism(FiniteDimensionalAlgebraMorphism):
     """
     A very thin wrapper around FiniteDimensionalAlgebraMorphism that
-    does only two things:
+    does only three things:
 
       1. Avoids the ``unitary`` and ``check`` arguments to the constructor
          that will always be ``False``. This is necessary because these
@@ -28,11 +28,44 @@ class FiniteDimensionalEuclideanJordanAlgebraMorphism(FiniteDimensionalAlgebraMo
       2. Inputs and outputs the underlying matrix with respect to COLUMN
          vectors, unlike the parent class.
 
+      3. Allows us to add morphisms in the obvious way.
+
     If this seems a bit heavyweight, it is. I would have been happy to
     use a the ring morphism that underlies the finite-dimensional
     algebra morphism, but they don't seem to be callable on elements of
-    our EJA.
+    our EJA, and you can't add them.
     """
+
+    def __add__(self, other):
+        """
+        Add two EJA morphisms in the obvious way.
+
+        EXAMPLES:
+
+            sage: J = RealSymmetricEJA(3)
+            sage: x = J.zero()
+            sage: y = J.zero()
+            sage: x.operator() + y.operator()
+            Morphism from Euclidean Jordan algebra of degree 6 over Rational
+            Field to Euclidean Jordan algebra of degree 6 over Rational Field
+            given by matrix
+            [0 0 0 0 0 0]
+            [0 0 0 0 0 0]
+            [0 0 0 0 0 0]
+            [0 0 0 0 0 0]
+            [0 0 0 0 0 0]
+            [0 0 0 0 0 0]
+
+        """
+        P = self.parent()
+        if not other in P:
+            raise ValueError("summands must live in the same space")
+
+        return FiniteDimensionalEuclideanJordanAlgebraMorphism(
+                  P,
+                  self.matrix() + other.matrix() )
+
+
     def __init__(self, parent, f):
         FiniteDimensionalAlgebraMorphism.__init__(self,
                                                   parent,