From: Michael Orlitzky Date: Fri, 26 Jul 2019 23:56:33 +0000 (-0400) Subject: eja: create our own Homset class for EJAs (ugh). X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=7929fc4e6fcfaa44e89e37a5233977581cb171a8;p=sage.d.git eja: create our own Homset class for EJAs (ugh). --- diff --git a/mjo/eja/euclidean_jordan_algebra.py b/mjo/eja/euclidean_jordan_algebra.py index 9414d2c..848fc57 100644 --- a/mjo/eja/euclidean_jordan_algebra.py +++ b/mjo/eja/euclidean_jordan_algebra.py @@ -6,12 +6,79 @@ what can be supported in a general Jordan Algebra. """ 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): @@ -38,7 +105,6 @@ class FiniteDimensionalEuclideanJordanAlgebraMorphism(FiniteDimensionalAlgebraMo 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. @@ -300,6 +366,15 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): 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,