X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=mjo%2Feja%2Feuclidean_jordan_algebra.py;h=30d04f4a352b7d553470bd456d18d224e2ec5428;hb=31baec0eee0c53b0cfe379c744cdf174aa57ebd9;hp=848fc57ae7eea635ba0f014e74b8de64938c6dbe;hpb=7929fc4e6fcfaa44e89e37a5233977581cb171a8;p=sage.d.git diff --git a/mjo/eja/euclidean_jordan_algebra.py b/mjo/eja/euclidean_jordan_algebra.py index 848fc57..30d04f4 100644 --- a/mjo/eja/euclidean_jordan_algebra.py +++ b/mjo/eja/euclidean_jordan_algebra.py @@ -81,6 +81,18 @@ class FiniteDimensionalEuclideanJordanAlgebraHomset(FiniteDimensionalAlgebraHoms return FiniteDimensionalEuclideanJordanAlgebraMorphism(self, x) + def one(self): + """ + Return the identity morphism, but as a member of the right + space (so that we can add it, multiply it, etc.) + """ + cols = self.domain().dimension() + rows = self.codomain().dimension() + mat = identity_matrix(self.base_ring(), rows, cols) + return FiniteDimensionalEuclideanJordanAlgebraMorphism(self, mat) + + + class FiniteDimensionalEuclideanJordanAlgebraMorphism(FiniteDimensionalAlgebraMorphism): """ A linear map between two finite-dimensional EJAs. @@ -152,7 +164,7 @@ class FiniteDimensionalEuclideanJordanAlgebraMorphism(FiniteDimensionalAlgebraMo check=False) - def _invert_(self): + def __invert__(self): """ EXAMPLES:: @@ -190,25 +202,48 @@ class FiniteDimensionalEuclideanJordanAlgebraMorphism(FiniteDimensionalAlgebraMo return FiniteDimensionalEuclideanJordanAlgebraMorphism(self.parent(), A.inverse()) - def _lmul_(self, other): + def _lmul_(self, right): """ Compose two EJA morphisms using multiplicative notation. EXAMPLES:: - sage: J = RealSymmetricEJA(3) + sage: J = RealSymmetricEJA(2) 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 + 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 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] + + :: + + sage: J = RealSymmetricEJA(2) + sage: x = J.linear_combination(zip(range(len(J.gens())), J.gens())) + 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 + [ 0 1 0] + [1/2 1 1/2] + [ 0 1 2] + sage: 2*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 + [0 2 0] + [1 2 1] + [0 2 4] + sage: x.operator()*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 + [0 2 0] + [1 2 1] + [0 2 4] TESTS:: @@ -220,12 +255,52 @@ class FiniteDimensionalEuclideanJordanAlgebraMorphism(FiniteDimensionalAlgebraMo True """ - if not other.codomain() is self.domain(): + try: + # I think the morphism classes break the coercion framework + # somewhere along the way, so we have to do this ourselves. + right = self.parent().coerce(right) + except: + pass + + if not right.codomain() is self.domain(): raise ValueError("(co)domains must agree for composition") return FiniteDimensionalEuclideanJordanAlgebraMorphism( - self.parent(), - self.matrix()*other.matrix() ) + self.parent(), + self.matrix()*right.matrix() ) + + __mul__ = _lmul_ + + + def __pow__(self, n): + """ + + TESTS:: + + sage: J = JordanSpinEJA(4) + sage: e0,e1,e2,e3 = J.gens() + sage: x = -5/2*e0 + 1/2*e2 + 20*e3 + sage: Qx = x.quadratic_representation() + sage: Qx^0 + Morphism from Euclidean Jordan algebra of degree 4 over Rational + Field to Euclidean Jordan algebra of degree 4 over Rational Field + given by matrix + [1 0 0 0] + [0 1 0 0] + [0 0 1 0] + [0 0 0 1] + sage: (x^0).quadratic_representation() == Qx^0 + True + + """ + if n == 0: + # We get back the stupid identity morphism which doesn't + # live in the right space. + return self.parent().one() + elif n == 1: + return self + else: + return FiniteDimensionalAlgebraMorphism.__pow__(self,n) def _neg_(self): @@ -1009,12 +1084,12 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): sage: n = ZZ.random_element(1,10) sage: J = JordanSpinEJA(n) sage: x = J.random_element() - sage: while x.is_zero(): + sage: while not x.is_invertible(): ....: x = J.random_element() sage: x_vec = x.vector() sage: x0 = x_vec[0] sage: x_bar = x_vec[1:] - sage: coeff = 1/(x0^2 - x_bar.inner_product(x_bar)) + sage: coeff = ~(x0^2 - x_bar.inner_product(x_bar)) sage: inv_vec = x_vec.parent()([x0] + (-x_bar).list()) sage: x_inverse = coeff*inv_vec sage: x.inverse() == J(x_inverse) @@ -1057,8 +1132,7 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): if not self.is_invertible(): raise ValueError("element is not invertible") - P = self.parent() - return P(self.quadratic_representation().inverse()*self.vector()) + return (~self.quadratic_representation())(self) def is_invertible(self): @@ -1443,7 +1517,7 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): sage: D = (x0^2 - x_bar.inner_product(x_bar))*D sage: D = D + 2*x_bar.tensor_product(x_bar) sage: Q = block_matrix(2,2,[A,B,C,D]) - sage: Q == x.quadratic_representation().operator_matrix() + sage: Q == x.quadratic_representation().matrix() True Test all of the properties from Theorem 11.2 in Alizadeh::