]> gitweb.michael.orlitzky.com - sage.d.git/blobdiff - mjo/eja/euclidean_jordan_algebra.py
eja: add more quadratic representation tests.
[sage.d.git] / mjo / eja / euclidean_jordan_algebra.py
index 0a53667c36284d3a07a218f30e37fae8334861a9..87a0ca0592b8103ec3410fef57a1134f26a0bf9b 100644 (file)
@@ -323,7 +323,7 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra):
             return elt.minimal_polynomial()
 
 
-        def quadratic_representation(self):
+        def quadratic_representation(self, other=None):
             """
             Return the quadratic representation of this element.
 
@@ -332,6 +332,7 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra):
             The explicit form in the spin factor algebra is given by
             Alizadeh's Example 11.12::
 
+                sage: set_random_seed()
                 sage: n = ZZ.random_element(1,10).abs()
                 sage: J = JordanSpinSimpleEJA(n)
                 sage: x = J.random_element()
@@ -348,8 +349,55 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra):
                 sage: Q == x.quadratic_representation()
                 True
 
+            Test all of the properties from Theorem 11.2 in Alizadeh::
+
+                sage: set_random_seed()
+                sage: J = random_eja()
+                sage: x = J.random_element()
+                sage: y = J.random_element()
+
+            Property 1:
+
+                sage: actual = x.quadratic_representation(y)
+                sage: expected = ( (x+y).quadratic_representation()
+                ....:              -x.quadratic_representation()
+                ....:              -y.quadratic_representation() ) / 2
+                sage: actual == expected
+                True
+
+            Property 2:
+
+                sage: alpha = QQ.random_element()
+                sage: actual = (alpha*x).quadratic_representation()
+                sage: expected = (alpha^2)*x.quadratic_representation()
+                sage: actual == expected
+                True
+
+            Property 5:
+
+                sage: Qy = y.quadratic_representation()
+                sage: actual = J(Qy*x.vector()).quadratic_representation()
+                sage: expected = Qy*x.quadratic_representation()*Qy
+                sage: actual == expected
+                True
+
+            Property 6:
+
+                sage: k = ZZ.random_element(1,10).abs()
+                sage: actual = (x^k).quadratic_representation()
+                sage: expected = (x.quadratic_representation())^k
+                sage: actual == expected
+                True
+
             """
-            return 2*(self.matrix()**2) - (self**2).matrix()
+            if other is None:
+                other=self
+            elif not other in self.parent():
+                raise ArgumentError("'other' must live in the same algebra")
+
+            return ( self.matrix()*other.matrix()
+                       + other.matrix()*self.matrix()
+                       - (self*other).matrix() )
 
 
         def span_of_powers(self):
@@ -604,6 +652,43 @@ def _real_symmetric_basis(n, field=QQ):
     return S
 
 
+def _complex_hermitian_basis(n, field=QQ):
+    """
+    Returns a basis for the space of complex Hermitian n-by-n matrices.
+
+    TESTS::
+
+        sage: set_random_seed()
+        sage: n = ZZ.random_element(1,5).abs()
+        sage: all( M.is_symmetric() for M in _complex_hermitian_basis(n) )
+        True
+
+    """
+    F = QuadraticField(-1, 'I')
+    I = F.gen()
+
+    # This is like the symmetric case, but we need to be careful:
+    #
+    #   * We want conjugate-symmetry, not just symmetry.
+    #   * The diagonal will (as a result) be real.
+    #
+    S = []
+    for i in xrange(n):
+        for j in xrange(i+1):
+            Eij = matrix(field, n, lambda k,l: k==i and l==j)
+            if i == j:
+                Sij = _embed_complex_matrix(Eij)
+                S.append(Sij)
+            else:
+                # Beware, orthogonal but not normalized! The second one
+                # has a minus because it's conjugated.
+                Sij_real = _embed_complex_matrix(Eij + Eij.transpose())
+                S.append(Sij_real)
+                Sij_imag = _embed_complex_matrix(I*Eij - I*Eij.transpose())
+                S.append(Sij_imag)
+    return S
+
+
 def _multiplication_table_from_matrix_basis(basis):
     """
     At least three of the five simple Euclidean Jordan algebras have the
@@ -745,6 +830,17 @@ def RealSymmetricSimpleEJA(n, field=QQ):
         e0 + e2
         sage: e2*e2
         e2
+
+    TESTS:
+
+    The degree of this algebra is `(n^2 + n) / 2`::
+
+        sage: set_random_seed()
+        sage: n = ZZ.random_element(1,5).abs()
+        sage: J = RealSymmetricSimpleEJA(n)
+        sage: J.degree() == (n^2 + n)/2
+        True
+
     """
     S = _real_symmetric_basis(n, field=field)
     Qs = _multiplication_table_from_matrix_basis(S)
@@ -756,20 +852,25 @@ def ComplexHermitianSimpleEJA(n, field=QQ):
     """
     The rank-n simple EJA consisting of complex Hermitian n-by-n
     matrices over the real numbers, the usual symmetric Jordan product,
-    and the real-part-of-trace inner product. It has dimension `n^2 over
+    and the real-part-of-trace inner product. It has dimension `n^2` over
     the reals.
+
+    TESTS:
+
+    The degree of this algebra is `n^2`::
+
+        sage: set_random_seed()
+        sage: n = ZZ.random_element(1,5).abs()
+        sage: J = ComplexHermitianSimpleEJA(n)
+        sage: J.degree() == n^2
+        True
+
     """
-    F = QuadraticField(-1, 'i')
-    i = F.gen()
-    S = _real_symmetric_basis(n, field=F)
-    T = []
-    for s in S:
-        T.append(s)
-        T.append(i*s)
-    embed_T = [ _embed_complex_matrix(t) for t in T ]
-    Qs = _multiplication_table_from_matrix_basis(embed_T)
+    S = _complex_hermitian_basis(n)
+    Qs = _multiplication_table_from_matrix_basis(S)
     return FiniteDimensionalEuclideanJordanAlgebra(field, Qs, rank=n)
 
+
 def QuaternionHermitianSimpleEJA(n):
     """
     The rank-n simple EJA consisting of self-adjoint n-by-n quaternion