def dup_zz_factor(f, K):
 (cont, g) = dup_primitive(f, K)
 n = dup_degree(g)
 if (dup_LC(g, K) < 0):
  (cont, g) = ((- cont), dup_neg(g, K))
 if (n <= 0):
  return (cont, [])
 elif (n == 1):
  return (cont, [(g, 1)])
 if query('USE_IRREDUCIBLE_IN_FACTOR'):
  if dup_zz_irreducible_p(g, K):
   return (cont, [(g, 1)])
 g = dup_sqf_part(g, K)
 H = None
 if query('USE_CYCLOTOMIC_FACTOR'):
  H = dup_zz_cyclotomic_factor(g, K)
 if (H is None):
  H = dup_zz_zassenhaus(g, K)
 factors = dup_trial_division(f, H, K)
 return (cont, factors)

def dup_zz_factor ( f , K ) : ( cont , g ) = dup_primitive ( f , K ) n = dup_degree ( g ) if ( dup_LC ( g , K ) < 0 ) : ( cont , g ) = ( ( - cont ) , dup_neg ( g , K ) ) if ( n <= 0 ) : return ( cont , [ ] ) elif ( n == 1 ) : return ( cont , [ ( g , 1 ) ] ) if query ( 'USE_IRREDUCIBLE_IN_FACTOR' ) : if dup_zz_irreducible_p ( g , K ) : return ( cont , [ ( g , 1 ) ] ) g = dup_sqf_part ( g , K ) H = None if query ( 'USE_CYCLOTOMIC_FACTOR' ) : H = dup_zz_cyclotomic_factor ( g , K ) if ( H is None ) : H = dup_zz_zassenhaus ( g , K ) factors = dup_trial_division ( f , H , K ) return ( cont , factors )
factor polynomials in z[x] .