(f, H, LC, A, p, u, K)
Wang/EEZ: Parallel Hensel lifting algorithm.
Wang/EEZ: Parallel Hensel lifting algorithm.
Wang / EEZ : Parallel Hensel lifting algorithm .
def dmp_zz_wang_hensel_lifting(f, H, LC, A, p, u, K):
    """Wang/EEZ: Parallel Hensel lifting algorithm. """
    S, n, v = [f], len(A), u - 1

    H = list(H)

    for i, a in enumerate(reversed(A[1:])):
        s = dmp_eval_in(S[0], a, n - i, u - i, K)
        S.insert(0, dmp_ground_trunc(s, p, v - i, K))

    d = max(dmp_degree_list(f, u)[1:])

    for j, s, a in zip(xrange(2, n + 2), S, A):
        G, w = list(H), j - 1

        I, J = A[:j - 2], A[j - 1:]

        for i, (h, lc) in enumerate(zip(H, LC)):
            lc = dmp_ground_trunc(dmp_eval_tail(lc, J, v, K), p, w - 1, K)
            H[i] = [lc] + dmp_raise(h[1:], 1, w - 1, K)

        m = dmp_nest([K.one, -a], w, K)
        M = dmp_one(w, K)

        c = dmp_sub(s, dmp_expand(H, w, K), w, K)

        dj = dmp_degree_in(s, w, w)

        for k in K.map(xrange(0, dj)):
            if dmp_zero_p(c, w):
                break

            M = dmp_mul(M, m, w, K)
            C = dmp_diff_eval_in(c, k + 1, a, w, w, K)

            if not dmp_zero_p(C, w - 1):
                C = dmp_quo_ground(C, K.factorial(k + 1), w - 1, K)
                T = dmp_zz_diophantine(G, C, I, d, p, w - 1, K)

                for i, (h, t) in enumerate(zip(H, T)):
                    h = dmp_add_mul(h, dmp_raise(t, 1, w - 1, K), M, w, K)
                    H[i] = dmp_ground_trunc(h, p, w, K)

                h = dmp_sub(s, dmp_expand(H, w, K), w, K)
                c = dmp_ground_trunc(h, p, w, K)

    if dmp_expand(H, u, K) != f:
        raise ExtraneousFactors  # pragma: no cover
    else:
        return H
def dmp_zz_wang_hensel_lifting ( f , H , LC , A , p , u , K ) : S , n , v = [ f ] , len ( A ) , u - 1 H = list ( H ) for i , a in enumerate ( reversed ( A [ 1 : ] ) ) : s = dmp_eval_in ( S [ 0 ] , a , n - i , u - i , K ) S . insert ( 0 , dmp_ground_trunc ( s , p , v - i , K ) ) d = max ( dmp_degree_list ( f , u ) [ 1 : ] ) for j , s , a in zip ( xrange ( 2 , n + 2 ) , S , A ) : G , w = list ( H ) , j - 1 I , J = A [ : j - 2 ] , A [ j - 1 : ] for i , ( h , lc ) in enumerate ( zip ( H , LC ) ) : lc = dmp_ground_trunc ( dmp_eval_tail ( lc , J , v , K ) , p , w - 1 , K ) H [ i ] = [ lc ] + dmp_raise ( h [ 1 : ] , 1 , w - 1 , K ) m = dmp_nest ( [ K . one , - a ] , w , K ) M = dmp_one ( w , K ) c = dmp_sub ( s , dmp_expand ( H , w , K ) , w , K ) dj = dmp_degree_in ( s , w , w ) for k in K . map ( xrange ( 0 , dj ) ) : if dmp_zero_p ( c , w ) : break M = dmp_mul ( M , m , w , K ) C = dmp_diff_eval_in ( c , k + 1 , a , w , w , K ) if not dmp_zero_p ( C , w - 1 ) : C = dmp_quo_ground ( C , K . factorial ( k + 1 ) , w - 1 , K ) T = dmp_zz_diophantine ( G , C , I , d , p , w - 1 , K ) for i , ( h , t ) in enumerate ( zip ( H , T ) ) : h = dmp_add_mul ( h , dmp_raise ( t , 1 , w - 1 , K ) , M , w , K ) H [ i ] = dmp_ground_trunc ( h , p , w , K ) h = dmp_sub ( s , dmp_expand ( H , w , K ) , w , K ) c = dmp_ground_trunc ( h , p , w , K ) if dmp_expand ( H , u , K ) != f : raise ExtraneousFactors # pragma: no cover else : return H