From 5c433ba91c916e1451708ce18815dd19e1ab5b08 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Fri, 26 Jul 2019 12:31:01 -0400 Subject: [PATCH] eja: allow addition of EJA morphisms. --- mjo/eja/euclidean_jordan_algebra.py | 37 +++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/mjo/eja/euclidean_jordan_algebra.py b/mjo/eja/euclidean_jordan_algebra.py index 72e167e..b239dc7 100644 --- a/mjo/eja/euclidean_jordan_algebra.py +++ b/mjo/eja/euclidean_jordan_algebra.py @@ -17,7 +17,7 @@ from sage.algebras.finite_dimensional_algebras.finite_dimensional_algebra_morphi class FiniteDimensionalEuclideanJordanAlgebraMorphism(FiniteDimensionalAlgebraMorphism): """ A very thin wrapper around FiniteDimensionalAlgebraMorphism that - does only two things: + does only three things: 1. Avoids the ``unitary`` and ``check`` arguments to the constructor that will always be ``False``. This is necessary because these @@ -28,11 +28,44 @@ class FiniteDimensionalEuclideanJordanAlgebraMorphism(FiniteDimensionalAlgebraMo 2. Inputs and outputs the underlying matrix with respect to COLUMN vectors, unlike the parent class. + 3. Allows us to add 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. + our EJA, and you can't add 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.zero() + 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] + + """ + 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, -- 2.44.2