]> gitweb.michael.orlitzky.com - sage.d.git/blobdiff - mjo/eja/eja_algebra.py
eja: reword two existing tests.
[sage.d.git] / mjo / eja / eja_algebra.py
index d0e7b074ce41a00f66d6f6dcd487653f3a8b1674..4acf513d3a8aa6b498621af5908b11363f77d420 100644 (file)
@@ -60,6 +60,9 @@ class FiniteDimensionalEuclideanJordanAlgebra(CombinatorialFreeModule):
         self._rank = rank
         self._natural_basis = natural_basis
 
+        # TODO: HACK for the charpoly.. needs redesign badly.
+        self._basis_normalizers = None
+
         if category is None:
             category = MagmaticAlgebras(field).FiniteDimensional()
             category = category.WithBasis().Unital()
@@ -224,6 +227,7 @@ class FiniteDimensionalEuclideanJordanAlgebra(CombinatorialFreeModule):
         return V.span_of_basis(b)
 
 
+
     @cached_method
     def _charpoly_coeff(self, i):
         """
@@ -234,6 +238,19 @@ class FiniteDimensionalEuclideanJordanAlgebra(CombinatorialFreeModule):
         store the trace/determinant (a_{r-1} and a_{0} respectively)
         separate from the entire characteristic polynomial.
         """
+        if self._basis_normalizers is not None:
+             # Must be a matrix class?
+             # WARNING/TODO: this whole mess is mis-designed.
+             n = self.natural_basis_space().nrows()
+             field = self.base_ring().base_ring() # yeeeeaaaahhh
+             J = self.__class__(n, field, False)
+             (_,x,_,_) = J._charpoly_matrix_system()
+             p = J._charpoly_coeff(i)
+             # p might be missing some vars, have to substitute "optionally"
+             pairs = zip(x.base_ring().gens(), self._basis_normalizers)
+             substitutions = { v: v*c for (v,c) in pairs }
+             return p.subs(substitutions)
+
         (A_of_x, x, xr, detA) = self._charpoly_matrix_system()
         R = A_of_x.base_ring()
         if i >= self.rank():
@@ -924,7 +941,7 @@ def _complex_hermitian_basis(n, field):
 
 
 
-def _quaternion_hermitian_basis(n, field, normalize):
+def _quaternion_hermitian_basis(n, field):
     """
     Returns a basis for the space of quaternion Hermitian n-by-n matrices.
 
@@ -942,7 +959,7 @@ def _quaternion_hermitian_basis(n, field, normalize):
 
         sage: set_random_seed()
         sage: n = ZZ.random_element(1,5)
-        sage: B = _quaternion_hermitian_basis(n, QQ, False)
+        sage: B = _quaternion_hermitian_basis(n, QQ)
         sage: all( M.is_symmetric() for M in B )
         True
 
@@ -1308,7 +1325,8 @@ class RealSymmetricEJA(FiniteDimensionalEuclideanJordanAlgebra):
         sage: (x*y).inner_product(z) == y.inner_product(x*z)
         True
 
-    Our basis is normalized with respect to the natural inner product::
+    Our natural basis is normalized with respect to the natural inner
+    product unless we specify otherwise::
 
         sage: set_random_seed()
         sage: n = ZZ.random_element(1,5)
@@ -1316,8 +1334,11 @@ class RealSymmetricEJA(FiniteDimensionalEuclideanJordanAlgebra):
         sage: all( b.norm() == 1 for b in J.gens() )
         True
 
-    Left-multiplication operators are symmetric because they satisfy
-    the Jordan axiom::
+    Since our natural basis is normalized with respect to the natural
+    inner product, and since we know that this algebra is an EJA, any
+    left-multiplication operator's matrix will be symmetric because
+    natural->EJA basis representation is an isometry and within the EJA
+    the operator is self-adjoint by the Jordan axiom::
 
         sage: set_random_seed()
         sage: n = ZZ.random_element(1,5)
@@ -1339,10 +1360,10 @@ class RealSymmetricEJA(FiniteDimensionalEuclideanJordanAlgebra):
             if p.is_irreducible():
                 field = NumberField(p, 'sqrt2', embedding=RLF(2).sqrt())
             S = [ s.change_ring(field) for s in S ]
-            self._basis_denormalizers = tuple(
-                self.__class__.natural_inner_product(s,s).sqrt()
+            self._basis_normalizers = tuple(
+                ~(self.__class__.natural_inner_product(s,s).sqrt())
                 for s in S )
-            S = tuple( s/c for (s,c) in zip(S,self._basis_denormalizers) )
+            S = tuple( s*c for (s,c) in zip(S,self._basis_normalizers) )
 
         Qs = _multiplication_table_from_matrix_basis(S)
 
@@ -1408,7 +1429,8 @@ class ComplexHermitianEJA(FiniteDimensionalEuclideanJordanAlgebra):
         sage: (x*y).inner_product(z) == y.inner_product(x*z)
         True
 
-    Our basis is normalized with respect to the natural inner product::
+    Our natural basis is normalized with respect to the natural inner
+    product unless we specify otherwise::
 
         sage: set_random_seed()
         sage: n = ZZ.random_element(1,4)
@@ -1416,8 +1438,11 @@ class ComplexHermitianEJA(FiniteDimensionalEuclideanJordanAlgebra):
         sage: all( b.norm() == 1 for b in J.gens() )
         True
 
-    Left-multiplication operators are symmetric because they satisfy
-    the Jordan axiom::
+    Since our natural basis is normalized with respect to the natural
+    inner product, and since we know that this algebra is an EJA, any
+    left-multiplication operator's matrix will be symmetric because
+    natural->EJA basis representation is an isometry and within the EJA
+    the operator is self-adjoint by the Jordan axiom::
 
         sage: set_random_seed()
         sage: n = ZZ.random_element(1,5)
@@ -1439,10 +1464,10 @@ class ComplexHermitianEJA(FiniteDimensionalEuclideanJordanAlgebra):
             if p.is_irreducible():
                 field = NumberField(p, 'sqrt2', embedding=RLF(2).sqrt())
             S = [ s.change_ring(field) for s in S ]
-            self._basis_denormalizers = tuple(
-                self.__class__.natural_inner_product(s,s).sqrt()
+            self._basis_normalizers = tuple(
+                ~(self.__class__.natural_inner_product(s,s).sqrt())
                 for s in S )
-            S = tuple( s/c for (s,c) in zip(S,self._basis_denormalizers) )
+            S = tuple( s*c for (s,c) in zip(S,self._basis_normalizers) )
 
         Qs = _multiplication_table_from_matrix_basis(S)