def dup_inner_gcd(f, g, K):
 if (not K.is_Exact):
  try:
   exact = K.get_exact()
  except DomainError:
   return ([K.one], f, g)
  f = dup_convert(f, K, exact)
  g = dup_convert(g, K, exact)
  (h, cff, cfg) = dup_inner_gcd(f, g, exact)
  h = dup_convert(h, exact, K)
  cff = dup_convert(cff, exact, K)
  cfg = dup_convert(cfg, exact, K)
  return (h, cff, cfg)
 elif K.has_Field:
  if (K.is_QQ and query('USE_HEU_GCD')):
   try:
    return dup_qq_heu_gcd(f, g, K)
   except HeuristicGCDFailed:
    pass
  return dup_ff_prs_gcd(f, g, K)
 else:
  if (K.is_ZZ and query('USE_HEU_GCD')):
   try:
    return dup_zz_heu_gcd(f, g, K)
   except HeuristicGCDFailed:
    pass
  return dup_rr_prs_gcd(f, g, K)

def dup_inner_gcd ( f , g , K ) : if ( not K . is_Exact ) : try : exact = K . get_exact ( ) except DomainError : return ( [ K . one ] , f , g ) f = dup_convert ( f , K , exact ) g = dup_convert ( g , K , exact ) ( h , cff , cfg ) = dup_inner_gcd ( f , g , exact ) h = dup_convert ( h , exact , K ) cff = dup_convert ( cff , exact , K ) cfg = dup_convert ( cfg , exact , K ) return ( h , cff , cfg ) elif K . has_Field : if ( K . is_QQ and query ( 'USE_HEU_GCD' ) ) : try : return dup_qq_heu_gcd ( f , g , K ) except HeuristicGCDFailed : pass return dup_ff_prs_gcd ( f , g , K ) else : if ( K . is_ZZ and query ( 'USE_HEU_GCD' ) ) : try : return dup_zz_heu_gcd ( f , g , K ) except HeuristicGCDFailed : pass return dup_rr_prs_gcd ( f , g , K )
computes polynomial gcd and cofactors of f and g in k[x] .