(F, c, A, d, p, u, K)
return S
Wang/EEZ: Solve multivariate Diophantine equations.
Wang/EEZ: Solve multivariate Diophantine equations.
Wang / EEZ : Solve multivariate Diophantine equations .
def dmp_zz_diophantine(F, c, A, d, p, u, K):
    """Wang/EEZ: Solve multivariate Diophantine equations. """
    if not A:
        S = [ [] for _ in F ]
        n = dup_degree(c)

        for i, coeff in enumerate(c):
            if not coeff:
                continue

            T = dup_zz_diophantine(F, n - i, p, K)

            for j, (s, t) in enumerate(zip(S, T)):
                t = dup_mul_ground(t, coeff, K)
                S[j] = dup_trunc(dup_add(s, t, K), p, K)
    else:
        n = len(A)
        e = dmp_expand(F, u, K)

        a, A = A[-1], A[:-1]
        B, G = [], []

        for f in F:
            B.append(dmp_quo(e, f, u, K))
            G.append(dmp_eval_in(f, a, n, u, K))

        C = dmp_eval_in(c, a, n, u, K)

        v = u - 1

        S = dmp_zz_diophantine(G, C, A, d, p, v, K)
        S = [ dmp_raise(s, 1, v, K) for s in S ]

        for s, b in zip(S, B):
            c = dmp_sub_mul(c, s, b, u, K)

        c = dmp_ground_trunc(c, p, u, K)

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

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

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

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

                for i, t in enumerate(T):
                    T[i] = dmp_mul(dmp_raise(t, 1, v, K), M, u, K)

                for i, (s, t) in enumerate(zip(S, T)):
                    S[i] = dmp_add(s, t, u, K)

                for t, b in zip(T, B):
                    c = dmp_sub_mul(c, t, b, u, K)

                c = dmp_ground_trunc(c, p, u, K)

        S = [ dmp_ground_trunc(s, p, u, K) for s in S ]

    return S
def dmp_zz_diophantine ( F , c , A , d , p , u , K ) : if not A : S = [ [ ] for _ in F ] n = dup_degree ( c ) for i , coeff in enumerate ( c ) : if not coeff : continue T = dup_zz_diophantine ( F , n - i , p , K ) for j , ( s , t ) in enumerate ( zip ( S , T ) ) : t = dup_mul_ground ( t , coeff , K ) S [ j ] = dup_trunc ( dup_add ( s , t , K ) , p , K ) else : n = len ( A ) e = dmp_expand ( F , u , K ) a , A = A [ - 1 ] , A [ : - 1 ] B , G = [ ] , [ ] for f in F : B . append ( dmp_quo ( e , f , u , K ) ) G . append ( dmp_eval_in ( f , a , n , u , K ) ) C = dmp_eval_in ( c , a , n , u , K ) v = u - 1 S = dmp_zz_diophantine ( G , C , A , d , p , v , K ) S = [ dmp_raise ( s , 1 , v , K ) for s in S ] for s , b in zip ( S , B ) : c = dmp_sub_mul ( c , s , b , u , K ) c = dmp_ground_trunc ( c , p , u , K ) m = dmp_nest ( [ K . one , - a ] , n , K ) M = dmp_one ( n , K ) for k in K . map ( xrange ( 0 , d ) ) : if dmp_zero_p ( c , u ) : break M = dmp_mul ( M , m , u , K ) C = dmp_diff_eval_in ( c , k + 1 , a , n , u , K ) if not dmp_zero_p ( C , v ) : C = dmp_quo_ground ( C , K . factorial ( k + 1 ) , v , K ) T = dmp_zz_diophantine ( G , C , A , d , p , v , K ) for i , t in enumerate ( T ) : T [ i ] = dmp_mul ( dmp_raise ( t , 1 , v , K ) , M , u , K ) for i , ( s , t ) in enumerate ( zip ( S , T ) ) : S [ i ] = dmp_add ( s , t , u , K ) for t , b in zip ( T , B ) : c = dmp_sub_mul ( c , t , b , u , K ) c = dmp_ground_trunc ( c , p , u , K ) S = [ dmp_ground_trunc ( s , p , u , K ) for s in S ] return S