From: Michael Orlitzky Date: Tue, 15 Oct 2019 12:23:10 +0000 (-0400) Subject: eja: simplify the algebra charpoly method a bit. X-Git-Url: http://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=04f4cf9128e6cad289e78845de177e7b1f7fca6d;p=sage.d.git eja: simplify the algebra charpoly method a bit. --- 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)) )