]> gitweb.michael.orlitzky.com - sage.d.git/commitdiff
eja: fix powers of zero for operators.
authorMichael Orlitzky <michael@orlitzky.com>
Sat, 27 Jul 2019 00:44:42 +0000 (20:44 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Mon, 29 Jul 2019 03:19:01 +0000 (23:19 -0400)
When you raise a morphism to the power of zero, it returns an object
(the identity morphism) in a much more general and useless space. We
need to be able to add/subtract these things. So now we have our own
one() method for the Homset, and our own __pow__ for morphisms.

mjo/eja/euclidean_jordan_algebra.py

index 713eca534b1028dadddf4bb6e99953de0d6b1cd0..0b50c233279ee576ea59c6953fbf5c58ca64fb35 100644 (file)
@@ -81,6 +81,18 @@ class FiniteDimensionalEuclideanJordanAlgebraHomset(FiniteDimensionalAlgebraHoms
         return FiniteDimensionalEuclideanJordanAlgebraMorphism(self, x)
 
 
+    def one(self):
+        """
+        Return the identity morphism, but as a member of the right
+        space (so that we can add it, multiply it, etc.)
+        """
+        cols = self.domain().dimension()
+        rows = self.codomain().dimension()
+        mat = identity_matrix(self.base_ring(), rows, cols)
+        return FiniteDimensionalEuclideanJordanAlgebraMorphism(self, mat)
+
+
+
 class FiniteDimensionalEuclideanJordanAlgebraMorphism(FiniteDimensionalAlgebraMorphism):
     """
     A linear map between two finite-dimensional EJAs.
@@ -260,6 +272,37 @@ class FiniteDimensionalEuclideanJordanAlgebraMorphism(FiniteDimensionalAlgebraMo
     __mul__ = _lmul_
 
 
+    def __pow__(self, n):
+        """
+
+        TESTS::
+
+            sage: J = JordanSpinEJA(4)
+            sage: e0,e1,e2,e3 = J.gens()
+            sage: x = -5/2*e0 + 1/2*e2 + 20*e3
+            sage: Qx = x.quadratic_representation()
+            sage: Qx^0
+            Morphism from Euclidean Jordan algebra of degree 4 over Rational
+            Field to Euclidean Jordan algebra of degree 4 over Rational Field
+            given by matrix
+            [1 0 0 0]
+            [0 1 0 0]
+            [0 0 1 0]
+            [0 0 0 1]
+            sage: (x^0).quadratic_representation() == Qx^0
+            True
+
+        """
+        if n == 0:
+            # We get back the stupid identity morphism which doesn't
+            # live in the right space.
+            return self.parent().one()
+        elif n == 1:
+            return self
+        else:
+            return FiniteDimensionalAlgebraMorphism.__pow__(self,n)
+
+
     def _neg_(self):
         """
         Negate this morphism.