Ejemplo n.º 1
0
def get_coefficient_term(R, f):
    """
    
    """
    terms = f.terms(R.order)
    syms = R.symbols
    LM, _ = terms[0]

    # get the first non-zero index - this is the "leading variable".
    leading_idx = first(nonzeros(LM))
    # Then, scan the rest of the terms for any thing other than this,
    # and add it to the polynomial.
    u = 0
    for monom, coeff in terms:
        if monom[leading_idx] != LM[leading_idx]: continue
        monom = monom[:leading_idx] + (0,) + monom[leading_idx+1:]
        u += coeff * prod(syms[var]**exp for (var, exp) in zip(xrange(len(monom)), monom))
    return R(u)
Ejemplo n.º 2
0
def get_coefficient_term(R, f):
    """
    
    """
    terms = f.terms(R.order)
    syms = R.symbols
    LM, _ = terms[0]

    # get the first non-zero index - this is the "leading variable".
    leading_idx = first(nonzeros(LM))
    # Then, scan the rest of the terms for any thing other than this,
    # and add it to the polynomial.
    u = 0
    for monom, coeff in terms:
        if monom[leading_idx] != LM[leading_idx]: continue
        monom = monom[:leading_idx] + (0, ) + monom[leading_idx + 1:]
        u += coeff * prod(syms[var]**exp
                          for (var, exp) in zip(xrange(len(monom)), monom))
    return R(u)
Ejemplo n.º 3
0
def active_symbols(f):
    """Find the active symbols"""
    return set(nonzeros(f.degrees()))
Ejemplo n.º 4
0
def active_symbols(f):
    """Find the active symbols"""
    return set(nonzeros(f.degrees()))