(a, b, c)
return (s, t)
Extended Euclidean Algorithm, Diophantine version.

    Given a, b in K[x] and c in (a, b), the ideal generated by a and b,
    return (s, t) such that s*a + t*b == c and either s == 0 or s.degree()
    < b.degree().
Extended Euclidean Algorithm, Diophantine version.
Extended Euclidean Algorithm Diophantine version .
def gcdex_diophantine(a, b, c):
    """
    Extended Euclidean Algorithm, Diophantine version.

    Given a, b in K[x] and c in (a, b), the ideal generated by a and b,
    return (s, t) such that s*a + t*b == c and either s == 0 or s.degree()
    < b.degree().
    """
    # Extended Euclidean Algorithm (Diophantine Version) pg. 13
    # TODO: This should go in densetools.py.
    # XXX: Bettter name?

    s, g = a.half_gcdex(b)
    q = c.exquo(g)  # Inexact division means c is not in (a, b)
    s = q*s

    if not s.is_zero and b.degree() >= b.degree():
        q, s = s.div(b)

    t = (c - s*a).exquo(b)

    return (s, t)
def gcdex_diophantine ( a , b , c ) : # Extended Euclidean Algorithm (Diophantine Version) pg. 13 # TODO: This should go in densetools.py. # XXX: Bettter name? s , g = a . half_gcdex ( b ) q = c . exquo ( g ) # Inexact division means c is not in (a, b) s = q * s if not s . is_zero and b . degree ( ) >= b . degree ( ) : q , s = s . div ( b ) t = ( c - s * a ) . exquo ( b ) return ( s , t )