From: Michael Orlitzky Date: Thu, 18 Jul 2019 23:44:45 +0000 (-0400) Subject: eja: finally give Euclidean Jordan algebras an inner product. X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=7668f7ca04051e748cc072e6cf3e637e0b4c8861;p=sage.d.git eja: finally give Euclidean Jordan algebras an inner product. --- diff --git a/mjo/eja/euclidean_jordan_algebra.py b/mjo/eja/euclidean_jordan_algebra.py index 8d9b27e..7c1f249 100644 --- a/mjo/eja/euclidean_jordan_algebra.py +++ b/mjo/eja/euclidean_jordan_algebra.py @@ -21,7 +21,8 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): assume_associative=False, category=None, rank=None, - natural_basis=None): + natural_basis=None, + inner_product=None): n = len(mult_table) mult_table = [b.base_extend(field) for b in mult_table] for b in mult_table: @@ -45,7 +46,8 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): names=names, category=cat, rank=rank, - natural_basis=natural_basis) + natural_basis=natural_basis, + inner_product=inner_product) def __init__(self, field, @@ -54,7 +56,8 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): assume_associative=False, category=None, rank=None, - natural_basis=None): + natural_basis=None, + inner_product=None): """ EXAMPLES: @@ -70,6 +73,7 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): """ self._rank = rank self._natural_basis = natural_basis + self._inner_product = inner_product fda = super(FiniteDimensionalEuclideanJordanAlgebra, self) fda.__init__(field, mult_table, @@ -85,6 +89,20 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): return fmt.format(self.degree(), self.base_ring()) + def inner_product(self, x, y): + """ + The inner product associated with this Euclidean Jordan algebra. + + Will default to the trace inner product if nothing else. + """ + if (not x in self) or (not y in self): + raise ArgumentError("arguments must live in this algebra") + if self._inner_product is None: + return x.trace_inner_product(y) + else: + return self._inner_product(x,y) + + def natural_basis(self): """ Return a more-natural representation of this algebra's basis. @@ -208,6 +226,44 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): raise NotImplementedError('irregular element') + def inner_product(self, other): + """ + Return the parent algebra's inner product of myself and ``other``. + + EXAMPLES: + + The inner product in the Jordan spin algebra is the usual + inner product on `R^n` (this example only works because the + basis for the Jordan algebra is the standard basis in `R^n`):: + + sage: J = JordanSpinSimpleEJA(3) + sage: x = vector(QQ,[1,2,3]) + sage: y = vector(QQ,[4,5,6]) + sage: x.inner_product(y) + 32 + sage: J(x).inner_product(J(y)) + 32 + + TESTS: + + Ensure that we can always compute an inner product, and that + it gives us back a real number:: + + sage: set_random_seed() + sage: J = random_eja() + sage: x = J.random_element() + sage: y = J.random_element() + sage: x.inner_product(y) in RR + True + + """ + P = self.parent() + if not other in P: + raise ArgumentError("'other' must live in the same algebra") + + return P.inner_product(self, other) + + def operator_commutes_with(self, other): """ Return whether or not this element operator-commutes @@ -885,7 +941,13 @@ def eja_rn(dimension, field=QQ): Qs = [ matrix(field, dimension, dimension, lambda k,j: 1*(k == j == i)) for i in xrange(dimension) ] - return FiniteDimensionalEuclideanJordanAlgebra(field,Qs,rank=dimension) + # The usual inner product on R^n. + ip = lambda x, y: x.vector().inner_product(y.vector()) + + return FiniteDimensionalEuclideanJordanAlgebra(field, + Qs, + rank=dimension, + inner_product=ip) @@ -1215,13 +1277,6 @@ def JordanSpinSimpleEJA(n, field=QQ): sage: e2*e3 0 - In one dimension, this is the reals under multiplication:: - - sage: J1 = JordanSpinSimpleEJA(1) - sage: J2 = eja_rn(1) - sage: J1 == J2 - True - """ Qs = [] id_matrix = identity_matrix(field, n) @@ -1236,7 +1291,13 @@ def JordanSpinSimpleEJA(n, field=QQ): Qi[0,0] = Qi[0,0] * ~field(2) Qs.append(Qi) + # The usual inner product on R^n. + ip = lambda x, y: x.vector().inner_product(y.vector()) + # The rank of the spin factor algebra is two, UNLESS we're in a # one-dimensional ambient space (the rank is bounded by the # ambient dimension). - return FiniteDimensionalEuclideanJordanAlgebra(field, Qs, rank=min(n,2)) + return FiniteDimensionalEuclideanJordanAlgebra(field, + Qs, + rank=min(n,2), + inner_product=ip)