U
    ZÊ¹j¨  ã                   @   s@  d Z ddlmZ ddlmZ ddlmZmZmZm	Z	m
Z
mZmZmZmZmZmZ ddlmZmZmZmZmZmZmZmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z) ddl*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@mAZAmBZBmCZCmDZD ddlEmFZFmGZGmHZHmIZImJZJmKZKmLZLmMZMmNZNmOZOmPZPmQZQmRZRmSZSmTZT ddlUmVZVmWZWmXZX dd	lYmZZZm[Z[m\Z\m]Z]m^Z^m_Z_m`Z` dd
lambZb ddlcmdZd ddlemfZfmgZgmhZhmiZi ddljmkZk ddllmmZnmoZpmqZr edk�rddlsmtZt ndZtdd„ Zudd„ Zvdd„ Zwdd„ Zxdd„ Zydd„ Zzdd„ Z{d d!„ Z|d"d#„ Z}d]d%d&„Z~d'd(„ Zd)d*„ Z€d+d,„ Z�d-d.„ Z‚d/d0„ Zƒd1d2„ Z„d3d4„ Z…d5d6„ Z†d7d8„ Z‡d9d:„ Zˆd;d<„ Z‰d^d=d>„ZŠd?d@„ Z‹dAdB„ ZŒdCdD„ Z�dEdF„ ZŽdGdH„ Z�dIdJ„ Z�dKdL„ Z‘dMdN„ Z’dOdP„ Z“dQdR„ Z”dSdT„ Z•dUdV„ Z–dWdX„ Z—dYdZ„ Z˜d[d\„ Z™dS )_z:Polynomial factorization routines in characteristic zero. é    )ÚGROUND_TYPES)Ú_randint)Úgf_from_int_polyÚgf_to_int_polyÚ	gf_lshiftÚ
gf_add_mulÚgf_mulÚgf_divÚgf_remÚgf_gcdexÚgf_sqf_pÚgf_factor_sqfÚ	gf_factor)Údup_LCÚdmp_LCÚdmp_ground_LCÚdup_TCÚdup_convertÚdmp_convertÚ
dup_degreeÚ
dmp_degreeÚdmp_degree_inÚdmp_degree_listÚdmp_from_dictÚ
dmp_zero_pÚdmp_oneÚdmp_nestÚ	dmp_raiseÚ	dup_stripÚ
dmp_groundÚdup_inflateÚdmp_excludeÚdmp_includeÚ
dmp_injectÚ	dmp_ejectÚdup_terms_gcdÚdmp_terms_gcd)Údup_negÚdmp_negÚdup_addÚdmp_addÚdup_subÚdmp_subÚdup_mulÚdmp_mulÚdup_sqrÚdmp_powÚdup_divÚdmp_divÚdup_quoÚdmp_quoÚ
dmp_expandÚdmp_add_mulÚdup_sub_mulÚdmp_sub_mulÚ
dup_lshiftÚdup_max_normÚdmp_max_normÚdup_l1_normÚdup_mul_groundÚdmp_mul_groundÚdup_quo_groundÚdmp_quo_ground)Údup_clear_denomsÚdmp_clear_denomsÚ	dup_truncÚdmp_ground_truncÚdup_contentÚ	dup_monicÚdmp_ground_monicÚdup_primitiveÚdmp_ground_primitiveÚdmp_eval_tailÚdmp_eval_inÚdmp_diff_eval_inÚ	dup_shiftÚ	dmp_shiftÚ
dup_mirror)Údmp_primitiveÚdup_inner_gcdÚdmp_inner_gcd)Ú	dup_sqf_pÚdup_sqf_normÚdmp_sqf_normÚdup_sqf_partÚdmp_sqf_partÚ_dup_check_degreesÚ_dmp_check_degrees)Ú_sort_factors)Úquery)ÚExtraneousFactorsÚDomainErrorÚCoercionFailedÚEvaluationFailed)Úsubsets)ÚceilÚlogÚlog2Úflint)Ú	fmpz_polyNc                 C   s`   g }|D ]N}d}t | ||ƒ\}}|s8||d  } }qq8q|dkrHtdƒ‚| ||f¡ qt|ƒS )z¥
    Determine multiplicities of factors for a univariate polynomial
    using trial division.

    An error will be raised if any factor does not divide ``f``.
    r   é   útrial division failed)r1   ÚRuntimeErrorÚappendrZ   )ÚfÚfactorsÚKÚresultÚfactorÚkÚqÚr© rr   úV/var/www/html/bwave/python/venv/lib/python3.8/site-packages/sympy/polys/factortools.pyÚdup_trial_divisionX   s    rt   c           	      C   sh   g }|D ]V}d}t | |||ƒ\}}t||ƒr@||d  } }qq@q|dkrPtdƒ‚| ||f¡ qt|ƒS )z§
    Determine multiplicities of factors for a multivariate polynomial
    using trial division.

    An error will be raised if any factor does not divide ``f``.
    r   rf   rg   )r2   r   rh   ri   rZ   )	rj   rk   Úurl   rm   rn   ro   rp   rq   rr   rr   rs   Údmp_trial_divisiont   s    
rv   c                 C   s¦   ddl m} t| ƒ}t|d ƒ}t|d ƒ}| tdd„ | D ƒƒ¡}||d |ƒ}||d |d ƒ}| t| |ƒ¡}	|| ||	  }
|
t| |ƒ7 }
t|
d ƒd }
|
S )aÍ  
    The Knuth-Cohen variant of Mignotte bound for
    univariate polynomials in ``K[x]``.

    Examples
    ========

    >>> from sympy.polys import ring, ZZ
    >>> R, x = ring("x", ZZ)

    >>> f = x**3 + 14*x**2 + 56*x + 64
    >>> R.dup_zz_mignotte_bound(f)
    152

    By checking ``factor(f)`` we can see that max coeff is 8

    Also consider a case that ``f`` is irreducible for example
    ``f = 2*x**2 + 3*x + 4``. To avoid a bug for these cases, we return the
    bound plus the max coefficient of ``f``

    >>> f = 2*x**2 + 3*x + 4
    >>> R.dup_zz_mignotte_bound(f)
    6

    Lastly, to see the difference between the new and the old Mignotte bound
    consider the irreducible polynomial:

    >>> f = 87*x**7 + 4*x**6 + 80*x**5 + 17*x**4 + 9*x**3 + 12*x**2 + 49*x + 26
    >>> R.dup_zz_mignotte_bound(f)
    744

    The new Mignotte bound is 744 whereas the old one (SymPy 1.5.1) is 1937664.


    References
    ==========

    ..[1] [Abbott13]_

    r   )Úbinomialé   c                 s   s   | ]}|d  V  qdS )rx   Nrr   ©Ú.0Úcfrr   rr   rs   Ú	<genexpr>¿   s     z(dup_zz_mignotte_bound.<locals>.<genexpr>rf   )	Z(sympy.functions.combinatorial.factorialsrw   r   Ú_ceilÚsqrtÚsumÚabsr   r:   )rj   rl   rw   ÚdÚdeltaZdelta2Z	eucl_normÚt1Út2ÚlcÚboundrr   rr   rs   Údup_zz_mignotte_bound�   s    )r‡   c                 C   sL   t | ||ƒ}tt| ||ƒƒ}tt| |ƒƒ}| ||d ƒ¡d|  | | S )z7Mignotte bound for multivariate polynomials in `K[X]`. rf   rx   )r;   r€   r   r   r   r~   )rj   ru   rl   ÚaÚbÚnrr   rr   rs   Údmp_zz_mignotte_boundÌ   s    r‹   c                 C   sJ  | d }t ||||ƒ}t|||ƒ}tt|||ƒ||ƒ\}	}
t|	||ƒ}	t|
||ƒ}
tt|||ƒt|	||ƒ|ƒ}tt|||ƒ||ƒ}tt||
|ƒ||ƒ}tt|||ƒt|||ƒ|ƒ}tt||jg|ƒ||ƒ}tt|||ƒ||ƒ\}}t|||ƒ}t|||ƒ}tt|||ƒt|||ƒ|ƒ}tt|||ƒ||ƒ}tt|||ƒ||ƒ}||||fS )a
  
    One step in Hensel lifting in `Z[x]`.

    Given positive integer `m` and `Z[x]` polynomials `f`, `g`, `h`, `s`
    and `t` such that::

        f = g*h (mod m)
        s*g + t*h = 1 (mod m)

        lc(f) is not a zero divisor (mod m)
        lc(h) = 1

        deg(f) = deg(g) + deg(h)
        deg(s) < deg(h)
        deg(t) < deg(g)

    returns polynomials `G`, `H`, `S` and `T`, such that::

        f = G*H (mod m**2)
        S*G + T*H = 1 (mod m**2)

    References
    ==========

    .. [1] [Gathen99]_

    rx   )r7   rC   r1   r-   r)   r+   Úone)Úmrj   ÚgÚhÚsÚtrl   ÚMÚerp   rq   ru   ÚGÚHr‰   Úcr�   ÚSÚTrr   rr   rs   Údup_zz_hensel_stepÕ   s$    r™   c              	   C   sv  t |ƒ}t||ƒ}|dkrHt|| || | ¡d |ƒ}t|| | |ƒgS | }|d }	ttt|ƒƒƒ}
t|g| ƒ}|d|	… D ]}t	|t|| ƒ| |ƒ}q|t||	 | ƒ}||	d d… D ]}t	|t|| ƒ| |ƒ}q´t
||| |ƒ\}}}t|| ƒ}t|| ƒ}t|| ƒ}t|| ƒ}td|
d ƒD ],}t|||||||ƒ|d  \}}}}}�qt| ||d|	… ||ƒt| |||	d… ||ƒ S )añ  
    Multifactor Hensel lifting in `Z[x]`.

    Given a prime `p`, polynomial `f` over `Z[x]` such that `lc(f)`
    is a unit modulo `p`, monic pair-wise coprime polynomials `f_i`
    over `Z[x]` satisfying::

        f = lc(f) f_1 ... f_r (mod p)

    and a positive integer `l`, returns a list of monic polynomials
    `F_1,\ F_2,\ \dots,\ F_r` satisfying::

       f = lc(f) F_1 ... F_r (mod p**l)

       F_i = f_i (mod p), i = 1..r

    References
    ==========

    .. [1] [Gathen99]_

    rf   r   rx   N)Úlenr   r=   ZgcdexrC   Úintr}   Ú_log2r   r   r   r   Úranger™   Údup_zz_hensel_lift)Úprj   Zf_listÚlrl   rq   r…   ÚFr�   ro   r�   rŽ   Zf_ir�   r�   r‘   Ú_rr   rr   rs   rž     s0    




*ÿrž   c                 C   s(   ||d kr|| }|sdS | | dkS )Nrx   Tr   rr   )Úfcrp   Úplrr   rr   rs   Ú_test_plG  s
    r¥   c                    s|  t | ƒ}|dkr| gS ddlm} | d }t| |ƒ}t| |ƒ}tt| ||d ƒ¡d|  | | ƒƒ}t|d d|  |d| d   ƒ}ttdt	|ƒ ƒƒ}	td|	 t
|	ƒ ƒ}
g }td|
d ƒD ]|}||ƒrÆ|| dkràqÆ| |¡}t| |ƒ}t|||ƒ�sqÆt|||ƒd }| ||f¡ t|ƒdk �s<t|ƒdkrÆ �qDqÆt|d	d
„ d�\‰}ttt
d| d ˆƒƒƒ}‡fdd„|D ƒ}tˆ| |||ƒ}tt|ƒƒ}t|ƒ}g d }}ˆ| }d| t|ƒk�rrt||ƒD �]Œ‰ |dk�r"d}ˆ D ]}||| d  }�qî|| }t|||ƒ�s~�qÖn\|g}ˆ D ]}t||| |ƒ}�q,t|||ƒ}t||ƒd }|d }|�r~|| dk�r~�qÖ|g}tˆ ƒ‰ |ˆ  }|dk�rÌ|g}ˆ D ]}t||| |ƒ}�q¨t|||ƒ}|D ]}t||| |ƒ}�qÐt|||ƒ}t||ƒ}t||ƒ}|| |k�rÖ|}‡ fdd„|D ƒ}t||ƒd }t||ƒd } | |¡ t| |ƒ} �qº�qÖ|d7 }�qº|| g S )z4Factor primitive square-free polynomials in `Z[x]`. rf   r   )Úisprimeéÿÿÿÿrx   é   é   é   c                 S   s   t | d ƒS )Nrf   )rš   )Úxrr   rr   rs   Ú<lambda>p  ó    z#dup_zz_zassenhaus.<locals>.<lambda>)Úkeyc                    s   g | ]}t |ˆ ƒ‘qS rr   )r   )rz   Úff)rŸ   rr   rs   Ú
<listcomp>t  s     z%dup_zz_zassenhaus.<locals>.<listcomp>c                    s   g | ]}|ˆ kr|‘qS rr   rr   )rz   Úi)r—   rr   rs   r°   ¨  s      )r   Úsympy.ntheoryr¦   r:   r   r›   r€   r~   r}   rœ   Ú_logr�   Úconvertr   r   r   ri   rš   Úminrž   Úsetr`   r¥   r-   rC   rH   r<   )rj   rl   rŠ   r¦   r£   ÚAr‰   ÚBÚCÚgammar†   rˆ   Zpxr¡   ZfsqfxZfsqfr    ZmodularrŽ   Zsorted_Tr˜   rk   r�   r¤   rp   r±   r”   r•   ZT_SZG_normZH_normrr   )r—   rŸ   rs   Údup_zz_zassenhausN  sŽ    

*$









r»   c                 C   sn   t | |ƒ}t| |ƒ}t| dd… |ƒ}|rjddlm} |t|ƒƒ}| ¡ D ]}|| rJ||d  rJ dS qJdS )z2Test irreducibility using Eisenstein's criterion. rf   Nr   ©Ú	factorintrx   T)r   r   rE   r²   r½   r›   Úkeys)rj   rl   r…   ÚtcZe_fcr½   Ze_ffrŸ   rr   rr   rs   Údup_zz_irreducible_p·  s    

rÀ   Fc                 C   sÈ  |j r>z|| ¡  }}t| ||ƒ} W qH tk
r:   Y dS X n
|jsHdS t| |ƒ}t| |ƒ}|dkst|dkrx|dkrxdS |s¦t| |ƒ\}}||jks¢|| dfgkr¦dS t	| ƒ}g g  }	}
t
|ddƒD ]}|	 d| | ¡ qÄt
|d ddƒD ]}|
 d| | ¡ qêtt|	ƒ|ƒ}	tt|
ƒ|ƒ}
t|	t|
d|ƒ|ƒ}| t||ƒ¡�rLt||ƒ}|| k�rZdS t| |ƒ}	| t|	|ƒ¡�r€t|	|ƒ}	||	k�ršt|	|ƒ�ršdS t||ƒ}t||ƒ|k�rÄt||ƒ�rÄdS dS )ad  
    Efficiently test if ``f`` is a cyclotomic polynomial.

    Examples
    ========

    >>> from sympy.polys import ring, ZZ
    >>> R, x = ring("x", ZZ)

    >>> f = x**16 + x**14 - x**10 + x**8 - x**6 + x**2 + 1
    >>> R.dup_cyclotomic_p(f)
    False

    >>> g = x**16 + x**14 - x**10 - x**8 - x**6 + x**2 + 1
    >>> R.dup_cyclotomic_p(g)
    True

    References
    ==========

    Bradford, Russell J., and James H. Davenport. "Effective tests for
    cyclotomic polynomials." In International Symposium on Symbolic and
    Algebraic Computation, pp. 244-251. Springer, Berlin, Heidelberg, 1988.

    Frf   r§   éþÿÿÿr   T)Zis_QQÚget_ringr   r^   Úis_ZZr   r   Údup_factor_listrŒ   r   r�   Úinsertr/   r   r+   r9   Úis_negativer'   rO   Údup_cyclotomic_prV   )rj   rl   ZirreducibleÚK0r…   r¿   Úcoeffrk   rŠ   rŽ   r�   r±   r¡   r”   rr   rr   rs   rÇ   Ç  sL    








rÇ   c                 C   s\   ddl m} |j|j g}|| ƒ ¡ D ]0\}}tt|||ƒ||ƒ}t|||d  |ƒ}q&|S )z1Efficiently generate n-th cyclotomic polynomial. r   r¼   rf   )r²   r½   rŒ   Úitemsr3   r    )rŠ   rl   r½   r�   rŸ   ro   rr   rr   rs   Údup_zz_cyclotomic_poly  s    rË   c                    s‚   ddl m} ˆ jˆ j gg}|| ƒ ¡ D ]T\‰}‡ ‡fdd„|D ƒ}| |¡ td|ƒD ]"}‡ ‡fdd„|D ƒ}| |¡ qXq(|S )Nr   r¼   c                    s    g | ]}t t|ˆˆ ƒ|ˆ ƒ‘qS rr   )r3   r    )rz   r�   ©rl   rŸ   rr   rs   r°   ,  s     z-_dup_cyclotomic_decompose.<locals>.<listcomp>rf   c                    s   g | ]}t |ˆˆ ƒ‘qS rr   )r    )rz   rp   rÌ   rr   rs   r°   0  s     )r²   r½   rŒ   rÊ   Úextendr�   )rŠ   rl   r½   r•   ro   ÚQr±   rr   rÌ   rs   Ú_dup_cyclotomic_decompose&  s    
rÏ   c                 C   sª   t | |ƒt| |ƒ }}t| ƒdkr&dS |dks6|dkr:dS tdd„ | dd… D ƒƒrXdS t| ƒ}t||ƒ}| |¡sx|S g }td| |ƒD ]}||krŠ| |¡ qŠ|S dS )	aø  
    Efficiently factor polynomials `x**n - 1` and `x**n + 1` in `Z[x]`.

    Given a univariate polynomial `f` in `Z[x]` returns a list of factors
    of `f`, provided that `f` is in the form `x**n - 1` or `x**n + 1` for
    `n >= 1`. Otherwise returns None.

    Factorization is performed using cyclotomic decomposition of `f`,
    which makes this method much faster that any other direct factorization
    approach (e.g. Zassenhaus's).

    References
    ==========

    .. [1] [Weisstein09]_

    r   Nrf   )r§   rf   c                 s   s   | ]}t |ƒV  qd S )N)Úboolry   rr   rr   rs   r|   P  s     z+dup_zz_cyclotomic_factor.<locals>.<genexpr>r§   rx   )r   r   r   ÚanyrÏ   Úis_oneri   )rj   rl   Zlc_fZtc_frŠ   r¡   r•   r�   rr   rr   rs   Údup_zz_cyclotomic_factor6  s     

rÓ   c                 C   s¬   t | |ƒ\}}t|ƒ}t||ƒdk r6| t||ƒ }}|dkrF|g fS |dkrX||gfS tdƒrtt||ƒrt||gfS d}tdƒrŠt||ƒ}|dkrœt||ƒ}|t|dd�fS )z:Factor square-free (non-primitive) polynomials in `Z[x]`. r   rf   ÚUSE_IRREDUCIBLE_IN_FACTORNÚUSE_CYCLOTOMIC_FACTORF)Zmultiple)	rH   r   r   r'   r[   rÀ   rÓ   r»   rZ   )rj   rl   ÚcontrŽ   rŠ   rk   rr   rr   rs   Údup_zz_factor_sqfb  s"    




r×   c                 C   s  t dkr@t| ddd… ƒ}| ¡ \}}dd„ |D ƒ}|t|ƒfS t| |ƒ\}}t|ƒ}t||ƒdk rv| t||ƒ }}|dkr†|g fS |dkrœ||dfgfS tdƒr¼t	||ƒr¼||dfgfS t
||ƒ}d}td	ƒrÜt||ƒ}|dkrît||ƒ}t| ||ƒ}t| |ƒ ||fS )
a  
    Factor (non square-free) polynomials in `Z[x]`.

    Given a univariate polynomial `f` in `Z[x]` computes its complete
    factorization `f_1, ..., f_n` into irreducibles over integers::

                f = content(f) f_1**k_1 ... f_n**k_n

    The factorization is computed by reducing the input polynomial
    into a primitive square-free polynomial and factoring it using
    Zassenhaus algorithm. Trial division is used to recover the
    multiplicities of factors.

    The result is returned as a tuple consisting of::

              (content(f), [(f_1, k_1), ..., (f_n, k_n))

    Examples
    ========

    Consider the polynomial `f = 2*x**4 - 2`::

        >>> from sympy.polys import ring, ZZ
        >>> R, x = ring("x", ZZ)

        >>> R.dup_zz_factor(2*x**4 - 2)
        (2, [(x - 1, 1), (x + 1, 1), (x**2 + 1, 1)])

    In result we got the following factorization::

                 f = 2 (x - 1) (x + 1) (x**2 + 1)

    Note that this is a complete factorization over integers,
    however over Gaussian integers we can factor the last term.

    By default, polynomials `x**n - 1` and `x**n + 1` are factored
    using cyclotomic decomposition to speedup computations. To
    disable this behaviour set cyclotomic=False.

    References
    ==========

    .. [1] [Gathen99]_

    rd   Nr§   c                 S   s&   g | ]\}}|  ¡ d d d… |f‘qS )Nr§   )Zcoeffs)rz   ÚfacÚexprr   rr   rs   r°   °  s     z!dup_zz_factor.<locals>.<listcomp>r   rf   rÔ   rÕ   )r   re   rn   rZ   rH   r   r   r'   r[   rÀ   rV   rÓ   r»   rt   rX   )rj   rl   Zf_flintrÖ   rk   rŽ   rŠ   r•   rr   rr   rs   Údup_zz_factor  s2    .




rÚ   c                 C   sp   || g}| D ]T}t |ƒ}t|ƒD ]4}|dkrD| ||¡}|| }q&| |¡r"  dS q"| |¡ q|dd… S )z,Wang/EEZ: Compute a set of valid divisors.  rf   N)r€   ÚreversedÚgcdrÒ   ri   )ÚEÚcsÚctrl   rm   rp   rq   rr   rr   rs   Údmp_zz_wang_non_divisorsÓ  s    



rà   c                    sº   t t| ˆƒˆ |d ˆƒs tdƒ‚t | ˆ |ˆƒ}t|ˆƒs@tdƒ‚t|ˆƒ\}}ˆ t|ˆƒ¡rp| t|ˆƒ }}|d ‰‡ ‡‡fdd„|D ƒ}	t|	||ˆƒ}
|
dk	r®|||	fS tdƒ‚dS )z2Wang/EEZ: Test evaluation points for suitability. rf   zno luckc                    s   g | ]\}}t |ˆ ˆˆƒ‘qS rr   )rJ   )rz   r‘   r¢   ©r·   rl   Úvrr   rs   r°   ø  s     z+dmp_zz_wang_test_points.<locals>.<listcomp>N)	rJ   r   r_   rS   rH   rÆ   r   r'   rà   )rj   r˜   rß   r·   ru   rl   rŽ   r–   r�   rÝ   ÚDrr   rá   rs   Údmp_zz_wang_test_pointsç  s    

rä   c              	   C   sò  g dgt |ƒ |d   }}	}
|D ]ž}t|
|ƒ}t||ƒ| }ttt |ƒƒƒD ]f}d|| ||   }}\}}|| sŠ|| |d  }}qn|dkrNt|t|||
|ƒ|
|ƒd }|	|< qN| |¡ q"t|	ƒsÎt	‚g g  }}t
||ƒD ]Œ\}}t|||
|ƒ}t||ƒ}| |¡�r|| }n4| ||¡}|| ||  }}t|||ƒ||  }}t|||
|ƒ}| |¡ | |¡ qâ| |¡�r†| ||fS g g  }}t
||ƒD ]2\}}| t|||
|ƒ¡ | t||d|ƒ¡ �qšt| |t |ƒd  ||ƒ} | ||fS )z0Wang/EEZ: Compute correct leading coefficients. r   rf   )rš   r   r   rÛ   r�   r.   r0   ri   Úallr\   ÚziprJ   rÒ   rÜ   r=   r>   )rj   r˜   rÞ   rÝ   r•   r·   ru   rl   r¹   ÚJrâ   r�   r–   r�   r±   ro   r“   r‘   r¢   ÚCCZHHr…   ÚccrŽ   ZCCCZHHHrr   rr   rs   Údmp_zz_wang_lead_coeffs  sB    
$





rê   c              	   C   sŽ  t | ƒdkr”| \}}t||ƒ}t||ƒ}t||||ƒ\}}	}
t|||ƒ}t|	||ƒ}	t||||ƒ\}}t|	||||ƒ}	t||ƒ}t|	|ƒ}	||	g}nö| d g}
t| dd… ƒD ]}|
 dt	||
d |ƒ¡ q®g dgg }}t
| |
ƒD ]<\}}t||g|d g d|d|ƒ\}	}| |	¡ | |¡ qäg ||d g  }}t
|| ƒD ]H\}}t||ƒ}t||ƒ}tt|||ƒ|||ƒ}t||ƒ}| |¡ �q@|S )z2Wang/EEZ: Solve univariate Diophantine equations. rx   r§   rf   r   )rš   r   r   r   r	   r   r   rÛ   rÅ   r-   ræ   Údmp_zz_diophantineri   r
   )r¡   r�   rŸ   rl   rˆ   r‰   rj   rŽ   r�   r‘   r”   rp   rm   r—   r˜   rq   rr   rr   rs   Údup_zz_diophantine7  s8    





 



rì   c              	      s¶  |sˆdd„ | D ƒ}t |ƒ}t|ƒD ]`\}	}
|
s0q"t| ||	 ˆˆ ƒ}tt||ƒƒD ]0\}\}}t||
ˆ ƒ}tt||ˆ ƒˆˆ ƒ||< qPq"�n*t|ƒ}t| ˆˆ ƒ}|d |dd…  }}g g  }}| D ].}| 	t
||ˆˆ ƒ¡ | 	t|||ˆˆ ƒ¡ qÀt|||ˆˆ ƒ}ˆd ‰t||||ˆˆˆ ƒ}‡ ‡fdd„|D ƒ}t||ƒD ]\}}t|||ˆˆ ƒ}�q:t|ˆˆˆ ƒ}tˆ j| g|ˆ ƒ}t|ˆ ƒ}td|ƒD �]}t|ˆƒ�r¤ �qœt||ˆˆ ƒ}t||d ||ˆˆ ƒ}t|ˆƒ�sŒt|ˆ  ˆ |ƒd ¡ˆˆ ƒ}t||||ˆˆˆ ƒ}t|ƒD ]&\}	}tt|dˆˆ ƒ|ˆˆ ƒ||	< �qtt||ƒƒD ] \}	\}}t||ˆˆ ƒ||	< �qBt||ƒD ]\}}t|||ˆˆ ƒ}�qnt|ˆˆˆ ƒ}�qŒ‡ ‡‡fdd„|D ƒ}|S )	z4Wang/EEZ: Solve multivariate Diophantine equations. c                 S   s   g | ]}g ‘qS rr   rr   ©rz   r¢   rr   rr   rs   r°   j  s     z&dmp_zz_diophantine.<locals>.<listcomp>r§   Nrf   c                    s   g | ]}t |d ˆˆ ƒ‘qS ©rf   )r   ©rz   r�   )rl   râ   rr   rs   r°   †  s     r   c                    s   g | ]}t |ˆˆˆ ƒ‘qS rr   )rD   rï   )rl   rŸ   ru   rr   rs   r°   ¦  s     )r   Ú	enumeraterì   ræ   r=   rC   r)   rš   r5   ri   r4   rK   rë   r8   rD   r   rŒ   r   r�   r   r.   rL   r@   Ú	factorialr   r*   )r¡   r–   r·   r�   rŸ   ru   rl   r—   rŠ   r±   rÉ   r˜   Újr�   r‘   r“   rˆ   r¸   r”   rj   r¹   r‰   r�   r’   ro   rr   )rl   rŸ   ru   râ   rs   rë   g  sV     

 rë   c              
   C   s   | gt |ƒ|d   }}}	t|ƒ}tt|dd… ƒƒD ]>\}
}t|d |||
 ||
 |ƒ}| dt|||	|
 |ƒ¡ q6tt| |ƒdd… ƒ}t	t
d|d ƒ||ƒD �]Ú\}}}t|ƒ|d  }}|d|d … ||d d…  }}tt	||ƒƒD ]L\}
\}}tt|||	|ƒ||d |ƒ}|gt|dd… d|d |ƒ ||
< qðt|j| g||ƒ}t||ƒ}t|t|||ƒ||ƒ}t|||ƒ}t
d|ƒD ]ô}t||ƒ�rœ q¢t||||ƒ}t||d ||||ƒ}t||d ƒ�sˆt|| ||ƒd ¡|d |ƒ}t||||||d |ƒ}tt	||ƒƒD ]>\}
\}}t|t|d|d |ƒ|||ƒ}t||||ƒ||
< �qt|t|||ƒ||ƒ}t||||ƒ}�qˆq¢t|||ƒ| k�r˜t‚n|S dS )z-Wang/EEZ: Parallel Hensel lifting algorithm. rf   Nr   rx   )rš   Úlistrð   rÛ   rK   rÅ   rD   Úmaxr   ræ   r�   rJ   r   r   rŒ   r   r,   r5   r   r   r.   rL   r@   rñ   rë   r6   r\   )rj   r•   ÚLCr·   rŸ   ru   rl   r—   rŠ   râ   r±   rˆ   r�   r�   rò   r”   ÚwÚIrç   r�   r…   r�   r’   r–   Zdjro   r¹   r˜   r‘   rr   rr   rs   Údmp_zz_wang_hensel_lifting«  s@    ""&
 rø   c              	      sN  ddl m} t|ƒ‰tt| ˆ ƒ|d ˆ ƒ\}}t| |ˆ ƒ}ˆ ||ƒƒ}	ˆdkr`|dkr\d‰nd‰tƒ g ˆ jg| df\}
}}}zRt| ||||ˆ ƒ\}}}t	|ˆ ƒ\}}t
|ƒ}|dkr¾| gW S |||||fg}W n tk
rä   Y nX tdƒ}tdƒ}tdƒ}t
|ƒ|k �r"t|ƒD �] }‡ ‡‡fd	d
„t|ƒD ƒ}t|ƒ|
k�r|
 t|ƒ¡ n�qzt| ||||ˆ ƒ\}}}W n tk
�rŽ   Y �qY nX t	|ˆ ƒ\}}t
|ƒ}|dk	�rÖ||k�rÚ||k �rg | }}n�qn|}|dk�rî| g  S | |||||f¡ t
|ƒ|k�r qþ�qˆ|7 ‰qþd\}}}|D ]D\}}}}}t|ˆ ƒ}|dk	�rf||k �rj|}|}n|}|d7 }�q0|| \}}}}}| }z4t| ||||||ˆ ƒ\} }}t| ||||	|ˆ ƒ}W n> tk
�rþ   tdƒ�ròt||ˆ ˆd ƒ Y S tdƒ‚Y nX g }|D ]@} t| |ˆ ƒ\}} ˆ  t| |ˆ ƒ¡�r<t| |ˆ ƒ} | | ¡ �q|S )a`  
    Factor primitive square-free polynomials in `Z[X]`.

    Given a multivariate polynomial `f` in `Z[x_1,...,x_n]`, which is
    primitive and square-free in `x_1`, computes factorization of `f` into
    irreducibles over integers.

    The procedure is based on Wang's Enhanced Extended Zassenhaus
    algorithm. The algorithm works by viewing `f` as a univariate polynomial
    in `Z[x_2,...,x_n][x_1]`, for which an evaluation mapping is computed::

                      x_2 -> a_2, ..., x_n -> a_n

    where `a_i`, for `i = 2, \dots, n`, are carefully chosen integers.  The
    mapping is used to transform `f` into a univariate polynomial in `Z[x_1]`,
    which can be factored efficiently using Zassenhaus algorithm. The last
    step is to lift univariate factors to obtain true multivariate
    factors. For this purpose a parallel Hensel lifting procedure is used.

    The parameter ``seed`` is passed to _randint and can be used to seed randint
    (when an integer) or (for testing purposes) can be a sequence of numbers.

    References
    ==========

    .. [1] [Wang78]_
    .. [2] [Geddes92]_

    r   )Ú	nextprimerf   Nrx   ZEEZ_NUMBER_OF_CONFIGSZEEZ_NUMBER_OF_TRIESZEEZ_MODULUS_STEPc                    s   g | ]}ˆ ˆˆ ˆƒƒ‘qS rr   rr   rí   ©rl   ÚmodÚrandintrr   rs   r°   "  s     zdmp_zz_wang.<locals>.<listcomp>)Nr   r   ZEEZ_RESTART_IF_NEEDEDz3we need to restart algorithm with better parameters)r²   rù   r   Údmp_zz_factorr   r‹   r¶   Úzerorä   r×   rš   r_   r[   r�   ÚtupleÚaddri   r:   rê   rø   r\   Údmp_zz_wangrI   rÆ   r   r(   )rj   ru   rl   rû   Úseedrù   rß   r˜   r‰   rŸ   ÚhistoryZconfigsr·   rq   rÞ   r�   rÝ   r¢   r•   Zeez_num_configsZeez_num_triesZeez_mod_stepZrrZs_normZs_argr±   Z_s_normÚorig_frõ   rk   rm   rr   rú   rs   r  ß  s’    










ÿ
r  c           	      C   s  |st | |ƒS t| |ƒr"|jg fS t| ||ƒ\}}t|||ƒdk rV| t|||ƒ }}tdd„ t||ƒD ƒƒrv|g fS t|||ƒ\}}g }t	||ƒdkr¾t
|||ƒ}t|||ƒ}t| |||ƒ}t||d |ƒd D ]\}}| d|g|f¡ qÒt| ||ƒ |t|ƒfS )aÜ  
    Factor (non square-free) polynomials in `Z[X]`.

    Given a multivariate polynomial `f` in `Z[x]` computes its complete
    factorization `f_1, \dots, f_n` into irreducibles over integers::

                 f = content(f) f_1**k_1 ... f_n**k_n

    The factorization is computed by reducing the input polynomial
    into a primitive square-free polynomial and factoring it using
    Enhanced Extended Zassenhaus (EEZ) algorithm. Trial division
    is used to recover the multiplicities of factors.

    The result is returned as a tuple consisting of::

             (content(f), [(f_1, k_1), ..., (f_n, k_n))

    Consider polynomial `f = 2*(x**2 - y**2)`::

        >>> from sympy.polys import ring, ZZ
        >>> R, x,y = ring("x,y", ZZ)

        >>> R.dmp_zz_factor(2*x**2 - 2*y**2)
        (2, [(x - y, 1), (x + y, 1)])

    In result we got the following factorization::

                    f = 2 (x - y) (x + y)

    References
    ==========

    .. [1] [Gathen99]_

    r   c                 s   s   | ]}|d kV  qdS ©r   Nrr   ©rz   r�   rr   rr   rs   r|   œ  s     z dmp_zz_factor.<locals>.<genexpr>rf   )rÚ   r   rþ   rI   r   r(   rå   r   rP   r   rW   r  rv   rý   rÅ   rY   rZ   )	rj   ru   rl   rÖ   rŽ   r”   rk   r•   ro   rr   rr   rs   rý   m  s&    $


rý   c                    sJ   ˆ   ¡ ‰t| ˆ ˆƒ} t| ˆƒ\}}‡ ‡fdd„|D ƒ}ˆ  |ˆ¡}||fS )z>Factor univariate polynomials into irreducibles in `QQ_I[x]`. c                    s    g | ]\}}t |ˆˆ ƒ|f‘qS rr   )r   ©rz   rØ   r±   ©rÈ   ÚK1rr   rs   r°   ¶  s     z#dup_qq_i_factor.<locals>.<listcomp>)Úas_AlgebraicFieldr   rÄ   r´   )rj   rÈ   rÉ   rk   rr   r  rs   Údup_qq_i_factor°  s    r  c                 C   s˜   |  ¡ }t| ||ƒ} t| |ƒ\}}g }|D ]T\}}t||ƒ\}}	t|	||ƒ}
t|
d|ƒ\}}|||  ||  }| ||f¡ q*|}| ||¡}||fS )z>Factor univariate polynomials into irreducibles in `ZZ_I[x]`. r   )Ú	get_fieldr   r  rA   rI   ri   r´   )rj   rÈ   r	  rÉ   rk   Únew_factorsrØ   r±   Ú	fac_denomÚfac_numÚfac_num_ZZ_IÚcontentÚfac_primrr   rr   rs   Údup_zz_i_factor»  s    r  c                    sP   ˆ   ¡ ‰t| ˆˆ ˆƒ} t| ˆˆƒ\}}‡ ‡‡fdd„|D ƒ}ˆ  |ˆ¡}||fS )z@Factor multivariate polynomials into irreducibles in `QQ_I[X]`. c                    s"   g | ]\}}t |ˆˆˆ ƒ|f‘qS rr   )r   r  ©rÈ   r	  ru   rr   rs   r°   ×  s     z#dmp_qq_i_factor.<locals>.<listcomp>)r
  r   Údmp_factor_listr´   )rj   ru   rÈ   rÉ   rk   rr   r  rs   Údmp_qq_i_factorÑ  s    r  c                 C   s    |  ¡ }t| |||ƒ} t| ||ƒ\}}g }|D ]X\}}t|||ƒ\}	}
t|
|||ƒ}t|||ƒ\}}|||  |	|  }| ||f¡ q.|}| ||¡}||fS )z@Factor multivariate polynomials into irreducibles in `ZZ_I[X]`. )r  r   r  rB   rI   ri   r´   )rj   ru   rÈ   r	  rÉ   rk   r  rØ   r±   r  r  r  r  r  rr   rr   rs   Údmp_zz_i_factorÜ  s    r  c                 C   s  t | ƒt| |ƒ }}t| |ƒ} |dkr.|g fS |dkrD|| dfgfS t| |ƒ|  } }t| |ƒ\}}}t||jƒ}t|ƒdkr’|| |t | ƒ fgfS ||j }	t	|ƒD ]@\}
\}}t
||j|ƒ}t|||ƒ\}}}t||	|ƒ}|||
< q¤t|||ƒ}t||ƒ ||fS )aN	  Factor univariate polynomials over algebraic number fields.

    The domain `K` must be an algebraic number field `k(a)` (see :ref:`QQ(a)`).

    Examples
    ========

    First define the algebraic number field `K = \mathbb{Q}(\sqrt{2})`:

    >>> from sympy import QQ, sqrt
    >>> from sympy.polys.factortools import dup_ext_factor
    >>> K = QQ.algebraic_field(sqrt(2))

    We can now factorise the polynomial `x^2 - 2` over `K`:

    >>> p = [K(1), K(0), K(-2)] # x^2 - 2
    >>> p1 = [K(1), -K.unit]    # x - sqrt(2)
    >>> p2 = [K(1), +K.unit]    # x + sqrt(2)
    >>> dup_ext_factor(p, K) == (K.one, [(p1, 1), (p2, 1)])
    True

    Usually this would be done at a higher level:

    >>> from sympy import factor
    >>> from sympy.abc import x
    >>> factor(x**2 - 2, extension=sqrt(2))
    (x - sqrt(2))*(x + sqrt(2))

    Explanation
    ===========

    Uses Trager's algorithm. In particular this function is algorithm
    ``alg_factor`` from [Trager76]_.

    If `f` is a polynomial in `k(a)[x]` then its norm `g(x)` is a polynomial in
    `k[x]`. If `g(x)` is square-free and has irreducible factors `g_1(x)`,
    `g_2(x)`, `\cdots` then the irreducible factors of `f` in `k(a)[x]` are
    given by `f_i(x) = \gcd(f(x), g_i(x))` where the GCD is computed in
    `k(a)[x]`.

    The first step in Trager's algorithm is to find an integer shift `s` so
    that `f(x-sa)` has square-free norm. Then the norm is factorized in `k[x]`
    and the GCD of (shifted) `f` with each factor gives the shifted factors of
    `f`. At the end the shift is undone to recover the unshifted factors of `f`
    in `k(a)[x]`.

    The algorithm reduces the problem of factorization in `k(a)[x]` to
    factorization in `k[x]` with the main additional steps being to compute the
    norm (a resultant calculation in `k[x,y]`) and some polynomial GCDs in
    `k(a)[x]`.

    In practice in SymPy the base field `k` will be the rationals :ref:`QQ` and
    this function factorizes a polynomial with coefficients in an algebraic
    number field  like `\mathbb{Q}(\sqrt{2})`.

    See Also
    ========

    dmp_ext_factor:
        Analogous function for multivariate polynomials over ``k(a)``.
    dup_sqf_norm:
        Subroutine ``sqfr_norm`` also from [Trager76]_.
    sympy.polys.polytools.factor:
        The high-level function that ultimately uses this function as needed.
    r   rf   )r   r   rF   rV   rT   Údup_factor_list_includeÚdomrš   Úunitrð   r   rQ   rM   rt   rX   )rj   rl   rŠ   r…   r¡   r�   rŽ   rq   rk   r•   r±   rn   r¢   r�   rr   rr   rs   Údup_ext_factorò  s(    B



r  c                    s  |st | ˆ ƒS t| |ˆ ƒ}t| |ˆ ƒ} tdd„ t| |ƒD ƒƒrF|g fS t| |ˆ ƒ|  } }t| |ˆ ƒ\}}}t||ˆ jƒ}t	|ƒdkrŒ| g}nbt
|ƒD ]X\}	\}
}t|
|ˆ jˆ ƒ}t|||ˆ ƒ\}}}‡ fdd„|D ƒ}t|||ˆ ƒ}|||	< q”t|||ˆ ƒ}t|||ƒ ||fS )a®  Factor multivariate polynomials over algebraic number fields.

    The domain `K` must be an algebraic number field `k(a)` (see :ref:`QQ(a)`).

    Examples
    ========

    First define the algebraic number field `K = \mathbb{Q}(\sqrt{2})`:

    >>> from sympy import QQ, sqrt
    >>> from sympy.polys.factortools import dmp_ext_factor
    >>> K = QQ.algebraic_field(sqrt(2))

    We can now factorise the polynomial `x^2 y^2 - 2` over `K`:

    >>> p = [[K(1),K(0),K(0)], [], [K(-2)]] # x**2*y**2 - 2
    >>> p1 = [[K(1),K(0)], [-K.unit]]       # x*y - sqrt(2)
    >>> p2 = [[K(1),K(0)], [+K.unit]]       # x*y + sqrt(2)
    >>> dmp_ext_factor(p, 1, K) == (K.one, [(p1, 1), (p2, 1)])
    True

    Usually this would be done at a higher level:

    >>> from sympy import factor
    >>> from sympy.abc import x, y
    >>> factor(x**2*y**2 - 2, extension=sqrt(2))
    (x*y - sqrt(2))*(x*y + sqrt(2))

    Explanation
    ===========

    This is Trager's algorithm for multivariate polynomials. In particular this
    function is algorithm ``alg_factor`` from [Trager76]_.

    See :func:`dup_ext_factor` for explanation.

    See Also
    ========

    dup_ext_factor:
        Analogous function for univariate polynomials over ``k(a)``.
    dmp_sqf_norm:
        Multivariate version of subroutine ``sqfr_norm`` also from [Trager76]_.
    sympy.polys.polytools.factor:
        The high-level function that ultimately uses this function as needed.
    c                 s   s   | ]}|d kV  qdS r  rr   r  rr   rr   rs   r|   ‰  s     z!dmp_ext_factor.<locals>.<genexpr>rf   c                    s   g | ]}|ˆ j  ‘qS rr   )r  )rz   Úsi©rl   rr   rs   r°   —  s     z"dmp_ext_factor.<locals>.<listcomp>)r  r   rG   rå   r   rW   rU   Údmp_factor_list_includer  rš   rð   r   rR   rN   rv   rY   )rj   ru   rl   r…   r¡   r�   rŽ   rq   rk   r±   rn   r¢   r�   rˆ   rm   rr   r  rs   Údmp_ext_factorT  s(    /

r  c                 C   s`   t | ||jƒ} t| |j|jƒ\}}t|ƒD ]"\}\} }t | |j|ƒ|f||< q*| ||j¡|fS )z2Factor univariate polynomials over finite fields. )r   r  r   rû   rð   r´   )rj   rl   rÉ   rk   r±   ro   rr   rr   rs   Údup_gf_factor¢  s
    r   c                 C   s   t dƒ‚dS )z4Factor multivariate polynomials over finite fields. z+multivariate polynomials over finite fieldsN)ÚNotImplementedError)rj   ru   rl   rr   rr   rs   Údmp_gf_factor®  s    r"  c                 C   sD  t | |ƒ\}} t| |ƒ\}} |jr4t| |ƒ\}}�nâ|jrLt| |ƒ\}}�nÊ|jrdt| |ƒ\}}�n²|jr|t	| |ƒ\}}�nš|j
sž|| ¡  }}t| ||ƒ} nd}|jrÎ| ¡ }t| ||ƒ\}} t| ||ƒ} n|}|jrèt| |ƒ\}}nr|j�rNt| d|ƒ\} }	t| |	|jƒ\}}t|ƒD ]"\}
\} }t| |	|ƒ|f||
< �q| ||j¡}ntd| ƒ‚|j�rt|ƒD ]"\}
\} }t| ||ƒ|f||
< �qj| ||¡}| ||¡}|�rt|ƒD ]P\}
\} }t| |ƒ}t| ||ƒ} t| ||ƒ} | |f||
< | || ||¡¡}�q´| ||¡}|}|�r4| d|j |j!g|f¡ || t"|ƒfS )ú;Factor univariate polynomials into irreducibles in `K[x]`. Nr   ú#factorization not supported over %s)#r%   rH   Úis_FiniteFieldr   Úis_Algebraicr  Úis_GaussianRingr  Úis_GaussianFieldr  Úis_ExactÚ	get_exactr   Úis_FieldrÂ   rA   rÃ   rÚ   Úis_Polyr#   r  r  rð   r$   r´   r]   Úquor:   r?   ÚmulÚpowrÅ   rŒ   rþ   rZ   )rj   rÈ   rò   rÖ   rÉ   rk   Ú
K0_inexactrl   Údenomru   r±   ro   Úmax_normrr   rr   rs   rÄ   ³  sZ    
rÄ   c                 C   sX   t | |ƒ\}}|s"t|gƒdfgS t|d d ||ƒ}||d d fg|dd…  S dS )r#  rf   r   N)rÄ   r   r=   )rj   rl   rÉ   rk   rŽ   rr   rr   rs   r  õ  s
    r  c                 C   sê  |st | |ƒS t| ||ƒ\}} t| ||ƒ\}} |jrHt| ||ƒ\}}�n:|jrbt| ||ƒ\}}�n |jr|t| ||ƒ\}}�n|j	r–t
| ||ƒ\}}�nì|jsº|| ¡  }}t| |||ƒ} nd}|jrî| ¡ }t| |||ƒ\}	} t| |||ƒ} n|}|j�rLt| ||ƒ\}
} }t| ||ƒ\}}t|ƒD ]$\}\} }t| |
||ƒ|f||< �q$nr|j�r²t| ||ƒ\} }t| ||jƒ\}}t|ƒD ]"\}\} }t| ||ƒ|f||< �q~| ||j¡}ntd| ƒ‚|j�r‚t|ƒD ]$\}\} }t| |||ƒ|f||< �qÎ| ||¡}| ||	¡}|�r‚t|ƒD ]V\}\} }t| ||ƒ}t| |||ƒ} t| |||ƒ} | |f||< |  || !||¡¡}�q| ||¡}|}tt"|ƒƒD ]J\}}|�s �qŽd||  d d|  |j#i}| $dt%|||ƒ|f¡ �qŽ|| t&|ƒfS )ú=Factor multivariate polynomials into irreducibles in `K[X]`. Nr$  )r   rî   r   )'rÄ   r&   rI   r%  r"  r&  r  r'  r  r(  r  r)  r*  r   r+  rÂ   rB   rÃ   r!   rý   rð   r"   r,  r#   r  r  r$   r´   r]   r-  r;   r@   r.  r/  rÛ   rŒ   rÅ   r   rZ   )rj   ru   rÈ   rç   rÖ   rÉ   rk   r0  rl   r1  Zlevelsrâ   r±   ro   r2  rò   Útermrr   rr   rs   r     sj    
r  c                 C   sj   |st | |ƒS t| ||ƒ\}}|s2t||ƒdfgS t|d d |||ƒ}||d d fg|dd…  S dS )r3  rf   r   N)r  r  r   r>   )rj   ru   rl   rÉ   rk   rŽ   rr   rr   rs   r  M  s    
r  c                 C   s   t | d|ƒS )z_
    Returns ``True`` if a univariate polynomial ``f`` has no factors
    over its domain.
    r   )Údmp_irreducible_p)rj   rl   rr   rr   rs   Údup_irreducible_p[  s    r6  c                 C   s@   t | ||ƒ\}}|sdS t|ƒdkr(dS |d \}}|dkS dS )za
    Returns ``True`` if a multivariate polynomial ``f`` has no factors
    over its domain.
    Trf   Fr   N)r  rš   )rj   ru   rl   r¢   rk   ro   rr   rr   rs   r5  c  s    r5  )F)NN)šÚ__doc__Zsympy.external.gmpyr   Zsympy.core.randomr   Zsympy.polys.galoistoolsr   r   r   r   r   r	   r
   r   r   r   r   Zsympy.polys.densebasicr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   Zsympy.polys.densearithr'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   Zsympy.polys.densetoolsrA   rB   rC   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   Zsympy.polys.euclidtoolsrP   rQ   rR   Zsympy.polys.sqfreetoolsrS   rT   rU   rV   rW   rX   rY   Zsympy.polys.polyutilsrZ   Zsympy.polys.polyconfigr[   Zsympy.polys.polyerrorsr\   r]   r^   r_   Zsympy.utilitiesr`   Úmathra   r}   rb   r³   rc   rœ   rd   re   rt   rv   r‡   r‹   r™   rž   r¥   r»   rÀ   rÇ   rË   rÏ   rÓ   r×   rÚ   rà   rä   rê   rì   rë   rø   r  rý   r  r  r  r  r  r  r   r"  rÄ   r  r  r  r6  r5  rr   rr   rr   rs   Ú<module>   sl   4hpD
$
<	99i
S,T60D4
 CbNBM