From: Michael Orlitzky Date: Fri, 12 Mar 2021 13:10:11 +0000 (-0500) Subject: eja: allow subalgebra elemenents to be coerced into the superalgebra. X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=da6160ad4c8156d51290fd056aa7d5b3d609c8e9;p=sage.d.git eja: allow subalgebra elemenents to be coerced into the superalgebra. --- diff --git a/mjo/eja/eja_algebra.py b/mjo/eja/eja_algebra.py index 5e2c315..8e52252 100644 --- a/mjo/eja/eja_algebra.py +++ b/mjo/eja/eja_algebra.py @@ -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()