]> gitweb.michael.orlitzky.com - sage.d.git/commitdiff
eja: fix the fast matrix _charpoly_coefficients() method.
authorMichael Orlitzky <michael@orlitzky.com>
Wed, 4 Nov 2020 23:24:49 +0000 (18:24 -0500)
committerMichael Orlitzky <michael@orlitzky.com>
Wed, 4 Nov 2020 23:24:49 +0000 (18:24 -0500)
mjo/eja/eja_algebra.py

index bcafe57cbebd2b974eda6e3f13b3ceda26ffd4ab..4091d03fd6a40351e7d4c2789847d1db6fa0e807 100644 (file)
@@ -993,7 +993,24 @@ class MatrixEuclideanJordanAlgebra(FiniteDimensionalEuclideanJordanAlgebra):
             J = MatrixEuclideanJordanAlgebra(QQ,
                                              basis,
                                              normalize_basis=False)
-            return J._charpoly_coefficients()
+            a = J._charpoly_coefficients()
+
+            # Unfortunately, changing the basis does change the
+            # coefficients of the characteristic polynomial, but since
+            # these are really the coefficients of the "characteristic
+            # polynomial of" function, everything is still nice and
+            # unevaluated. It's therefore "obvious" how scaling the
+            # basis affects the coordinate variables X1, X2, et
+            # cetera. Scaling the first basis vector up by "n" adds a
+            # factor of 1/n into every "X1" term, for example. So here
+            # we simply undo the basis_normalizer scaling that we
+            # performed earlier.
+            #
+            # TODO: make this access safe.
+            XS = a[0].variables()
+            subs_dict = { XS[i]: self._basis_normalizers[i]*XS[i]
+                          for i in range(len(XS)) }
+            return tuple( a_i.subs(subs_dict) for a_i in a )
 
 
     @staticmethod