(f, g, u, K)
return h, cff, cfg
Computes polynomial GCD using subresultants over a ring.

    Returns ``(h, cff, cfg)`` such that ``a = gcd(f, g)``, ``cff = quo(f, h)``,
    and ``cfg = quo(g, h)``.

    Examples
    ========

    >>> from sympy.polys import ring, ZZ
    >>> R, x,y, = ring("x,y", ZZ)

    >>> f = x**2 + 2*x*y + y**2
    >>> g = x**2 + x*y

    >>> R.dmp_rr_prs_gcd(f, g)
    (x + y, x + y, x)
Computes polynomial GCD using subresultants over a ring.
Computes polynomial GCD using subresultants over a ring .
def dmp_rr_prs_gcd(f, g, u, K):
    """
    Computes polynomial GCD using subresultants over a ring.

    Returns ``(h, cff, cfg)`` such that ``a = gcd(f, g)``, ``cff = quo(f, h)``,
    and ``cfg = quo(g, h)``.

    Examples
    ========

    >>> from sympy.polys import ring, ZZ
    >>> R, x,y, = ring("x,y", ZZ)

    >>> f = x**2 + 2*x*y + y**2
    >>> g = x**2 + x*y

    >>> R.dmp_rr_prs_gcd(f, g)
    (x + y, x + y, x)

    """
    if not u:
        return dup_rr_prs_gcd(f, g, K)

    result = _dmp_rr_trivial_gcd(f, g, u, K)

    if result is not None:
        return result

    fc, F = dmp_primitive(f, u, K)
    gc, G = dmp_primitive(g, u, K)

    h = dmp_subresultants(F, G, u, K)[-1]
    c, _, _ = dmp_rr_prs_gcd(fc, gc, u - 1, K)

    if K.is_negative(dmp_ground_LC(h, u, K)):
        h = dmp_neg(h, u, K)

    _, h = dmp_primitive(h, u, K)
    h = dmp_mul_term(h, c, 0, u, K)

    cff = dmp_quo(f, h, u, K)
    cfg = dmp_quo(g, h, u, K)

    return h, cff, cfg
def dmp_rr_prs_gcd ( f , g , u , K ) : if not u : return dup_rr_prs_gcd ( f , g , K ) result = _dmp_rr_trivial_gcd ( f , g , u , K ) if result is not None : return result fc , F = dmp_primitive ( f , u , K ) gc , G = dmp_primitive ( g , u , K ) h = dmp_subresultants ( F , G , u , K ) [ - 1 ] c , _ , _ = dmp_rr_prs_gcd ( fc , gc , u - 1 , K ) if K . is_negative ( dmp_ground_LC ( h , u , K ) ) : h = dmp_neg ( h , u , K ) _ , h = dmp_primitive ( h , u , K ) h = dmp_mul_term ( h , c , 0 , u , K ) cff = dmp_quo ( f , h , u , K ) cfg = dmp_quo ( g , h , u , K ) return h , cff , cfg