]> gitweb.michael.orlitzky.com - sage.d.git/commitdiff
eja: get a rudimentary spectral decomposition for operators working.
authorMichael Orlitzky <michael@orlitzky.com>
Fri, 30 Aug 2019 02:48:51 +0000 (22:48 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Fri, 30 Aug 2019 02:48:51 +0000 (22:48 -0400)
mjo/eja/TODO
mjo/eja/eja_operator.py
mjo/eja/eja_utils.py

index b2495b59f3264e5d638a59f6630daa77214cdb50..985e50a8dbbfc2d6f8c8d2e80d445fcd9b3ccd86 100644 (file)
@@ -8,12 +8,3 @@
 
 5. Factor out the unit-norm basis (and operator symmetry) tests once
    all of the algebras pass.
-
-6. Implement spectral projector decomposition for EJA operators
-   using jordan_form() or eigenmatrix_right(). I suppose we can
-   ignore the problem of base rings for now and just let it crash
-   if we're not using AA as our base field.
-
-7. Do we really need to orthonormalize the basis in a subalgebra?
-   So long as we can decompose the operator (which is invariant
-   under changes of basis), who cares?
index 0e898b59fb9d8a99090da6f4baec3e49df51d9cd..c32ff1ed7c2ba0aa87c842e5545f9bf204f43fac 100644 (file)
@@ -426,3 +426,43 @@ class FiniteDimensionalEuclideanJordanAlgebraOperator(Map):
         """
         # The matrix method returns a polynomial in 'x' but want one in 't'.
         return self.matrix().minimal_polynomial().change_variable_name('t')
+
+
+    def spectral_decomposition(self):
+        """
+        Return the spectral decomposition of this operator as a list of
+        (eigenvalue, orthogonal projector) pairs.
+
+        SETUP::
+
+            sage: from mjo.eja.eja_algebra import RealSymmetricEJA
+
+        EXAMPLES::
+
+            sage: J = RealSymmetricEJA(4,AA)
+            sage: x = sum(J.gens())
+            sage: A = x.subalgebra_generated_by(orthonormalize_basis=True)
+            sage: L0x = A(x).operator()
+            sage: Ps = [ P*l for (l,P) in L0x.spectral_decomposition() ]
+            sage: Ps[0] + Ps[1] == L0x
+            True
+
+        """
+        if not self.matrix().is_symmetric():
+            raise ValueError('algebra basis is not orthonormal')
+
+        D,P = self.matrix().jordan_form(subdivide=False,transformation=True)
+        eigenvalues = D.diagonal()
+        us = P.columns()
+        projectors = []
+        for i in range(len(us)):
+            # they won't be normalized, but they have to be
+            # for the spectral theorem to work.
+            us[i] = us[i]/us[i].norm()
+            mat = us[i].column()*us[i].row()
+            Pi = FiniteDimensionalEuclideanJordanAlgebraOperator(
+                   self.domain(),
+                   self.codomain(),
+                   mat)
+            projectors.append(Pi)
+        return zip(eigenvalues, projectors)
index d486b4c604723b2a3e8544c2cf2644edb733d713..cf75e325697dcefb3bf682b855f8d83e3e4f89e2 100644 (file)
@@ -26,11 +26,11 @@ def gram_schmidt(v):
         sage: u = gram_schmidt(v)
         sage: all( u_i.inner_product(u_i).sqrt() == 1 for u_i in u )
         True
-        sage: u[0].inner_product(u[1]) == 0
+        sage: bool(u[0].inner_product(u[1]) == 0)
         True
-        sage: u[0].inner_product(u[2]) == 0
+        sage: bool(u[0].inner_product(u[2]) == 0)
         True
-        sage: u[1].inner_product(u[2]) == 0
+        sage: bool(u[1].inner_product(u[2]) == 0)
         True
 
     TESTS:
@@ -67,29 +67,10 @@ def gram_schmidt(v):
     # And now drop all zero vectors again if they were "orthogonalized out."
     v = [ v_i for v_i in v if not v_i.is_zero() ]
 
-    # Now pretend to normalize, building a new ring R that contains
-    # all of the necessary square roots.
-    norms_squared = [0]*len(v)
-
-    for i in xrange(len(v)):
-        norms_squared[i] = v[i].inner_product(v[i])
-        ns = [norms_squared[i].numerator(), norms_squared[i].denominator()]
-
-        # Do the numerator and denominator separately so that we
-        # adjoin e.g. sqrt(2) and sqrt(3) instead of sqrt(2/3).
-        for j in xrange(len(ns)):
-            PR = PolynomialRing(R, 'z')
-            z = PR.gen()
-            p = z**2 - ns[j]
-            if p.is_irreducible():
-                R = NumberField(p,
-                                'sqrt' + str(ns[j]),
-                                embedding=RLF(ns[j]).sqrt())
-
-    # When we're done, we have to change every element's ring to the
-    # extension that we wound up with, and then normalize it (which
-    # should work, since "R" contains its norm now).
+    # Just normalize. If the algebra is missing the roots, we can't add
+    # them here because then our subalgebra would have a bigger field
+    # than the superalgebra.
     for i in xrange(len(v)):
-        v[i] = v[i].change_ring(R) / R(norms_squared[i]).sqrt()
+        v[i] = v[i] / v[i].norm()
 
     return v