]> gitweb.michael.orlitzky.com - sage.d.git/commitdiff
eja: finally get scalar-morphism multiplication working with the new homsets.
authorMichael Orlitzky <michael@orlitzky.com>
Fri, 26 Jul 2019 23:57:04 +0000 (19:57 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Mon, 29 Jul 2019 03:19:01 +0000 (23:19 -0400)
mjo/eja/euclidean_jordan_algebra.py

index 848fc57ae7eea635ba0f014e74b8de64938c6dbe..cc356dc0ff7e6a94186d4d809ae937c01f0a3e6c 100644 (file)
@@ -152,7 +152,7 @@ class FiniteDimensionalEuclideanJordanAlgebraMorphism(FiniteDimensionalAlgebraMo
                                                   check=False)
 
 
-    def _invert_(self):
+    def __invert__(self):
         """
         EXAMPLES::
 
@@ -190,25 +190,48 @@ class FiniteDimensionalEuclideanJordanAlgebraMorphism(FiniteDimensionalAlgebraMo
         return FiniteDimensionalEuclideanJordanAlgebraMorphism(self.parent(),
                                                                 A.inverse())
 
-    def _lmul_(self, other):
+    def _lmul_(self, right):
         """
         Compose two EJA morphisms using multiplicative notation.
 
         EXAMPLES::
 
-            sage: J = RealSymmetricEJA(3)
+            sage: J = RealSymmetricEJA(2)
             sage: x = J.zero()
             sage: y = J.one()
             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
+            Morphism from Euclidean Jordan algebra of degree 3 over Rational
+            Field to Euclidean Jordan algebra of degree 3 over Rational Field
+            given by matrix
+            [0 0 0]
+            [0 0 0]
+            [0 0 0]
+
+        ::
+
+            sage: J = RealSymmetricEJA(2)
+            sage: x = J.linear_combination(zip(range(len(J.gens())), J.gens()))
+            sage: x.operator()
+            Morphism from Euclidean Jordan algebra of degree 3 over Rational
+            Field to Euclidean Jordan algebra of degree 3 over Rational Field
+            given by matrix
+            [  0   1   0]
+            [1/2   1 1/2]
+            [  0   1   2]
+            sage: 2*x.operator()
+            Morphism from Euclidean Jordan algebra of degree 3 over Rational
+            Field to Euclidean Jordan algebra of degree 3 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]
+            [0 2 0]
+            [1 2 1]
+            [0 2 4]
+            sage: x.operator()*2
+            Morphism from Euclidean Jordan algebra of degree 3 over Rational
+            Field to Euclidean Jordan algebra of degree 3 over Rational Field
+            given by matrix
+            [0 2 0]
+            [1 2 1]
+            [0 2 4]
 
         TESTS::
 
@@ -220,12 +243,21 @@ class FiniteDimensionalEuclideanJordanAlgebraMorphism(FiniteDimensionalAlgebraMo
             True
 
         """
-        if not other.codomain() is self.domain():
+        try:
+            # I think the morphism classes break the coercion framework
+            # somewhere along the way, so we have to do this ourselves.
+            right = self.parent().coerce(right)
+        except:
+            pass
+
+        if not right.codomain() is self.domain():
             raise ValueError("(co)domains must agree for composition")
 
         return FiniteDimensionalEuclideanJordanAlgebraMorphism(
-                  self.parent(),
-                  self.matrix()*other.matrix() )
+                 self.parent(),
+                 self.matrix()*right.matrix() )
+
+    __mul__ = _lmul_
 
 
     def _neg_(self):