]> gitweb.michael.orlitzky.com - sage.d.git/blobdiff - mjo/eja/eja_algebra.py
eja: add a soon-TODO.
[sage.d.git] / mjo / eja / eja_algebra.py
index 34f88010cd31eb8d5cba9446d6dd6ffd2f5a2eaf..eca279f68156ef1cd8e407f2f8ad25661af1e517 100644 (file)
@@ -133,7 +133,7 @@ class FiniteDimensionalEJA(CombinatorialFreeModule):
             deortho_vector_basis = tuple( V(b.list()) for b in basis )
 
             from mjo.eja.eja_utils import gram_schmidt
-            basis = gram_schmidt(basis, inner_product)
+            basis = tuple(gram_schmidt(basis, inner_product))
 
         # Save the (possibly orthonormalized) matrix basis for
         # later...
@@ -158,7 +158,7 @@ class FiniteDimensionalEJA(CombinatorialFreeModule):
 
         # Now we actually compute the multiplication and inner-product
         # tables/matrices using the possibly-orthonormalized basis.
-        self._inner_product_matrix = matrix.zero(field, n)
+        self._inner_product_matrix = matrix.identity(field, n)
         self._multiplication_table = [ [0 for j in range(i+1)]
                                        for i in range(n) ]
 
@@ -171,15 +171,20 @@ class FiniteDimensionalEJA(CombinatorialFreeModule):
                 q_i = basis[i]
                 q_j = basis[j]
 
-                elt = jordan_product(q_i, q_j)
-                ip = inner_product(q_i, q_j)
-
                 # The jordan product returns a matrixy answer, so we
                 # have to convert it to the algebra coordinates.
+                elt = jordan_product(q_i, q_j)
                 elt = W.coordinate_vector(V(elt.list()))
                 self._multiplication_table[i][j] = self.from_vector(elt)
-                self._inner_product_matrix[i,j] = ip
-                self._inner_product_matrix[j,i] = ip
+
+                if not orthonormalize:
+                    # If we're orthonormalizing the basis with respect
+                    # to an inner-product, then the inner-product
+                    # matrix with respect to the resulting basis is
+                    # just going to be the identity.
+                    ip = inner_product(q_i, q_j)
+                    self._inner_product_matrix[i,j] = ip
+                    self._inner_product_matrix[j,i] = ip
 
         self._inner_product_matrix._cache = {'hermitian': True}
         self._inner_product_matrix.set_immutable()
@@ -1256,7 +1261,14 @@ class RationalBasisEJA(FiniteDimensionalEJA):
         a = ( a_i.change_ring(self.base_ring())
               for a_i in self._rational_algebra._charpoly_coefficients() )
 
-        # Now convert the coordinate variables back to the
+        if self._deortho_matrix is None:
+            # This can happen if our base ring was, say, AA and we
+            # chose not to (or didn't need to) orthonormalize. It's
+            # still faster to do the computations over QQ even if
+            # the numbers in the boxes stay the same.
+            return tuple(a)
+
+        # Otherwise, convert the coordinate variables back to the
         # deorthonormalized ones.
         R = self.coordinate_polynomial_ring()
         from sage.modules.free_module_element import vector