From: Michael Orlitzky Date: Fri, 2 Aug 2019 20:22:04 +0000 (-0400) Subject: eja: fix construction of subalgebra elements from superalgebra ones. X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=40e1b7a4beee7218ec3131efc2111f3f073184c6;p=sage.d.git eja: fix construction of subalgebra elements from superalgebra ones. --- diff --git a/mjo/eja/eja_subalgebra.py b/mjo/eja/eja_subalgebra.py index 7971e15..5e782cf 100644 --- a/mjo/eja/eja_subalgebra.py +++ b/mjo/eja/eja_subalgebra.py @@ -24,39 +24,6 @@ class FiniteDimensionalEuclideanJordanElementSubalgebraElement(FiniteDimensional True """ - def __init__(self, A, elt): - """ - SETUP:: - - sage: from mjo.eja.eja_algebra import RealSymmetricEJA - sage: from mjo.eja.eja_subalgebra import FiniteDimensionalEuclideanJordanElementSubalgebra - - EXAMPLES:: - - sage: J = RealSymmetricEJA(3) - sage: x = sum( i*J.gens()[i] for i in range(6) ) - sage: K = FiniteDimensionalEuclideanJordanElementSubalgebra(x) - sage: [ K.element_class(K,x^k) for k in range(J.rank()) ] - [f0, f1, f2] - - :: - - """ - if elt in A.superalgebra(): - # Try to convert a parent algebra element into a - # subalgebra element... - try: - coords = A.vector_space().coordinate_vector(elt.to_vector()) - elt = A.from_vector(coords).monomial_coefficients() - except AttributeError: - # Catches a missing method in elt.to_vector() - pass - - s = super(FiniteDimensionalEuclideanJordanElementSubalgebraElement, - self) - - s.__init__(A, elt) - def superalgebra_element(self): """ @@ -75,9 +42,9 @@ class FiniteDimensionalEuclideanJordanElementSubalgebraElement(FiniteDimensional sage: x e0 + e1 + e2 + e3 + e4 + e5 sage: A = x.subalgebra_generated_by() - sage: A.element_class(A,x) + sage: A(x) f1 - sage: A.element_class(A,x).superalgebra_element() + sage: A(x).superalgebra_element() e0 + e1 + e2 + e3 + e4 + e5 TESTS: @@ -88,10 +55,10 @@ class FiniteDimensionalEuclideanJordanElementSubalgebraElement(FiniteDimensional sage: J = random_eja() sage: x = J.random_element() sage: A = x.subalgebra_generated_by() - sage: A.element_class(A,x).superalgebra_element() == x + sage: A(x).superalgebra_element() == x True sage: y = A.random_element() - sage: A.element_class(A,y.superalgebra_element()) == y + sage: A(y.superalgebra_element()) == y True """ @@ -184,6 +151,32 @@ class FiniteDimensionalEuclideanJordanElementSubalgebra(FiniteDimensionalEuclide natural_basis=natural_basis) + def _element_constructor_(self, elt): + """ + Construct an element of this subalgebra from the given one. + The only valid arguments are elements of the parent algebra + that happen to live in this subalgebra. + + SETUP:: + + sage: from mjo.eja.eja_algebra import RealSymmetricEJA + sage: from mjo.eja.eja_subalgebra import FiniteDimensionalEuclideanJordanElementSubalgebra + + EXAMPLES:: + + sage: J = RealSymmetricEJA(3) + sage: x = sum( i*J.gens()[i] for i in range(6) ) + sage: K = FiniteDimensionalEuclideanJordanElementSubalgebra(x) + sage: [ K(x^k) for k in range(J.rank()) ] + [f0, f1, f2] + + :: + + """ + if elt in self.superalgebra(): + coords = self.vector_space().coordinate_vector(elt.to_vector()) + return self.from_vector(coords) + def superalgebra(self): """