From 04f4cf9128e6cad289e78845de177e7b1f7fca6d Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Tue, 15 Oct 2019 08:23:10 -0400 Subject: [PATCH] eja: simplify the algebra charpoly method a bit. --- mjo/eja/eja_algebra.py | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/mjo/eja/eja_algebra.py b/mjo/eja/eja_algebra.py index 56be0fa..725cd71 100644 --- a/mjo/eja/eja_algebra.py +++ b/mjo/eja/eja_algebra.py @@ -251,7 +251,10 @@ class FiniteDimensionalEuclideanJordanAlgebra(CombinatorialFreeModule): """ (A_of_x, x, xr, detA) = self._charpoly_matrix_system() R = A_of_x.base_ring() - if i >= self.rank(): + + if i == self.rank(): + return R.one() + if i > self.rank(): # Guaranteed by theory return R.zero() @@ -378,8 +381,8 @@ class FiniteDimensionalEuclideanJordanAlgebra(CombinatorialFreeModule): r = self.rank() n = self.dimension() - # The list of coefficient polynomials a_1, a_2, ..., a_n. - a = [ self._charpoly_coeff(i) for i in range(n) ] + # The list of coefficient polynomials a_0, a_1, a_2, ..., a_n. + a = [ self._charpoly_coeff(i) for i in range(r+1) ] # We go to a bit of trouble here to reorder the # indeterminates, so that it's easier to evaluate the @@ -391,17 +394,6 @@ class FiniteDimensionalEuclideanJordanAlgebra(CombinatorialFreeModule): S = PolynomialRing(S, R.variable_names()) t = S(t) - # Note: all entries past the rth should be zero. The - # coefficient of the highest power (x^r) is 1, but it doesn't - # appear in the solution vector which contains coefficients - # for the other powers (to make them sum to x^r). - if (r < n): - a[r] = 1 # corresponds to x^r - else: - # When the rank is equal to the dimension, trying to - # assign a[r] goes out-of-bounds. - a.append(1) # corresponds to x^r - return sum( a[k]*(t**k) for k in xrange(len(a)) ) -- 2.44.2