"""
from sage.categories.finite_dimensional_algebras_with_basis import FiniteDimensionalAlgebrasWithBasis
+from sage.categories.morphism import SetMorphism
from sage.structure.element import is_Matrix
from sage.structure.category_object import normalize_names
from sage.algebras.finite_dimensional_algebras.finite_dimensional_algebra import FiniteDimensionalAlgebra
from sage.algebras.finite_dimensional_algebras.finite_dimensional_algebra_element import FiniteDimensionalAlgebraElement
-from sage.algebras.finite_dimensional_algebras.finite_dimensional_algebra_morphism import FiniteDimensionalAlgebraMorphism
+from sage.algebras.finite_dimensional_algebras.finite_dimensional_algebra_morphism import FiniteDimensionalAlgebraMorphism, FiniteDimensionalAlgebraHomset
+
+
+class FiniteDimensionalEuclideanJordanAlgebraHomset(FiniteDimensionalAlgebraHomset):
+
+ def has_coerce_map_from(self, S):
+ """
+ EXAMPLES::
+
+ sage: J = RealSymmetricEJA(2)
+ sage: H = J.Hom(J)
+ sage: H.has_coerce_map_from(QQ)
+ True
+
+ """
+ try:
+ # The Homset classes override has_coerce_map_from() with
+ # something that crashes when it's given e.g. QQ.
+ if S.is_subring(self.codomain().base_ring()):
+ return True
+ except:
+ pclass = super(FiniteDimensionalEuclideanJordanAlgebraHomset, self)
+ return pclass.has_coerce_map_from(S)
+
+
+ def _coerce_map_from_(self, S):
+ """
+ EXAMPLES::
+
+ sage: J = RealSymmetricEJA(2)
+ sage: H = J.Hom(J)
+ sage: H.coerce(2)
+ Morphism from Euclidean Jordan algebra of degree 3 over Rational
+ Field to Euclidean Jordan algebra of degree 3 over Rational Field
+ given by matrix
+ [2 0 0]
+ [0 2 0]
+ [0 0 2]
+
+ """
+ C = self.codomain()
+ R = C.base_ring()
+ if S.is_subring(R):
+ h = S.hom(self.codomain())
+ return SetMorphism(Hom(S,C), lambda x: h(x).operator())
+
+
+ def __call__(self, x):
+ """
+ EXAMPLES::
+
+ sage: J = RealSymmetricEJA(2)
+ sage: H = J.Hom(J)
+ sage: H(2)
+ Morphism from Euclidean Jordan algebra of degree 3 over Rational
+ Field to Euclidean Jordan algebra of degree 3 over Rational Field
+ given by matrix
+ [2 0 0]
+ [0 2 0]
+ [0 0 2]
+
+ """
+ if x in self.base_ring():
+ cols = self.domain().dimension()
+ rows = self.codomain().dimension()
+ x = x*identity_matrix(self.codomain().base_ring(), rows, cols)
+ return FiniteDimensionalEuclideanJordanAlgebraMorphism(self, x)
class FiniteDimensionalEuclideanJordanAlgebraMorphism(FiniteDimensionalAlgebraMorphism):
algebra morphism, but they don't seem to be callable on elements of
our EJA, and you can't add/multiply/etc. them.
"""
-
def _add_(self, other):
"""
Add two EJA morphisms in the obvious way.
natural_basis=natural_basis)
+ def _Hom_(self, B, cat):
+ """
+ Construct a homset of ``self`` and ``B``.
+ """
+ return FiniteDimensionalEuclideanJordanAlgebraHomset(self,
+ B,
+ category=cat)
+
+
def __init__(self,
field,
mult_table,