X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=mjo%2Feja%2Feja_element.py;h=03376bda408b8fde98597ca8e8669e7e72a3e81a;hb=517fbc3c451b7b3914d455653bccf2ec647dbc30;hp=107603ce712ecf79d6de89a2e4fd573f17738798;hpb=9c35b8d70e384cd98b8ec7eb7a84cf84db1d1137;p=sage.d.git diff --git a/mjo/eja/eja_element.py b/mjo/eja/eja_element.py index 107603c..03376bd 100644 --- a/mjo/eja/eja_element.py +++ b/mjo/eja/eja_element.py @@ -25,69 +25,6 @@ class FiniteDimensionalEuclideanJordanAlgebraElement(IndexedFreeModuleElement): dir(self.__class__) ) - def __init__(self, A, elt): - """ - - SETUP:: - - sage: from mjo.eja.eja_algebra import (RealSymmetricEJA, - ....: random_eja) - - EXAMPLES: - - The identity in `S^n` is converted to the identity in the EJA:: - - sage: J = RealSymmetricEJA(3) - sage: I = matrix.identity(QQ,3) - sage: J(I) == J.one() - True - - This skew-symmetric matrix can't be represented in the EJA:: - - sage: J = RealSymmetricEJA(3) - sage: A = matrix(QQ,3, lambda i,j: i-j) - sage: J(A) - Traceback (most recent call last): - ... - ArithmeticError: vector is not in free module - - TESTS: - - Ensure that we can convert any element of the parent's - underlying vector space back into an algebra element whose - vector representation is what we started with:: - - sage: set_random_seed() - sage: J = random_eja() - sage: v = J.vector_space().random_element() - sage: J(v).to_vector() == v - True - - """ - # Goal: if we're given a matrix, and if it lives in our - # parent algebra's "natural ambient space," convert it - # into an algebra element. - # - # The catch is, we make a recursive call after converting - # the given matrix into a vector that lives in the algebra. - # This we need to try the parent class initializer first, - # to avoid recursing forever if we're given something that - # already fits into the algebra, but also happens to live - # in the parent's "natural ambient space" (this happens with - # vectors in R^n). - ifme = super(FiniteDimensionalEuclideanJordanAlgebraElement, self) - try: - ifme.__init__(A, elt) - except ValueError: - natural_basis = A.natural_basis() - if elt in natural_basis[0].matrix_space(): - # Thanks for nothing! Matrix spaces aren't vector - # spaces in Sage, so we have to figure out its - # natural-basis coordinates ourselves. - V = VectorSpace(elt.base_ring(), elt.nrows()**2) - W = V.span( _mat2vec(s) for s in natural_basis ) - coords = W.coordinate_vector(_mat2vec(elt)) - ifme.__init__(A, coords) def __pow__(self, n): @@ -228,6 +165,21 @@ class FiniteDimensionalEuclideanJordanAlgebraElement(IndexedFreeModuleElement): sage: x.apply_univariate_polynomial(p) 0 + The characteristic polynomials of the zero and unit elements + should be what we think they are in a subalgebra, too:: + + sage: J = RealCartesianProductEJA(3) + sage: p1 = J.one().characteristic_polynomial() + sage: q1 = J.zero().characteristic_polynomial() + sage: e0,e1,e2 = J.gens() + sage: A = (e0 + 2*e1 + 3*e2).subalgebra_generated_by() # dim 3 + sage: p2 = A.one().characteristic_polynomial() + sage: q2 = A.zero().characteristic_polynomial() + sage: p1 == p2 + True + sage: q1 == q2 + True + """ p = self.parent().characteristic_polynomial() return p(*self.to_vector()) @@ -257,7 +209,7 @@ class FiniteDimensionalEuclideanJordanAlgebraElement(IndexedFreeModuleElement): sage: y = vector(QQ,[4,5,6]) sage: x.inner_product(y) 32 - sage: J(x).inner_product(J(y)) + sage: J.from_vector(x).inner_product(J.from_vector(y)) 32 The inner product on `S^n` is ` = trace(X*Y)`, where @@ -431,6 +383,16 @@ class FiniteDimensionalEuclideanJordanAlgebraElement(IndexedFreeModuleElement): sage: x.is_invertible() == (x.det() != 0) True + Ensure that the determinant is multiplicative on an associative + subalgebra as in Faraut and Koranyi's Proposition II.2.2:: + + sage: set_random_seed() + sage: J = random_eja().random_element().subalgebra_generated_by() + sage: x = J.random_element() + sage: y = J.random_element() + sage: (x*y).det() == x.det()*y.det() + True + """ P = self.parent() r = P.rank() @@ -473,7 +435,7 @@ class FiniteDimensionalEuclideanJordanAlgebraElement(IndexedFreeModuleElement): 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) + sage: x.inverse() == J.from_vector(x_inverse) True TESTS: @@ -545,15 +507,23 @@ class FiniteDimensionalEuclideanJordanAlgebraElement(IndexedFreeModuleElement): sage: J.one().is_invertible() True - The zero element is never invertible:: + The zero element is never invertible in a non-trivial algebra:: sage: set_random_seed() sage: J = random_eja() - sage: J.zero().is_invertible() + sage: (not J.is_trivial()) and J.zero().is_invertible() False """ - zero = self.parent().zero() + if self.is_zero(): + if self.parent().is_trivial(): + return True + else: + return False + + # In fact, we only need to know if the constant term is non-zero, + # so we can pass in the field's zero element instead. + zero = self.base_ring().zero() p = self.minimal_polynomial() return not (p(zero) == zero) @@ -706,6 +676,11 @@ class FiniteDimensionalEuclideanJordanAlgebraElement(IndexedFreeModuleElement): True """ + if self.is_zero() and not self.parent().is_trivial(): + # The minimal polynomial of zero in a nontrivial algebra + # is "t"; in a trivial algebra it's "1" by convention + # (it's an empty product). + return 1 return self.subalgebra_generated_by().dimension() @@ -734,6 +709,7 @@ class FiniteDimensionalEuclideanJordanAlgebraElement(IndexedFreeModuleElement): SETUP:: sage: from mjo.eja.eja_algebra import (JordanSpinEJA, + ....: RealSymmetricEJA, ....: random_eja) TESTS: @@ -783,9 +759,35 @@ class FiniteDimensionalEuclideanJordanAlgebraElement(IndexedFreeModuleElement): sage: x.apply_univariate_polynomial(p) 0 + The minimal polynomial is invariant under a change of basis, + and in particular, a re-scaling of the basis:: + + sage: set_random_seed() + sage: n = ZZ.random_element(1,5).abs() + sage: J1 = RealSymmetricEJA(n) + sage: J2 = RealSymmetricEJA(n,QQ,False) + sage: X = random_matrix(QQ,n) + sage: X = X*X.transpose() + sage: x1 = J1(X) + sage: x2 = J2(X) + sage: x1.minimal_polynomial() == x2.minimal_polynomial() + True + """ + if self.is_zero(): + # We would generate a zero-dimensional subalgebra + # where the minimal polynomial would be constant. + # That might be correct, but only if *this* algebra + # is trivial too. + if not self.parent().is_trivial(): + # Pretty sure we know what the minimal polynomial of + # the zero operator is going to be. This ensures + # consistency of e.g. the polynomial variable returned + # in the "normal" case without us having to think about it. + return self.operator().minimal_polynomial() + A = self.subalgebra_generated_by() - return A.element_class(A,self).operator().minimal_polynomial() + return A(self).operator().minimal_polynomial() @@ -808,7 +810,7 @@ class FiniteDimensionalEuclideanJordanAlgebraElement(IndexedFreeModuleElement): sage: J = ComplexHermitianEJA(3) sage: J.one() - e0 + e5 + e8 + e0 + e3 + e8 sage: J.one().natural_representation() [1 0 0 0 0 0] [0 1 0 0 0 0] @@ -821,7 +823,7 @@ class FiniteDimensionalEuclideanJordanAlgebraElement(IndexedFreeModuleElement): sage: J = QuaternionHermitianEJA(3) sage: J.one() - e0 + e9 + e14 + e0 + e5 + e14 sage: J.one().natural_representation() [1 0 0 0 0 0 0 0 0 0 0 0] [0 1 0 0 0 0 0 0 0 0 0 0] @@ -838,10 +840,37 @@ class FiniteDimensionalEuclideanJordanAlgebraElement(IndexedFreeModuleElement): """ B = self.parent().natural_basis() - W = B[0].matrix_space() + W = self.parent().natural_basis_space() return W.linear_combination(zip(B,self.to_vector())) + def norm(self): + """ + The norm of this element with respect to :meth:`inner_product`. + + SETUP:: + + sage: from mjo.eja.eja_algebra import (JordanSpinEJA, + ....: RealCartesianProductEJA) + + EXAMPLES:: + + sage: J = RealCartesianProductEJA(2) + sage: x = sum(J.gens()) + sage: x.norm() + sqrt(2) + + :: + + sage: J = JordanSpinEJA(4) + sage: x = sum(J.gens()) + sage: x.norm() + 2 + + """ + return self.inner_product(self).sqrt() + + def operator(self): """ Return the left-multiplication-by-this-element @@ -864,10 +893,12 @@ class FiniteDimensionalEuclideanJordanAlgebraElement(IndexedFreeModuleElement): """ P = self.parent() + left_mult_by_self = lambda y: self*y + L = P.module_morphism(function=left_mult_by_self, codomain=P) return FiniteDimensionalEuclideanJordanAlgebraOperator( P, P, - self.to_matrix() ) + L.matrix() ) def quadratic_representation(self, other=None): @@ -923,7 +954,7 @@ class FiniteDimensionalEuclideanJordanAlgebraElement(IndexedFreeModuleElement): Property 2 (multiply on the right for :trac:`28272`): - sage: alpha = QQ.random_element() + sage: alpha = J.base_ring().random_element() sage: (alpha*x).quadratic_representation() == Qx*(alpha^2) True @@ -1001,11 +1032,17 @@ class FiniteDimensionalEuclideanJordanAlgebraElement(IndexedFreeModuleElement): sage: from mjo.eja.eja_algebra import random_eja - TESTS:: + TESTS: + + This subalgebra, being composed of only powers, is associative:: sage: set_random_seed() - sage: x = random_eja().random_element() - sage: x.subalgebra_generated_by().is_associative() + sage: x0 = random_eja().random_element() + sage: A = x0.subalgebra_generated_by() + sage: x = A.random_element() + sage: y = A.random_element() + sage: z = A.random_element() + sage: (x*y)*z == x*(y*z) True Squaring in the subalgebra should work the same as in @@ -1017,6 +1054,15 @@ class FiniteDimensionalEuclideanJordanAlgebraElement(IndexedFreeModuleElement): sage: A(x^2) == A(x)*A(x) True + The subalgebra generated by the zero element is trivial:: + + sage: set_random_seed() + sage: A = random_eja().zero().subalgebra_generated_by() + sage: A + Euclidean Jordan algebra of dimension 0 over... + sage: A.one() + 0 + """ return FiniteDimensionalEuclideanJordanElementSubalgebra(self) @@ -1071,7 +1117,7 @@ class FiniteDimensionalEuclideanJordanAlgebraElement(IndexedFreeModuleElement): # Our FiniteDimensionalAlgebraElement superclass uses rows. u_next = u**(s+1) A = u_next.operator().matrix() - c = J(A.solve_right(u_next.to_vector())) + c = J.from_vector(A.solve_right(u_next.to_vector())) # Now c is the idempotent we want, but it still lives in the subalgebra. return c.superalgebra_element() @@ -1145,7 +1191,7 @@ class FiniteDimensionalEuclideanJordanAlgebraElement(IndexedFreeModuleElement): sage: x = J.random_element() sage: y = J.random_element() sage: z = J.random_element() - sage: a = QQ.random_element(); + sage: a = J.base_ring().random_element(); sage: actual = (a*(x+z)).trace_inner_product(y) sage: expected = ( a*x.trace_inner_product(y) + ....: a*z.trace_inner_product(y) ) @@ -1173,3 +1219,30 @@ class FiniteDimensionalEuclideanJordanAlgebraElement(IndexedFreeModuleElement): raise TypeError("'other' must live in the same algebra") return (self*other).trace() + + + def trace_norm(self): + """ + The norm of this element with respect to :meth:`trace_inner_product`. + + SETUP:: + + sage: from mjo.eja.eja_algebra import (JordanSpinEJA, + ....: RealCartesianProductEJA) + + EXAMPLES:: + + sage: J = RealCartesianProductEJA(2) + sage: x = sum(J.gens()) + sage: x.trace_norm() + sqrt(2) + + :: + + sage: J = JordanSpinEJA(4) + sage: x = sum(J.gens()) + sage: x.trace_norm() + 2*sqrt(2) + + """ + return self.trace_inner_product(self).sqrt()