def dup_rr_prs_gcd(f, g, K):
 result = _dup_rr_trivial_gcd(f, g, K)
 if (result is not None):
  return result
 (fc, F) = dup_primitive(f, K)
 (gc, G) = dup_primitive(g, K)
 c = K.gcd(fc, gc)
 h = dup_subresultants(F, G, K)[(-1)]
 (_, h) = dup_primitive(h, K)
 if K.is_negative(dup_LC(h, K)):
  c = (- c)
 h = dup_mul_ground(h, c, K)
 cff = dup_quo(f, h, K)
 cfg = dup_quo(g, h, K)
 return (h, cff, cfg)

def dup_rr_prs_gcd ( f , g , K ) : result = _dup_rr_trivial_gcd ( f , g , K ) if ( result is not None ) : return result ( fc , F ) = dup_primitive ( f , K ) ( gc , G ) = dup_primitive ( g , K ) c = K . gcd ( fc , gc ) h = dup_subresultants ( F , G , K ) [ ( - 1 ) ] ( _ , h ) = dup_primitive ( h , K ) if K . is_negative ( dup_LC ( h , K ) ) : c = ( - c ) h = dup_mul_ground ( h , c , K ) cff = dup_quo ( f , h , K ) cfg = dup_quo ( g , h , K ) return ( h , cff , cfg )
computes polynomial gcd using subresultants over a ring .