(f, i)
return fswap
Make the variable `x_i` the leading one in a multivariate polynomial `f`.
Make the variable `x_i` the leading one in a multivariate polynomial `f`.
Make the variable x_i the leading one in a multivariate polynomial f .
def _swap(f, i):
    """
    Make the variable `x_i` the leading one in a multivariate polynomial `f`.
    """
    ring = f.ring
    k = ring.ngens
    fswap = ring.zero
    for monom, coeff in f.iterterms():
        monomswap = (monom[i],) + monom[:i] + monom[i+1:]
        fswap[monomswap] = coeff
    return fswap
def _swap ( f , i ) : ring = f . ring k = ring . ngens fswap = ring . zero for monom , coeff in f . iterterms ( ) : monomswap = ( monom [ i ] , ) + monom [ : i ] + monom [ i + 1 : ] fswap [ monomswap ] = coeff return fswap