- """
- n = self.dimension()
- var_names = [ "X" + str(z) for z in range(1,n+1) ]
- d = 0
- ideal_dim = len(var_names)
- def L_x_i_j(i,j):
- # From a result in my book, these are the entries of the
- # basis representation of L_x.
- return sum( vars[d+k]*self.monomial(k).operator().matrix()[i,j]
- for k in range(n) )
-
- while ideal_dim == len(var_names):
- coeff_names = [ "a" + str(z) for z in range(d) ]
- R = PolynomialRing(self.base_ring(), coeff_names + var_names)
- vars = R.gens()
- L_x = matrix(R, n, n, L_x_i_j)
- x_powers = [ vars[k]*(L_x**k)*self.one().to_vector()
- for k in range(d) ]
- eqs = [ sum(x_powers[k][j] for k in range(d)) for j in range(n) ]
- ideal_dim = R.ideal(eqs).dimension()
- d += 1
-
- # Subtract one because we increment one too many times, and
- # subtract another one because "d" is one greater than the
- # answer anyway; when d=3, we go up to x^2.
- return d-2
-
- def _rank_computation2(self):
- r"""
- Instead of using the dimension of an ideal, find the rank of a
- matrix containing polynomials.
- """
- n = self.dimension()
- var_names = [ "X" + str(z) for z in range(1,n+1) ]
- R = PolynomialRing(self.base_ring(), var_names)
- vars = R.gens()
-
- def L_x_i_j(i,j):
- # From a result in my book, these are the entries of the
- # basis representation of L_x.
- return sum( vars[k]*self.monomial(k).operator().matrix()[i,j]
- for k in range(n) )
-
- L_x = matrix(R, n, n, L_x_i_j)
- x_powers = [ (vars[k]*(L_x**k)*self.one().to_vector()).row()
- for k in range(n) ]
-
- from sage.matrix.constructor import block_matrix
- M = block_matrix(n,1,x_powers)
- return M.rank()
-
- def _rank_computation3(self):
- r"""
- Similar to :meth:`_rank_computation2`, but it stops echelonizing
- as soon as it hits the first zero row.