X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=mjo%2Feja%2Feuclidean_jordan_algebra.py;h=5f01556b0f0cecf52437f0a115ab343cbeeb2b18;hb=ca41a63e824257c972f275e4b47e474adf13bc2e;hp=8bd10cc493e130364aea3971d2c5f9ce5910803b;hpb=d4abbb9559730285a79574ccbabe18ff28dad585;p=sage.d.git diff --git a/mjo/eja/euclidean_jordan_algebra.py b/mjo/eja/euclidean_jordan_algebra.py index 8bd10cc..5f01556 100644 --- a/mjo/eja/euclidean_jordan_algebra.py +++ b/mjo/eja/euclidean_jordan_algebra.py @@ -11,6 +11,258 @@ 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 + + +class FiniteDimensionalEuclideanJordanAlgebraMorphism(FiniteDimensionalAlgebraMorphism): + """ + A linear map between two finite-dimensional EJAs. + + This is a very thin wrapper around FiniteDimensionalAlgebraMorphism + that does only a few things: + + 1. Avoids the ``unitary`` and ``check`` arguments to the constructor + that will always be ``False``. This is necessary because these + are homomorphisms with respect to ADDITION, but the SageMath + machinery wants to check that they're homomorphisms with respect + to (Jordan) MULTIPLICATION. That obviously doesn't work. + + 2. Inputs and outputs the underlying matrix with respect to COLUMN + vectors, unlike the parent class. + + 3. Allows us to add, subtract, negate, multiply (compose), and + invert morphisms in the obvious way. + + If this seems a bit heavyweight, it is. I would have been happy to + use a the ring morphism that underlies the finite-dimensional + 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. + + EXAMPLES:: + + sage: J = RealSymmetricEJA(3) + sage: x = J.zero() + sage: y = J.one() + sage: x.operator() + y.operator() + Morphism from Euclidean Jordan algebra of degree 6 over Rational + Field to Euclidean Jordan algebra of degree 6 over Rational Field + given by matrix + [1 0 0 0 0 0] + [0 1 0 0 0 0] + [0 0 1 0 0 0] + [0 0 0 1 0 0] + [0 0 0 0 1 0] + [0 0 0 0 0 1] + + TESTS:: + + sage: set_random_seed() + sage: J = random_eja() + sage: x = J.random_element() + sage: y = J.random_element() + sage: (x.operator() + y.operator()) in J.Hom(J) + True + + """ + P = self.parent() + if not other in P: + raise ValueError("summands must live in the same space") + + return FiniteDimensionalEuclideanJordanAlgebraMorphism( + P, + self.matrix() + other.matrix() ) + + + def __init__(self, parent, f): + FiniteDimensionalAlgebraMorphism.__init__(self, + parent, + f.transpose(), + unitary=False, + check=False) + + + def __invert__(self): + """ + EXAMPLES:: + + sage: J = RealSymmetricEJA(2) + sage: x = J.linear_combination(zip(range(len(J.gens())), J.gens())) + sage: x.is_invertible() + True + sage: ~x.operator() + Morphism from Euclidean Jordan algebra of degree 3 over Rational + Field to Euclidean Jordan algebra of degree 3 over Rational Field + given by matrix + [-3/2 2 -1/2] + [ 1 0 0] + [-1/2 0 1/2] + sage: x.operator_matrix().inverse() + [-3/2 2 -1/2] + [ 1 0 0] + [-1/2 0 1/2] + + TESTS:: + + sage: set_random_seed() + sage: J = random_eja() + sage: x = J.random_element() + sage: not x.is_invertible() or ( + ....: (~x.operator()).matrix() == x.operator_matrix().inverse() ) + True + + """ + A = self.matrix() + if not A.is_invertible(): + raise ValueError("morphism is not invertible") + + P = self.parent() + return FiniteDimensionalEuclideanJordanAlgebraMorphism(self.parent(), + A.inverse()) + + def __mul__(self, other): + """ + Compose two EJA morphisms using multiplicative notation. + + EXAMPLES:: + + sage: J = RealSymmetricEJA(3) + sage: x = J.zero() + sage: y = J.one() + sage: x.operator() * y.operator() + Morphism from Euclidean Jordan algebra of degree 6 over Rational + Field to Euclidean Jordan algebra of degree 6 over Rational Field + given by matrix + [0 0 0 0 0 0] + [0 0 0 0 0 0] + [0 0 0 0 0 0] + [0 0 0 0 0 0] + [0 0 0 0 0 0] + [0 0 0 0 0 0] + + TESTS:: + + sage: set_random_seed() + sage: J = random_eja() + sage: x = J.random_element() + sage: y = J.random_element() + sage: (x.operator() * y.operator()) in J.Hom(J) + True + + """ + if not other.codomain() is self.domain(): + raise ValueError("(co)domains must agree for composition") + + return FiniteDimensionalEuclideanJordanAlgebraMorphism( + self.parent(), + self.matrix()*other.matrix() ) + + + def __neg__(self): + """ + Negate this morphism. + + EXAMPLES:: + + sage: J = RealSymmetricEJA(2) + sage: x = J.one() + sage: -x.operator() + Morphism from Euclidean Jordan algebra of degree 3 over Rational + Field to Euclidean Jordan algebra of degree 3 over Rational Field + given by matrix + [-1 0 0] + [ 0 -1 0] + [ 0 0 -1] + + TESTS:: + + sage: set_random_seed() + sage: J = random_eja() + sage: x = J.random_element() + sage: -x.operator() in J.Hom(J) + True + + """ + return FiniteDimensionalEuclideanJordanAlgebraMorphism( + self.parent(), + -self.matrix() ) + + + def _repr_(self): + """ + We override only the representation that is shown to the user, + because we want the matrix to be with respect to COLUMN vectors. + + TESTS: + + Ensure that we see the transpose of the underlying matrix object: + + sage: J = RealSymmetricEJA(3) + sage: x = J.linear_combination(zip(range(len(J.gens())), J.gens())) + sage: L = x.operator() + sage: L + Morphism from Euclidean Jordan algebra of degree 6 over Rational + Field to Euclidean Jordan algebra of degree 6 over Rational Field + given by matrix + [ 0 1 2 0 0 0] + [1/2 3/2 2 1/2 1 0] + [ 1 2 5/2 0 1/2 1] + [ 0 1 0 3 4 0] + [ 0 1 1/2 2 4 2] + [ 0 0 2 0 4 5] + sage: L._matrix + [ 0 1/2 1 0 0 0] + [ 1 3/2 2 1 1 0] + [ 2 2 5/2 0 1/2 2] + [ 0 1/2 0 3 2 0] + [ 0 1 1/2 4 4 4] + [ 0 0 1 0 2 5] + + """ + return "Morphism from {} to {} given by matrix\n{}".format( + self.domain(), self.codomain(), self.matrix()) + + + def __sub__(self, other): + """ + Subtract one morphism from another using addition and negation. + + EXAMPLES:: + + sage: J = RealSymmetricEJA(2) + sage: L1 = J.one().operator() + sage: L1 - L1 + Morphism from Euclidean Jordan algebra of degree 3 over Rational + Field to Euclidean Jordan algebra of degree 3 over Rational + Field given by matrix + [0 0 0] + [0 0 0] + [0 0 0] + + TESTS:: + + sage: set_random_seed() + sage: J = random_eja() + sage: x = J.random_element() + sage: y = J.random_element() + sage: x.operator() - y.operator() in J.Hom(J) + True + + """ + return self + (-other) + + + def matrix(self): + """ + Return the matrix of this morphism with respect to a left-action + on column vectors. + """ + return FiniteDimensionalAlgebraMorphism.matrix(self).transpose() + class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): @staticmethod @@ -1003,6 +1255,30 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): return W.linear_combination(zip(self.vector(), B)) + def operator(self): + """ + Return the left-multiplication-by-this-element + operator on the ambient algebra. + + TESTS:: + + sage: set_random_seed() + sage: J = random_eja() + sage: x = J.random_element() + sage: y = J.random_element() + sage: x.operator()(y) == x*y + True + sage: y.operator()(x) == x*y + True + + """ + P = self.parent() + return FiniteDimensionalEuclideanJordanAlgebraMorphism( + Hom(P,P), + self.operator_matrix() ) + + + def operator_matrix(self): """ Return the matrix that represents left- (or right-)