"""
(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()
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
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)) )