An element of a Euclidean Jordan algebra.
"""
+ def __init__(self, A, elt=None):
+ """
+ EXAMPLES:
+
+ The identity in `S^n` is converted to the identity in the EJA::
+
+ sage: J = RealSymmetricSimpleEJA(3)
+ sage: I = identity_matrix(QQ,3)
+ sage: J(I) == J.one()
+ True
+
+ This skew-symmetric matrix can't be represented in the EJA::
+
+ sage: J = RealSymmetricSimpleEJA(3)
+ sage: A = matrix(QQ,3, lambda i,j: i-j)
+ sage: J(A)
+ Traceback (most recent call last):
+ ...
+ ArithmeticError: vector is not in free module
+
+ """
+ # Goal: if we're given a matrix, and if it lives in our
+ # parent algebra's "natural ambient space," convert it
+ # into an algebra element.
+ #
+ # The catch is, we make a recursive call after converting
+ # the given matrix into a vector that lives in the algebra.
+ # This we need to try the parent class initializer first,
+ # to avoid recursing forever if we're given something that
+ # already fits into the algebra, but also happens to live
+ # in the parent's "natural ambient space" (this happens with
+ # vectors in R^n).
+ try:
+ FiniteDimensionalAlgebraElement.__init__(self, A, elt)
+ except ValueError:
+ natural_basis = A.natural_basis()
+ if elt in natural_basis[0].matrix_space():
+ # Thanks for nothing! Matrix spaces aren't vector
+ # spaces in Sage, so we have to figure out its
+ # natural-basis coordinates ourselves.
+ V = VectorSpace(elt.base_ring(), elt.nrows()**2)
+ W = V.span( _mat2vec(s) for s in natural_basis )
+ coords = W.coordinates(_mat2vec(elt))
+ FiniteDimensionalAlgebraElement.__init__(self, A, coords)
+
def __pow__(self, n):
"""
Return ``self`` raised to the power ``n``.