]> gitweb.michael.orlitzky.com - sage.d.git/commitdiff
eja: allow subalgebra elemenents to be coerced into the superalgebra.
authorMichael Orlitzky <michael@orlitzky.com>
Fri, 12 Mar 2021 13:10:11 +0000 (08:10 -0500)
committerMichael Orlitzky <michael@orlitzky.com>
Fri, 12 Mar 2021 13:10:11 +0000 (08:10 -0500)
mjo/eja/eja_algebra.py

index 5e2c315adbe7730cd7c25f9947ac8ff426f00611..8e522527413b89c0e704687583dc9c4636303170 100644 (file)
@@ -690,8 +690,8 @@ class FiniteDimensionalEJA(CombinatorialFreeModule):
 
     def _element_constructor_(self, elt):
         """
-        Construct an element of this algebra from its vector or matrix
-        representation.
+        Construct an element of this algebra or a subalgebra from its
+        EJA element, vector, or matrix representation.
 
         This gets called only after the parent element _call_ method
         fails to find a coercion for the argument.
@@ -730,6 +730,16 @@ class FiniteDimensionalEJA(CombinatorialFreeModule):
             sage: J( (J1.matrix_basis()[1], J2.matrix_basis()[2]) )
             b1 + b5
 
+        Subalgebra elements are embedded into the superalgebra::
+
+            sage: J = JordanSpinEJA(3)
+            sage: J.one()
+            b0
+            sage: x = sum(J.gens())
+            sage: A = x.subalgebra_generated_by()
+            sage: J(A.one())
+            b0
+
         TESTS:
 
         Ensure that we can convert any element back and forth
@@ -754,6 +764,7 @@ class FiniteDimensionalEJA(CombinatorialFreeModule):
             Traceback (most recent call last):
             ...
             ValueError: not an element of this algebra
+
         """
         msg = "not an element of this algebra"
         if elt in self.base_ring():
@@ -763,6 +774,11 @@ class FiniteDimensionalEJA(CombinatorialFreeModule):
             # that the integer 3 belongs to the space of 2-by-2 matrices.
             raise ValueError(msg)
 
+        if hasattr(elt, 'superalgebra_element'):
+            # Handle subalgebra elements
+            if elt.parent().superalgebra() == self:
+                return elt.superalgebra_element()
+
         try:
             # Try to convert a vector into a column-matrix...
             elt = elt.column()