(f, g, u, K0)
return h, cff, cfg
Heuristic polynomial GCD in `Q[X]`.

    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, QQ
    >>> R, x,y, = ring("x,y", QQ)

    >>> f = QQ(1,4)*x**2 + x*y + y**2
    >>> g = QQ(1,2)*x**2 + x*y

    >>> R.dmp_qq_heu_gcd(f, g)
    (x + 2*y, 1/4*x + 1/2*y, 1/2*x)
Heuristic polynomial GCD in `Q[X]`.
Heuristic polynomial GCD in Q [ X ] .
def dmp_qq_heu_gcd(f, g, u, K0):
    """
    Heuristic polynomial GCD in `Q[X]`.

    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, QQ
    >>> R, x,y, = ring("x,y", QQ)

    >>> f = QQ(1,4)*x**2 + x*y + y**2
    >>> g = QQ(1,2)*x**2 + x*y

    >>> R.dmp_qq_heu_gcd(f, g)
    (x + 2*y, 1/4*x + 1/2*y, 1/2*x)

    """
    result = _dmp_ff_trivial_gcd(f, g, u, K0)

    if result is not None:
        return result

    K1 = K0.get_ring()

    cf, f = dmp_clear_denoms(f, u, K0, K1)
    cg, g = dmp_clear_denoms(g, u, K0, K1)

    f = dmp_convert(f, u, K0, K1)
    g = dmp_convert(g, u, K0, K1)

    h, cff, cfg = dmp_zz_heu_gcd(f, g, u, K1)

    h = dmp_convert(h, u, K1, K0)

    c = dmp_ground_LC(h, u, K0)
    h = dmp_ground_monic(h, u, K0)

    cff = dmp_convert(cff, u, K1, K0)
    cfg = dmp_convert(cfg, u, K1, K0)

    cff = dmp_mul_ground(cff, K0.quo(c, cf), u, K0)
    cfg = dmp_mul_ground(cfg, K0.quo(c, cg), u, K0)

    return h, cff, cfg
def dmp_qq_heu_gcd ( f , g , u , K0 ) : result = _dmp_ff_trivial_gcd ( f , g , u , K0 ) if result is not None : return result K1 = K0 . get_ring ( ) cf , f = dmp_clear_denoms ( f , u , K0 , K1 ) cg , g = dmp_clear_denoms ( g , u , K0 , K1 ) f = dmp_convert ( f , u , K0 , K1 ) g = dmp_convert ( g , u , K0 , K1 ) h , cff , cfg = dmp_zz_heu_gcd ( f , g , u , K1 ) h = dmp_convert ( h , u , K1 , K0 ) c = dmp_ground_LC ( h , u , K0 ) h = dmp_ground_monic ( h , u , K0 ) cff = dmp_convert ( cff , u , K1 , K0 ) cfg = dmp_convert ( cfg , u , K1 , K0 ) cff = dmp_mul_ground ( cff , K0 . quo ( c , cf ) , u , K0 ) cfg = dmp_mul_ground ( cfg , K0 . quo ( c , cg ) , u , K0 ) return h , cff , cfg