(f, K)
return lc, factors
Factor univariate polynomials over algebraic number fields.
Factor univariate polynomials over algebraic number fields.
Factor univariate polynomials over algebraic number fields .
def dup_ext_factor(f, K):
    """Factor univariate polynomials over algebraic number fields. """
    n, lc = dup_degree(f), dup_LC(f, K)

    f = dup_monic(f, K)

    if n <= 0:
        return lc, []
    if n == 1:
        return lc, [(f, 1)]

    f, F = dup_sqf_part(f, K), f
    s, g, r = dup_sqf_norm(f, K)

    factors = dup_factor_list_include(r, K.dom)

    if len(factors) == 1:
        return lc, [(f, n//dup_degree(f))]

    H = s*K.unit

    for i, (factor, _) in enumerate(factors):
        h = dup_convert(factor, K.dom, K)
        h, _, g = dup_inner_gcd(h, g, K)
        h = dup_shift(h, H, K)
        factors[i] = h

    factors = dup_trial_division(F, factors, K)
    return lc, factors
def dup_ext_factor ( f , K ) : n , lc = dup_degree ( f ) , dup_LC ( f , K ) f = dup_monic ( f , K ) if n <= 0 : return lc , [ ] if n == 1 : return lc , [ ( f , 1 ) ] f , F = dup_sqf_part ( f , K ) , f s , g , r = dup_sqf_norm ( f , K ) factors = dup_factor_list_include ( r , K . dom ) if len ( factors ) == 1 : return lc , [ ( f , n // dup_degree ( f ) ) ] H = s * K . unit for i , ( factor , _ ) in enumerate ( factors ) : h = dup_convert ( factor , K . dom , K ) h , _ , g = dup_inner_gcd ( h , g , K ) h = dup_shift ( h , H , K ) factors [ i ] = h factors = dup_trial_division ( F , factors , K ) return lc , factors