From: Michael Orlitzky Date: Sun, 21 Jul 2019 02:48:12 +0000 (-0400) Subject: eja: turn the other simple EJA constructors into classes. X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=2cfb1e2864c14542d101334bac962000f85e017d;p=sage.d.git eja: turn the other simple EJA constructors into classes. --- diff --git a/mjo/eja/euclidean_jordan_algebra.py b/mjo/eja/euclidean_jordan_algebra.py index fa112a3..3248162 100644 --- a/mjo/eja/euclidean_jordan_algebra.py +++ b/mjo/eja/euclidean_jordan_algebra.py @@ -133,7 +133,7 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): EXAMPLES:: - sage: J = RealSymmetricSimpleEJA(2) + sage: J = RealSymmetricEJA(2) sage: J.basis() Family (e0, e1, e2) sage: J.natural_basis() @@ -181,14 +181,14 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): The identity in `S^n` is converted to the identity in the EJA:: - sage: J = RealSymmetricSimpleEJA(3) + sage: J = RealSymmetricEJA(3) sage: I = identity_matrix(QQ,3) sage: J(I) == J.one() True This skew-symmetric matrix can't be represented in the EJA:: - sage: J = RealSymmetricSimpleEJA(3) + sage: J = RealSymmetricEJA(3) sage: A = matrix(QQ,3, lambda i,j: i-j) sage: J(A) Traceback (most recent call last): @@ -309,7 +309,7 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): so the inner product of the identity matrix with itself should be the `n`:: - sage: J = RealSymmetricSimpleEJA(3) + sage: J = RealSymmetricEJA(3) sage: J.one().inner_product(J.one()) 3 @@ -318,13 +318,13 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): part because the product of Hermitian matrices may not be Hermitian:: - sage: J = ComplexHermitianSimpleEJA(3) + sage: J = ComplexHermitianEJA(3) sage: J.one().inner_product(J.one()) 3 Ditto for the quaternions:: - sage: J = QuaternionHermitianSimpleEJA(3) + sage: J = QuaternionHermitianEJA(3) sage: J.one().inner_product(J.one()) 3 @@ -670,7 +670,7 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): EXAMPLES:: - sage: J = ComplexHermitianSimpleEJA(3) + sage: J = ComplexHermitianEJA(3) sage: J.one() e0 + e5 + e8 sage: J.one().natural_representation() @@ -683,7 +683,7 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): :: - sage: J = QuaternionHermitianSimpleEJA(3) + sage: J = QuaternionHermitianEJA(3) sage: J.one() e0 + e9 + e14 sage: J.one().natural_representation() @@ -1086,9 +1086,9 @@ def random_eja(): n = ZZ.random_element(1,5) constructor = choice([eja_rn, JordanSpinEJA, - RealSymmetricSimpleEJA, - ComplexHermitianSimpleEJA, - QuaternionHermitianSimpleEJA]) + RealSymmetricEJA, + ComplexHermitianEJA, + QuaternionHermitianEJA]) return constructor(n, field=QQ) @@ -1465,7 +1465,7 @@ def _matrix_ip(X,Y): return (X_mat*Y_mat).trace() -def RealSymmetricSimpleEJA(n, field=QQ): +class RealSymmetricEJA(FiniteDimensionalEuclideanJordanAlgebra): """ The rank-n simple EJA consisting of real symmetric n-by-n matrices, the usual symmetric Jordan product, and the trace inner @@ -1473,7 +1473,7 @@ def RealSymmetricSimpleEJA(n, field=QQ): EXAMPLES:: - sage: J = RealSymmetricSimpleEJA(2) + sage: J = RealSymmetricEJA(2) sage: e0, e1, e2 = J.gens() sage: e0*e0 e0 @@ -1488,7 +1488,7 @@ def RealSymmetricSimpleEJA(n, field=QQ): sage: set_random_seed() sage: n = ZZ.random_element(1,5) - sage: J = RealSymmetricSimpleEJA(n) + sage: J = RealSymmetricEJA(n) sage: J.degree() == (n^2 + n)/2 True @@ -1496,7 +1496,7 @@ def RealSymmetricSimpleEJA(n, field=QQ): sage: set_random_seed() sage: n = ZZ.random_element(1,5) - sage: J = RealSymmetricSimpleEJA(n) + sage: J = RealSymmetricEJA(n) sage: x = J.random_element() sage: y = J.random_element() sage: actual = (x*y).natural_representation() @@ -1509,17 +1509,23 @@ def RealSymmetricSimpleEJA(n, field=QQ): True """ - S = _real_symmetric_basis(n, field=field) - (Qs, T) = _multiplication_table_from_matrix_basis(S) + @staticmethod + def __classcall_private__(cls, n, field=QQ): + S = _real_symmetric_basis(n, field=field) + (Qs, T) = _multiplication_table_from_matrix_basis(S) - return FiniteDimensionalEuclideanJordanAlgebra(field, - Qs, - rank=n, - natural_basis=T, - inner_product=_matrix_ip) + fdeja = super(RealSymmetricEJA, cls) + return fdeja.__classcall_private__(cls, + field, + Qs, + rank=n, + natural_basis=T) + + def inner_product(self, x, y): + return _matrix_ip(x,y) -def ComplexHermitianSimpleEJA(n, field=QQ): +class ComplexHermitianEJA(FiniteDimensionalEuclideanJordanAlgebra): """ The rank-n simple EJA consisting of complex Hermitian n-by-n matrices over the real numbers, the usual symmetric Jordan product, @@ -1532,7 +1538,7 @@ def ComplexHermitianSimpleEJA(n, field=QQ): sage: set_random_seed() sage: n = ZZ.random_element(1,5) - sage: J = ComplexHermitianSimpleEJA(n) + sage: J = ComplexHermitianEJA(n) sage: J.degree() == n^2 True @@ -1540,7 +1546,7 @@ def ComplexHermitianSimpleEJA(n, field=QQ): sage: set_random_seed() sage: n = ZZ.random_element(1,5) - sage: J = ComplexHermitianSimpleEJA(n) + sage: J = ComplexHermitianEJA(n) sage: x = J.random_element() sage: y = J.random_element() sage: actual = (x*y).natural_representation() @@ -1553,26 +1559,30 @@ def ComplexHermitianSimpleEJA(n, field=QQ): True """ - S = _complex_hermitian_basis(n) - (Qs, T) = _multiplication_table_from_matrix_basis(S) + @staticmethod + def __classcall_private__(cls, n, field=QQ): + S = _complex_hermitian_basis(n) + (Qs, T) = _multiplication_table_from_matrix_basis(S) - # Since a+bi on the diagonal is represented as - # - # a + bi = [ a b ] - # [ -b a ], - # - # we'll double-count the "a" entries if we take the trace of - # the embedding. - ip = lambda X,Y: _matrix_ip(X,Y)/2 + fdeja = super(ComplexHermitianEJA, cls) + return fdeja.__classcall_private__(cls, + field, + Qs, + rank=n, + natural_basis=T) - return FiniteDimensionalEuclideanJordanAlgebra(field, - Qs, - rank=n, - natural_basis=T, - inner_product=ip) + def inner_product(self, x, y): + # Since a+bi on the diagonal is represented as + # + # a + bi = [ a b ] + # [ -b a ], + # + # we'll double-count the "a" entries if we take the trace of + # the embedding. + return _matrix_ip(x,y)/2 -def QuaternionHermitianSimpleEJA(n, field=QQ): +class QuaternionHermitianEJA(FiniteDimensionalEuclideanJordanAlgebra): """ The rank-n simple EJA consisting of self-adjoint n-by-n quaternion matrices, the usual symmetric Jordan product, and the @@ -1585,7 +1595,7 @@ def QuaternionHermitianSimpleEJA(n, field=QQ): sage: set_random_seed() sage: n = ZZ.random_element(1,5) - sage: J = QuaternionHermitianSimpleEJA(n) + sage: J = QuaternionHermitianEJA(n) sage: J.degree() == 2*(n^2) - n True @@ -1593,7 +1603,7 @@ def QuaternionHermitianSimpleEJA(n, field=QQ): sage: set_random_seed() sage: n = ZZ.random_element(1,5) - sage: J = QuaternionHermitianSimpleEJA(n) + sage: J = QuaternionHermitianEJA(n) sage: x = J.random_element() sage: y = J.random_element() sage: actual = (x*y).natural_representation() @@ -1606,33 +1616,30 @@ def QuaternionHermitianSimpleEJA(n, field=QQ): True """ - S = _quaternion_hermitian_basis(n) - (Qs, T) = _multiplication_table_from_matrix_basis(S) + @staticmethod + def __classcall_private__(cls, n, field=QQ): + S = _quaternion_hermitian_basis(n) + (Qs, T) = _multiplication_table_from_matrix_basis(S) - # Since a+bi+cj+dk on the diagonal is represented as - # - # a + bi +cj + dk = [ a b c d] - # [ -b a -d c] - # [ -c d a -b] - # [ -d -c b a], - # - # we'll quadruple-count the "a" entries if we take the trace of - # the embedding. - ip = lambda X,Y: _matrix_ip(X,Y)/4 - - return FiniteDimensionalEuclideanJordanAlgebra(field, - Qs, - rank=n, - natural_basis=T, - inner_product=ip) + fdeja = super(QuaternionHermitianEJA, cls) + return fdeja.__classcall_private__(cls, + field, + Qs, + rank=n, + natural_basis=T) + def inner_product(self, x, y): + # Since a+bi+cj+dk on the diagonal is represented as + # + # a + bi +cj + dk = [ a b c d] + # [ -b a -d c] + # [ -c d a -b] + # [ -d -c b a], + # + # we'll quadruple-count the "a" entries if we take the trace of + # the embedding. + return _matrix_ip(x,y)/4 -def OctonionHermitianSimpleEJA(n): - """ - This shit be crazy. It has dimension 27 over the reals. - """ - n = 3 - pass class JordanSpinEJA(FiniteDimensionalEuclideanJordanAlgebra): """