o
    §ƒð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   sb   g }|D ](}d}	 t | ||ƒ\}}|s||d } }nnq	|dkr%t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   Té   útrial division failed)r1   ÚRuntimeErrorÚappendrZ   )ÚfÚfactorsÚKÚresultÚfactorÚkÚqÚr© rr   ú™/tmp/claude-1000/-var-www-html-academy/3f42efd1-c2b7-4d08-9b05-30d86bb35479/scratchpad/piper/venv/lib/python3.10/site-packages/sympy/polys/factortools.pyÚdup_trial_divisionX   s   úrt   c           	      C   sj   g }|D ],}d}	 t | |||ƒ\}}t||ƒr||d } }nnq	|dkr)t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   Trf   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>¿   ó   € z(dup_zz_mignotte_bound.<locals>.<genexpr>rf   )	Ú(sympy.functions.combinatorial.factorialsrw   r   Ú_ceilÚsqrtÚsumÚabsr   r:   )rj   rl   rw   ÚdÚdeltaÚdelta2Ú	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   st  t |ƒ}t||ƒ}|dkr$t|| || | ¡d |ƒ}t|| | |ƒgS | }|d }	ttt|ƒƒƒ}
t|g| ƒ}|d|	… D ]}t	|t|| ƒ| |ƒ}q>t||	 | ƒ}||	d d… D ]}t	|t|| ƒ| |ƒ}qZt
||| |ƒ\}}}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=   ÚgcdexrC   Úintr   Ú_log2r   r   r   r   Úranger�   Údup_zz_hensel_lift)Úprj   Úf_listÚlrl   rq   r‰   ÚFr‘   ro   rƒ   r’   Ú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                    sv  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 ];}||ƒro|| dkrpqc| |¡}t| |ƒ}t|||ƒs�qct|||ƒd }| ||f¡ t|ƒdk sœt|ƒdkrž nqct|d	d
„ d�\‰}ttt
d| d ˆƒƒƒ}‡fdd„|D ƒ}tˆ| |||ƒ}tt|ƒƒ}t|ƒ}g d}}ˆ| }d| t|ƒk�r¶t||ƒD ]Á‰ |dk�rd}ˆ D ]
}||| d  }qó|| }t|||ƒ�s
qèn-|g}ˆ D ]}t||| |ƒ}�qt|||ƒ}t||ƒd }|d }|�r8|| dk�r8qè|g}tˆ ƒ‰ |ˆ  }|dk�r_|g}ˆ D ]}t||| |ƒ}�qMt|||ƒ}|D ]}t||| |ƒ}�qat|||ƒ}t||ƒ}t||ƒ}|| |k�r©|}‡ fdd„|D ƒ}t||ƒd }t||ƒd } | |¡ t| |ƒ} nqè|d7 }d| t|ƒksã|| 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  s    z#dup_zz_zassenhaus.<locals>.<lambda>)Úkeyc                    s   g | ]}t |ˆ ƒ‘qS rr   )r   )rz   Úff)r¤   rr   rs   Ú
<listcomp>t  ó    z%dup_zz_zassenhaus.<locals>.<listcomp>c                    s   g | ]}|ˆ vr|‘qS rr   rr   )rz   Úi)r›   rr   rs   r¶   ¨  ó    )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Œ   Úpxr§   ÚfsqfxÚfsqfr¦   Úmodularr’   Úsorted_Trœ   rk   r”   r«   rp   r¸   r˜   r™   ÚT_SÚG_normÚH_normrr   )r›   r¤   rs   Údup_zz_zassenhausN  s–   

*$

ÿ

ÿ




öË
7rË   c                 C   sr   t | |ƒ}t| |ƒ}t| dd… |ƒ}|r5ddlm} |t|ƒƒ}| ¡ D ]}|| r4||d  r4 dS q%dS dS )z2Test irreducibility using Eisenstein's criterion. rf   Nr   ©Ú	factorintrx   T)r   r   rE   rº   rÍ   r    Úkeys)rj   rl   r‰   ÚtcÚe_fcrÍ   Úe_ffr¤   rr   rr   rs   Údup_zz_irreducible_p·  s   

€úrÒ   Fc                 C   s¶  |j rz|| ¡ }}t| ||ƒ} W n ty   Y dS w |js"dS t| |ƒ}t| |ƒ}|dks8|dkr:|dkr:dS |sQt| |ƒ\}}||jksO|| dfgkrQdS t	| ƒ}g g }	}
t
|ddƒD ]
}|	 d| | ¡ q`t
|d ddƒD ]
}|
 d| | ¡ qstt|	ƒ|ƒ}	tt|
ƒ|ƒ}
t|	t|
d|ƒ|ƒ}| t||ƒ¡r£t||ƒ}|| kr©d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)Ú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   ÚirreducibleÚK0r‰   rÏ   Úcoeffrk   rŽ   r’   r“   r¸   r§   r˜   rr   rr   rs   rÚ   Ç  sN   ÿ






rÚ   c                 C   s\   ddl m} |j|j g}|| ƒ ¡ D ]\}}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 ]*\‰}‡ ‡fdd„|D ƒ}| |¡ td|ƒD ]}‡ ‡fdd„|D ƒ}| |¡ q,q|S )Nr   rÌ   c                    s    g | ]}t t|ˆˆ ƒ|ˆ ƒ‘qS rr   )r3   r    )rz   r“   ©rl   r¤   rr   rs   r¶   ,  ó     z-_dup_cyclotomic_decompose.<locals>.<listcomp>rf   c                    s   g | ]}t |ˆˆ ƒ‘qS rr   )r    )rz   rp   rà   rr   rs   r¶   0  r¹   )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s|dvrdS tdd„ | dd… D ƒƒr,dS t| ƒ}t||ƒ}| |¡s<|S g }td| |ƒD ]}||vrP| |¡ qE|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  r}   z+dup_zz_cyclotomic_factor.<locals>.<genexpr>r®   rx   )r   r   r   Úanyrä   Úis_oneri   )rj   rl   Úlc_fÚtc_frŽ   r§   r™   r“   rr   rr   rs   Údup_zz_cyclotomic_factor6  s"   


€rê   c                 C   s¬   t | |ƒ\}}t|ƒ}t||ƒdk r| t||ƒ}}|dkr#|g fS |dkr,||gfS tdƒr:t||ƒr:||gfS d}tdƒrEt||ƒ}|du rNt||ƒ}|t|dd�fS )z:Factor square-free (non-primitive) polynomials in `Z[x]`. r   rf   ÚUSE_IRREDUCIBLE_IN_FACTORNÚUSE_CYCLOTOMIC_FACTORF)Ú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 r;| t||ƒ}}|dkrC|g fS |dkrN||dfgfS tdƒr^t	||ƒr^||dfgfS t
||ƒ}d}td	ƒrnt||ƒ}|du rwt||ƒ}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®   )Ú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   Úf_flintrî   rk   r’   rŽ   r™   rr   rr   rs   Údup_zz_factor  s2   .




rô   c                 C   sv   || g}| D ]-}t |ƒ}t|ƒD ]}|dkr%| ||¡}|| }|dks| |¡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|ˆƒ¡r8| t|ˆƒ}}|d ‰‡ ‡‡fdd„|D ƒ}	t|	||ˆƒ}
|
durW|||	fS tdƒ‚)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 ]R}t|
|ƒ}t||ƒ| }ttt |ƒƒƒD ]6}d|| || }}\}}|| sH|| |d }}|| r;|dkr]t|t|||
|ƒ|
|ƒd}|	|< q'| |¡ qt|	ƒsjt	‚g g }}t
||ƒD ]E\}}t|||
|ƒ}t||ƒ}| |¡rŽ|| }n| ||¡}|| || }}t|||ƒ|| }}t|||
|ƒ}| |¡ | |¡ qt| |¡rÄ| ||fS g g }}t
||ƒD ]\}}| 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©   ÚCCÚHHr‰   Úccr’   ÚCCCÚHHHrr   rr   rs   Údmp_zz_wang_lead_coeffs  sF   
ÿ"€








r  c              	   C   sŽ  t | ƒdkrK| \}}t||ƒ}t||ƒ}t||||ƒ\}}	}
t|||ƒ}t|	||ƒ}	t||||ƒ\}}t|	||||ƒ}	t||ƒ}t|	|ƒ}	||	g}|S | d g}
t| dd… ƒD ]}|
 dt	||
d |ƒ¡ qXg dgg}}t
| |
ƒD ]\}}t||g|d g d|d|ƒ\}	}| |	¡ | |¡ qsg ||d g }}t
|| ƒD ]#\}}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  s:   




é 



r	  c              	      s¬  |sDdd„ | D ƒ}t |ƒ}t|ƒD ]0\}	}
|
sqt| ||	 ˆˆ ƒ}tt||ƒƒD ]\}\}}t||
ˆ ƒ}tt||ˆ ƒˆˆ ƒ||< q(q|S 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Î n{t||ˆˆ ƒ}t||d ||ˆˆ ƒ}t|ˆƒ�sHt|ˆ  ˆ |ƒd ¡ˆˆ ƒ}t||||ˆˆˆ ƒ}t|ƒD ]\}	}tt|dˆˆ ƒ|ˆˆ ƒ||	< �qtt||ƒƒD ]\}	\}}t||ˆˆ ƒ||	< �qt||ƒD ]\}}t|||ˆˆ ƒ}�q3t|ˆˆˆ ƒ}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¶   †  ó    r   c                    s   g | ]	}t |ˆˆˆ ƒ‘qS rr   )rD   r  )rl   r¤   ru   rr   rs   r¶   ¦  r  )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  s\   þ5Ï


 €r  c              
   C   s”  | gt |ƒ|d }}}	t|ƒ}tt|dd… ƒƒD ]\}
}t|d |||
 ||
 |ƒ}| dt|||	|
 |ƒ¡ qtt| |ƒdd… ƒ}t	t
d|d ƒ||ƒD ]ë\}}}t|ƒ|d }}|d|d … ||d d… }}tt	||ƒƒD ]&\}
\}}tt|||	|ƒ||d |ƒ}|gt|dd… d|d |ƒ ||
< qwt|j| g||ƒ}t||ƒ}t|t|||ƒ||ƒ}t|||ƒ}t
d|ƒD ]x}t||ƒrÌ npt||||ƒ}t||d ||||ƒ}t||d ƒ�s;t|| ||ƒd ¡|d |ƒ}t||||||d |ƒ}tt	||ƒƒD ]\}
\}}t|t|d|d |ƒ|||ƒ}t||||ƒ||
< �q	t|t|||ƒ||ƒ}t||||ƒ}qÃqQt|||ƒ| k�rHt‚|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š   Údjro   rÁ   rœ   r•   rr   rr   rs   Údmp_zz_wang_hensel_lifting«  sB    "&

 €r  c              	      s2  ddl m} t|ƒ‰tt| ˆ ƒ|d ˆ ƒ\}}t| |ˆ ƒ}ˆ ||ƒƒ}	ˆdu r0|dkr.d‰nd‰tƒ g ˆ jg| df\}
}}}z)t| ||||ˆ ƒ\}}}t	|ˆ ƒ\}}t
|ƒ}|dkr_| gW S |||||fg}W n	 tyq   Y nw tdƒ}tdƒ}tdƒ}t
|ƒ|k �rt|ƒD ]r}‡ ‡‡fd	d
„t|ƒD ƒ}t|ƒ|
vr¦|
 t|ƒ¡ nq‰zt| ||||ˆ ƒ\}}}W n	 ty¾   Y q‰w t	|ˆ ƒ\}}t
|ƒ}|durÞ||krÝ||k rÜg |}}nq‰n|}|dkré| g  S | |||||f¡ t
|ƒ|krû nq‰ˆ|7 ‰t
|ƒ|k s…d\}}}|D ]"\}}}}}t|ˆ ƒ}|du�r(||k �r'|}|}n|}|d7 }�q|| \}}}}}| }zt| ||||||ˆ ƒ\} }}t| ||||	|ˆ ƒ}W n t�yq   tdƒ�rmt||ˆ ˆd ƒ Y S tdƒ‚w g }|D ] } t| |ˆ ƒ\}} ˆ  t| |ˆ ƒ¡�r�t| |ˆ ƒ} | | ¡ �qv|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   ÚEEZ_NUMBER_OF_CONFIGSÚEEZ_NUMBER_OF_TRIESÚEEZ_MODULUS_STEPc                    s   g | ]
}ˆ ˆˆ ˆƒƒ‘qS rr   rr   r
  ©rl   ÚmodÚrandintrr   rs   r¶   "  s    zdmp_zz_wang.<locals>.<listcomp>)Nr   r   Ú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¤   ÚhistoryÚconfigsr¿   rq   rø   r”   r÷   r©   r™   Úeez_num_configsÚeez_num_triesÚeez_mod_stepÚrrÚs_normÚs_argr¸   Ú_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 r+| t|||ƒ}}tdd„ t||ƒD ƒƒr;|g fS t|||ƒ\}}g }t	||ƒdkr_t
|||ƒ}t|||ƒ}t| |||ƒ}t||d |ƒd D ]\}}| d|g|f¡ qit| ||ƒ |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   ó   � | ]}|d kV  qdS ©r   Nrr   ©rz   rƒ   rr   rr   rs   r|   œ  r}   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¶   ¶  rá   z#dup_qq_i_factor.<locals>.<listcomp>)Úas_AlgebraicFieldr   r×   r¼   )rj   rÜ   rÝ   rk   rr   r4  rs   Údup_qq_i_factor°  s   r7  c                 C   s˜   |  ¡ }t| ||ƒ} t| |ƒ\}}g }|D ]*\}}t||ƒ\}}	t|	||ƒ}
t|
d|ƒ\}}|||  ||  }| ||f¡ q|}| ||¡}||fS )z>Factor univariate polynomials into irreducibles in `ZZ_I[x]`. r   )Ú	get_fieldr   r7  rA   rI   ri   r¼   )rj   rÜ   r5  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   r3  ©rÜ   r5  ru   rr   rs   r¶   ×  s   " z#dmp_qq_i_factor.<locals>.<listcomp>)r6  r   Údmp_factor_listr¼   )rj   ru   rÜ   rÝ   rk   rr   r@  rs   Údmp_qq_i_factorÑ  s   rB  c                 C   s    |  ¡ }t| |||ƒ} t| ||ƒ\}}g }|D ],\}}t|||ƒ\}	}
t|
|||ƒ}t|||ƒ\}}|||  |	|  }| ||f¡ q|}| ||¡}||fS )z@Factor multivariate polynomials into irreducibles in `ZZ_I[X]`. )r8  r   rB  rB   rI   ri   r¼   )rj   ru   rÜ   r5  rÝ   rk   r9  rñ   r¸   r:  r;  r<  r=  r>  rr   rr   rs   Údmp_zz_i_factorÜ  s   rC  c                 C   s  t | ƒt| |ƒ}}t| |ƒ} |dkr|g fS |dkr"|| dfgfS t| |ƒ| } }t| |ƒ\}}}t||jƒ}t|ƒdkrI|| |t | ƒ fgfS ||j }	t	|ƒD ] \}
\}}t
||j|ƒ}t|||ƒ\}}}t||	|ƒ}|||
< qRt|||ƒ}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



rG  c                    s  |st | ˆ ƒS t| |ˆ ƒ}t| |ˆ ƒ} tdd„ t| |ƒD ƒƒr#|g fS t| |ˆ ƒ| } }t| |ˆ ƒ\}}}t||ˆ jƒ}t	|ƒdkrF| g}n1t
|ƒD ],\}	\}
}t|
|ˆ jˆ ƒ}t|||ˆ ƒ\}}}‡ fdd„|D ƒ}t|||ˆ ƒ}|||	< qJt|||ˆ ƒ}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   r0  r1  rr   r2  rr   rr   rs   r|   ‰  r}   z!dmp_ext_factor.<locals>.<genexpr>rf   c                    s   g | ]}|ˆ j  ‘qS rr   )rF  )rz   Úsi©rl   rr   rs   r¶   —  r·   z"dmp_ext_factor.<locals>.<listcomp>)rG  r   rG   rÿ   r   rW   rU   Údmp_factor_list_includerE  rž   r  r   rR   rN   rv   rY   )rj   ru   rl   r‰   r§   r”   r’   rq   rk   r¸   rn   r©   r“   rŒ   rm   rr   rI  rs   Údmp_ext_factorT  s(   /

rK  c                 C   s`   t | ||jƒ} t| |j|jƒ\}}t|ƒD ]\}\} }t | |j|ƒ|f||< q| ||j¡|fS )z2Factor univariate polynomials over finite fields. )r   rE  r   r  r  r¼   )rj   rl   rÝ   rk   r¸   ro   rr   rr   rs   Údup_gf_factor¢  s
   rL  c                 C   s   t dƒ‚)z4Factor multivariate polynomials over finite fields. z+multivariate polynomials over finite fields)ÚNotImplementedError)rj   ru   rl   rr   rr   rs   Údmp_gf_factor®  s   rN  c                 C   s4  t | |ƒ\}} t| |ƒ\}} |jrt| |ƒ\}}nê|jr$t| |ƒ\}}nß|jr/t| |ƒ\}}nÔ|jr:t	| |ƒ\}}nÉ|j
sK|| ¡ }}t| ||ƒ} nd}|jrc| ¡ }t| ||ƒ\}} t| ||ƒ} n|}|jrpt| |ƒ\}}n7|jr¡t| d|ƒ\} }	t| |	|jƒ\}}t|ƒD ]\}
\} }t| |	|ƒ|f||
< qˆ| ||j¡}ntd| ƒ‚|j�rt|ƒD ]\}
\} }t| ||ƒ|f||
< q¯| ||¡}| ||¡}|�rt|ƒD ]'\}
\} }t| |ƒ}t| ||ƒ} t| ||ƒ} | |f||
< | || ||¡¡}qÓ| ||¡}|}|�r| 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_FiniteFieldrL  Úis_AlgebraicrG  Úis_GaussianRingr?  Úis_GaussianFieldr7  Úis_ExactÚ	get_exactr   Úis_FieldrÕ   rA   rÖ   rô   Úis_Polyr#   rA  rE  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   sT   t | |ƒ\}}|st|gƒdfgS t|d d ||ƒ}||d d fg|dd…  S )rO  rf   r   N)r×   r   r=   )rj   rl   rÝ   rk   r’   rr   rr   rs   rD  õ  s
   rD  c                 C   sÜ  |st | |ƒS t| ||ƒ\}} t| ||ƒ\}} |jr$t| ||ƒ\}}�n|jr1t| ||ƒ\}}�n	|jr=t| ||ƒ\}}ný|j	rIt
| ||ƒ\}}nñ|js[|| ¡ }}t| |||ƒ} nd}|jru| ¡ }t| |||ƒ\}	} t| |||ƒ} n|}|jr¢t| ||ƒ\}
} }t| ||ƒ\}}t|ƒD ]\}\} }t| |
||ƒ|f||< q�n7|jrÓt| ||ƒ\} }t| ||jƒ\}}t|ƒD ]\}\} }t| ||ƒ|f||< qº| ||j¡}ntd| ƒ‚|j�r:t|ƒD ]\}\} }t| |||ƒ|f||< qá| ||¡}| ||	¡}|�r:t|ƒD ]+\}\} }t| ||ƒ}t| |||ƒ} t| |||ƒ} | |f||< |  || !||¡¡}�q| ||¡}|}tt"|ƒƒD ]%\}}|�sI�q@d||  d d|  |j#i}| $dt%|||ƒ|f¡ �q@|| t&|ƒfS )ú=Factor multivariate polynomials into irreducibles in `K[X]`. NrP  )r   r  r   )'r×   r&   rI   rQ  rN  rR  rK  rS  rC  rT  rB  rU  rV  r   rW  rÕ   rB   rÖ   r!   r   r  r"   rX  r#   rA  rE  r$   r¼   r]   rY  r;   r@   rZ  r[  rõ   r�   rØ   r   rZ   )rj   ru   rÜ   r  rî   rÝ   rk   r\  rl   r]  Úlevelsrü   r¸   ro   r^  r  Útermrr   rr   rs   rA     sl   
ÿrA  c                 C   sf   |st | |ƒS t| ||ƒ\}}|st||ƒdfgS t|d d |||ƒ}||d d fg|dd…  S )r_  rf   r   N)rD  rA  r   r>   )rj   ru   rl   rÝ   rk   r’   rr   rr   rs   rJ  M  s   
rJ  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   rc  c                 C   s<   t | ||ƒ\}}|sdS t|ƒdkrdS |d \}}|dkS )za
    Returns ``True`` if a multivariate polynomial ``f`` has no factors
    over its domain.
    Trf   Fr   )rA  rž   )rj   ru   rl   r©   rk   ro   rr   rr   rs   rb  c  s   rb  )F)NN)šÚ__doc__Úsympy.external.gmpyr   Úsympy.core.randomr   Úsympy.polys.galoistoolsr   r   r   r   r   r	   r
   r   r   r   r   Ú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&   Ú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@   Úsympy.polys.densetoolsrA   rB   rC   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   Úsympy.polys.euclidtoolsrP   rQ   rR   Úsympy.polys.sqfreetoolsrS   rT   rU   rV   rW   rX   rY   Úsympy.polys.polyutilsrZ   Úsympy.polys.polyconfigr[   Úsympy.polys.polyerrorsr\   r]   r^   r_   Ú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   r7  r?  rB  rC  rG  rK  rL  rN  r×   rD  rA  rJ  rc  rb  rr   rr   rr   rs   Ú<module>   sn    4hpD
$
<	99i
S,T60D
4 CbNBM