From b82bd087507b8f727c10ca0eb55f9a1d15ed3438 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Sat, 20 Jul 2019 23:03:20 -0400 Subject: [PATCH] eja: turn the eja_rn() constructor into a class too. This fixes the inner product issue I created in the previous commit. We can always get rid of this class when real Cartesian products are supported. --- mjo/eja/euclidean_jordan_algebra.py | 50 ++++++++++++++--------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/mjo/eja/euclidean_jordan_algebra.py b/mjo/eja/euclidean_jordan_algebra.py index e109b52..15ff26c 100644 --- a/mjo/eja/euclidean_jordan_algebra.py +++ b/mjo/eja/euclidean_jordan_algebra.py @@ -922,7 +922,7 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): TESTS:: sage: set_random_seed() - sage: J = eja_rn(5) + sage: J = RealCartesianProductEJA(5) sage: c = J.random_element().subalgebra_idempotent() sage: c^2 == c True @@ -1006,16 +1006,20 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): return (self*other).trace() -def eja_rn(dimension, field=QQ): +class RealCartesianProductEJA(FiniteDimensionalEuclideanJordanAlgebra): """ Return the Euclidean Jordan Algebra corresponding to the set `R^n` under the Hadamard product. + Note: this is nothing more than the Cartesian product of ``n`` + copies of the spin algebra. Once Cartesian product algebras + are implemented, this can go. + EXAMPLES: This multiplication table can be verified by hand:: - sage: J = eja_rn(3) + sage: J = RealCartesianProductEJA(3) sage: e0,e1,e2 = J.gens() sage: e0*e0 e0 @@ -1031,18 +1035,21 @@ def eja_rn(dimension, field=QQ): e2 """ - # The FiniteDimensionalAlgebra constructor takes a list of - # matrices, the ith representing right multiplication by the ith - # basis element in the vector space. So if e_1 = (1,0,0), then - # right (Hadamard) multiplication of x by e_1 picks out the first - # component of x; and likewise for the ith basis element e_i. - Qs = [ matrix(field, dimension, dimension, lambda k,j: 1*(k == j == i)) - for i in xrange(dimension) ] + @staticmethod + def __classcall_private__(cls, n, field=QQ): + # The FiniteDimensionalAlgebra constructor takes a list of + # matrices, the ith representing right multiplication by the ith + # basis element in the vector space. So if e_1 = (1,0,0), then + # right (Hadamard) multiplication of x by e_1 picks out the first + # component of x; and likewise for the ith basis element e_i. + Qs = [ matrix(field, n, n, lambda k,j: 1*(k == j == i)) + for i in xrange(n) ] - return FiniteDimensionalEuclideanJordanAlgebra(field, - Qs, - rank=dimension) + fdeja = super(RealCartesianProductEJA, cls) + return fdeja.__classcall_private__(cls, field, Qs, rank=n) + def inner_product(self, x, y): + return _usual_ip(x,y) def random_eja(): @@ -1078,7 +1085,7 @@ def random_eja(): """ n = ZZ.random_element(1,5) - constructor = choice([eja_rn, + constructor = choice([RealCartesianProductEJA, JordanSpinEJA, RealSymmetricEJA, ComplexHermitianEJA, @@ -1679,18 +1686,11 @@ class JordanSpinEJA(FiniteDimensionalEuclideanJordanAlgebra): Qi[0,0] = Qi[0,0] * ~field(2) Qs.append(Qi) + # The rank of the spin algebra is two, unless we're in a + # one-dimensional ambient space (because the rank is bounded by + # the ambient dimension). fdeja = super(JordanSpinEJA, cls) - return fdeja.__classcall_private__(cls, field, Qs) - - def rank(self): - """ - Return the rank of this Jordan Spin Algebra. - - The rank of the spin algebra is two, unless we're in a - one-dimensional ambient space (because the rank is bounded by - the ambient dimension). - """ - return min(self.dimension(),2) + return fdeja.__classcall_private__(cls, field, Qs, rank=min(n,2)) def inner_product(self, x, y): return _usual_ip(x,y) -- 2.44.2