From cd6b8ef2dd49e7a91ff21689cc4396d1e994b8e0 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Sat, 20 Jul 2019 21:53:20 -0400 Subject: [PATCH] eja: turn the spin algebra constructor into a subclass. --- mjo/eja/euclidean_jordan_algebra.py | 88 +++++++++++++++-------------- 1 file changed, 46 insertions(+), 42 deletions(-) diff --git a/mjo/eja/euclidean_jordan_algebra.py b/mjo/eja/euclidean_jordan_algebra.py index 24eaf50..579be23 100644 --- a/mjo/eja/euclidean_jordan_algebra.py +++ b/mjo/eja/euclidean_jordan_algebra.py @@ -50,7 +50,8 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): inner_product=inner_product) - def __init__(self, field, + def __init__(self, + field, mult_table, names='e', assume_associative=False, @@ -143,7 +144,7 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): :: - sage: J = JordanSpinSimpleEJA(2) + sage: J = JordanSpinAlgebra(2) sage: J.basis() Family (e0, e1) sage: J.natural_basis() @@ -295,7 +296,7 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): 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: J = JordanSpinAlgebra(3) sage: x = vector(QQ,[1,2,3]) sage: y = vector(QQ,[4,5,6]) sage: x.inner_product(y) @@ -390,12 +391,12 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): EXAMPLES:: - sage: J = JordanSpinSimpleEJA(2) + sage: J = JordanSpinAlgebra(2) sage: e0,e1 = J.gens() sage: x = e0 + e1 sage: x.det() 0 - sage: J = JordanSpinSimpleEJA(3) + sage: J = JordanSpinAlgebra(3) sage: e0,e1,e2 = J.gens() sage: x = e0 + e1 + e2 sage: x.det() @@ -424,7 +425,7 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): sage: set_random_seed() sage: n = ZZ.random_element(1,10) - sage: J = JordanSpinSimpleEJA(n) + sage: J = JordanSpinAlgebra(n) sage: x = J.random_element() sage: while x.is_zero(): ....: x = J.random_element() @@ -554,7 +555,7 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): The identity element always has degree one, but any element linearly-independent from it is regular:: - sage: J = JordanSpinSimpleEJA(5) + sage: J = JordanSpinAlgebra(5) sage: J.one().is_regular() False sage: e0, e1, e2, e3, e4 = J.gens() # e0 is the identity @@ -579,7 +580,7 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): EXAMPLES:: - sage: J = JordanSpinSimpleEJA(4) + sage: J = JordanSpinAlgebra(4) sage: J.one().degree() 1 sage: e0,e1,e2,e3 = J.gens() @@ -591,7 +592,7 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): sage: set_random_seed() sage: n = ZZ.random_element(1,10) - sage: J = JordanSpinSimpleEJA(n) + sage: J = JordanSpinAlgebra(n) sage: x = J.random_element() sage: x == x.coefficient(0)*J.one() or x.degree() == 2 True @@ -623,7 +624,7 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): sage: set_random_seed() sage: n = ZZ.random_element(2,10) - sage: J = JordanSpinSimpleEJA(n) + sage: J = JordanSpinAlgebra(n) sage: y = J.random_element() sage: while y == y.coefficient(0)*J.one(): ....: y = J.random_element() @@ -783,7 +784,7 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): sage: set_random_seed() sage: n = ZZ.random_element(1,10) - sage: J = JordanSpinSimpleEJA(n) + sage: J = JordanSpinAlgebra(n) sage: x = J.random_element() sage: x_vec = x.vector() sage: x0 = x_vec[0] @@ -930,7 +931,7 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): sage: c = J.random_element().subalgebra_idempotent() sage: c^2 == c True - sage: J = JordanSpinSimpleEJA(5) + sage: J = JordanSpinAlgebra(5) sage: c = J.random_element().subalgebra_idempotent() sage: c^2 == c True @@ -986,7 +987,7 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): EXAMPLES:: - sage: J = JordanSpinSimpleEJA(3) + sage: J = JordanSpinAlgebra(3) sage: e0,e1,e2 = J.gens() sage: x = e0 + e1 + e2 sage: x.trace() @@ -1084,7 +1085,7 @@ def random_eja(): """ n = ZZ.random_element(1,5) constructor = choice([eja_rn, - JordanSpinSimpleEJA, + JordanSpinAlgebra, RealSymmetricSimpleEJA, ComplexHermitianSimpleEJA, QuaternionHermitianSimpleEJA]) @@ -1633,7 +1634,7 @@ def OctonionHermitianSimpleEJA(n): n = 3 pass -def JordanSpinSimpleEJA(n, field=QQ): +class JordanSpinAlgebra(FiniteDimensionalEuclideanJordanAlgebra): """ The rank-2 simple EJA consisting of real vectors ``x=(x0, x_bar)`` with the usual inner product and jordan product ``x*y = @@ -1644,7 +1645,7 @@ def JordanSpinSimpleEJA(n, field=QQ): This multiplication table can be verified by hand:: - sage: J = JordanSpinSimpleEJA(4) + sage: J = JordanSpinAlgebra(4) sage: e0,e1,e2,e3 = J.gens() sage: e0*e0 e0 @@ -1661,31 +1662,34 @@ def JordanSpinSimpleEJA(n, field=QQ): sage: e2*e3 0 - In one dimension, this is the reals under multiplication:: + """ + @staticmethod + def __classcall_private__(cls, n, field=QQ): + Qs = [] + id_matrix = identity_matrix(field, n) + for i in xrange(n): + ei = id_matrix.column(i) + Qi = zero_matrix(field, n) + Qi.set_row(0, ei) + Qi.set_column(0, ei) + Qi += diagonal_matrix(n, [ei[0]]*n) + # The addition of the diagonal matrix adds an extra ei[0] in the + # upper-left corner of the matrix. + Qi[0,0] = Qi[0,0] * ~field(2) + Qs.append(Qi) + + fdeja = super(JordanSpinAlgebra, cls) + return fdeja.__classcall_private__(cls, field, Qs) - sage: J1 = JordanSpinSimpleEJA(1) - sage: J2 = eja_rn(1) - sage: J1 == J2 - True + def rank(self): + """ + Return the rank of this Jordan Spin Algebra. - """ - Qs = [] - id_matrix = identity_matrix(field, n) - for i in xrange(n): - ei = id_matrix.column(i) - Qi = zero_matrix(field, n) - Qi.set_row(0, ei) - Qi.set_column(0, ei) - Qi += diagonal_matrix(n, [ei[0]]*n) - # The addition of the diagonal matrix adds an extra ei[0] in the - # upper-left corner of the matrix. - Qi[0,0] = Qi[0,0] * ~field(2) - Qs.append(Qi) - - # 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), - inner_product=_usual_ip) + 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) + + def inner_product(self, x, y): + return _usual_ip(x,y) -- 2.44.2