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):
"""
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:
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
"""
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):
"""