
    \h                        S r SSKJr  SSKJr  SSKJrJrJrJ	r	J
r
JrJrJrJrJrJr  SSKJrJrJrJrJrJrJrJrJrJrJrJrJrJrJ r J!r!J"r"J#r#J$r$J%r%J&r&J'r'J(r(J)r)  SSK*J+r+J,r,J-r-J.r.J/r/J0r0J1r1J2r2J3r3J4r4J5r5J6r6J7r7J8r8J9r9J:r:J;r;J<r<J=r=J>r>J?r?J@r@JArAJBrBJCrCJDrD  SSKEJFrFJGrGJHrHJIrIJJrJJKrKJLrLJMrMJNrNJOrOJPrPJQrQJRrRJSrSJTrT  SSKUJVrVJWrWJXrX  SS	KYJZrZJ[r[J\r\J]r]J^r^J_r_J`r`  SS
KaJbrb  SSKcJdrd  SSKeJfrfJgrgJhrhJiri  SSKjJkrk  SSKlJmrnJorpJqrr  \S:X  a  SSKsJtrt  OSrtS ruS rvS rwS rxS ryS rzS r{S r|S r}S7S jr~S rS rS rS rS  rS! rS" rS# rS$ rS% rS& rS8S' jrS( rS) rS* rS+ rS, rS- rS. rS/ rS0 rS1 rS2 rS3 rS4 rS5 rS6 rg)9z: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                     / nU HG  nSn [        XU5      u  pgU(       d  XeS-   pPOOM  US:X  a  [        S5      eUR                  XE45        MI     [        U5      $ )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)r2   RuntimeErrorappendr[   )ffactorsKresultfactorkqrs           O/var/www/auris/envauris/lib/python3.13/site-packages/sympy/polys/factortools.pydup_trial_divisionru   X   sm     F1a(DAa%1  6677vk"         c                     / nU HP  nSn [        XX#5      u  px[        X5      (       a  XvS-   p`OOM'  US:X  a  [        S5      eUR                  XV45        MR     [	        U5      $ )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   rh   ri   )r3   r   rj   rk   r[   )	rl   rm   urn   ro   rp   rq   rr   rs   s	            rt   dmp_trial_divisionry   t   su     F1a+DA!a%1  6677vk"     rv   c                 \   SSK Jn  [        U 5      n[        US-  5      n[        US-  5      nUR	                  [        S U  5       5      5      nU" US-
  U5      nU" US-
  US-
  5      nUR                  [        X5      5      n	Xv-  X-  -   n
U
[        X5      -  n
[        U
S-  5      S-  n
U
$ )ae  
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              3   *   #    U  H	  oS -  v   M     g7f)r|   N .0cfs     rt   	<genexpr>(dup_zz_mignotte_bound.<locals>.<genexpr>   s     0QrUQ   rh   )	(sympy.functions.combinatorial.factorialsr{   r   _ceilsqrtsumabsr   r;   )rl   rn   r{   ddeltadelta2	eucl_normt1t2lcbounds              rt   dup_zz_mignotte_boundr      s    R B1A!a%LE519F 0Q002I 
%!)V	$B	%!)VaZ	(B	
va|	BNRW$E	\!E%!)q ELrv   c                     [        XU5      n[        [        XU5      5      n[        [	        X5      5      nUR                  U" US-   5      5      SU-  -  U-  U-  $ )z7Mignotte bound for multivariate polynomials in `K[X]`. rh   r|   )r<   r   r   r   r   r   )rl   rx   rn   abns         rt   dmp_zz_mignotte_boundr      sX    Q1AM!"#AOA!"A66!AE(AqD "1$$rv   c                    U S-  n[        XX65      n[        XU5      n[        [        XHU5      X65      u  p[        XU5      n	[        XU5      n
[	        [        XXU5      [        XU5      U5      n[        [	        X+U5      Xv5      n[        [	        X:U5      Xv5      n[	        [        XLU5      [        X]U5      U5      n[        [        XR                  /U5      Xv5      n[        [        XNU5      X5      u  nn[        XU5      n[        UXv5      n[	        [        X^U5      [        XU5      U5      n[        [        UUU5      Xv5      n[        [        X[U5      Xv5      nXUU4$ )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]_

r|   )r8   rD   r2   r.   r*   r,   one)mrl   ghstrn   Merr   rs   rx   GHr   cr   STs                      rt   dup_zz_hensel_stepr      sH   8 	
1AA!A!A71#Q*DA!A!Aa '!"2A6A'!"A)A'!"A)Aa '!"2A6A'!eeWa(!/A71#Q*DAq!A!QAa '!"2A6A'!Q"A)A'!"A)AA:rv   c           
         [        U5      n[        X5      nUS:X  a1  [        XR                  X`U-  5      S   U5      n[	        XpU-  U5      /$ U nUS-  n	[        [        [        U5      5      5      n
[        U/U 5      nUSU	  H  n[        U[        X5      X5      nM     [        X)   U 5      nX)S-   S  H  n[        U[        X5      X5      nM     [        XX5      u  pn[        X5      n[        X5      n[        X5      n[        X5      n[        SU
S-   5       H  n[        XXXU5      US-  su  ppnM     [        XUSU	 X45      [        XX)S X45      -   $ )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]_

rh   r   r|   N)lenr   r>   gcdexrD   intr   _log2r   r	   r   r   ranger   dup_zz_hensel_lift)prl   f_listlrn   rs   r   Fr   rq   r   r   f_ir   r   r   _s                    rt   r   r     sq   . 	FA	BAv1ggbQ$/2A61dA&((	A	QAE%(OA"q!Abqz1&s.5  	A&A!ef~1&s.5  qQ"GA!qAqAqAqA1a!e_,Q1qA1a4qa  aF2AJ5
Q6":q
45 5rv   c                 8    XS-  :  a  X-
  nU(       d  gX-  S:H  $ )Nr|   Tr   r~   )fcrr   pls      rt   _test_plr   G  s$    7{F6Q;rv   c           
      F   [        U 5      nUS:X  a  U /$ SSKJn  U S   n[        X5      n[	        X5      n[        [        UR                  U" US-   5      5      SU-  -  U-  U-  5      5      n[        US-   SU-  -  USU-  S-
  -  -  5      n[        [        S[        U5      -  5      5      n	[        SU	-  [        U	5      -  5      n
/ n[        SU
S-   5       H  nU" U5      (       a  Xl-  S:X  a  M  UR                  U5      n[        X5      n[        XU5      (       d  MI  [        XU5      S   nUR!                  X45        [#        U5      S:  d  [#        U5      S:  d  M    O   [%        US	 S
9u  nn[        [        [        SU-  S-   U5      5      5      nU Vs/ s H  n['        UU5      PM     nn[)        XUUU5      n[        [#        U5      5      n[+        U5      n/ SnnUU-  nSU-  [#        U5      ::  Ga  [-        UU5       GHj  nUS:X  a0  SnU H  nUUU   S   -  nM     UU-  n[/        UUU5      (       d  M9  OOU/nU H  n[1        UUU   U5      nM     [3        UUU5      n[5        UU5      S   nUS   nU(       a  UU-  S:w  a  M  U/n[+        U5      nUU-
  nUS:X  a)  U/nU H  n[1        UUU   U5      nM     [3        UUU5      nU H  n[1        UUU   U5      nM     [3        UUU5      n[7        WU5      n [7        UU5      n!U U!-  U::  d  GM  UnU Vs/ s H  nUU;  d  M  UPM     nn[5        UU5      S   n[5        UU5      S   n UR!                  U5        [	        X5      n  O   US-  nSU-  [#        U5      ::  a  GM  UU /-   $ s  snf s  snf )z4Factor primitive square-free polynomials in `Z[x]`. rh   r   )isprimer|            c                     [        U S   5      $ )Nrh   )r   )xs    rt   <lambda>#dup_zz_zassenhaus.<locals>.<lambda>p  s    3qt9rv   )key)r   sympy.ntheoryr   r;   r   r   r   r   r   r   _logr   convertr   r   r   rk   r   minr   r   setra   r   r.   rD   rI   r=   )"rl   rn   r   r   r   Ar   BCgammar   r   pxr   fsqfxr   fsqfr   ffmodularr   sorted_Tr   rm   r   r   r   rr   ir   r   T_SG_normH_norms"                                     rt   dup_zz_zassenhausr   N  s   1AAvs
%	
2BQAqACqQx A%a')*+AQUacN1qsQw<'(Aaaj!"E%U#$E
A Auqy!r{{afkYYr]Q#q!!aQ'*	"u:?c!fqj " !,-GAtE$qsQw"#$A/34t~b!$tG41!Q/ASV}HHAQQG	
AB
A#Q-1%A
 AvA!A$r(
A FAr** + CA1Q4+A aQ'!!Q'*bEa1AAAa%CAvCA1Q4+A aQ'AqtQ'  !R#A A&F A&Ff}!'/>x!1A:Ax>!!Q'*!!Q'*q!1Le &h FAk A#Q-n aS=A 5h ?s   N%
N3Nc                     [        X5      n[        X5      n[        U SS U5      nU(       aH  SSKJn  U" [        U5      5      nUR                  5        H  nX'-  (       d  M  X7S-  -  (       d  M    g   gg)z2Test irreducibility using Eisenstein's criterion. rh   Nr   	factorintr|   T)r   r   rF   r   r   r   keys)rl   rn   r   tce_fcr   e_ffr   s           rt   dup_zz_irreducible_pr     sc    	B	Bqua D+T#ARQ$YY 	 rv   c                    UR                   (       a   XR                  5       p[        XU5      n OUR                  (       d  g[        X5      n[        X5      nUS:w  d  US:w  a  US:w  a  gU(       d%  [        X5      u  pgXaR                  :w  d  XpS4/:w  a  g[        U 5      n/ / p[        USS5       H  nU	R                  SX   5        M     [        US-
  SS5       H  nU
R                  SX   5        M     [        [        U	5      U5      n	[        [        U
5      U5      n
[        U	[        U
SU5      U5      nUR!                  [        X5      5      (       a  [#        X5      nX:X  a  g[%        X5      n	UR!                  [        X5      5      (       a  [#        X5      n	X:X  a  ['        X5      (       a  g[)        X5      n[        X5      U:X  a  ['        X5      (       a  gg! [         a     gf = f)a   
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.

Frh   r   r   T)is_QQget_ringr   r_   is_ZZr   r   dup_factor_listr   r   r   insertr0   r   r,   r:   is_negativer(   rP   dup_cyclotomic_prW   )rl   rn   irreducibleK0r   r   coeffrm   r   r   r   r   r   r   s                 rt   r   r     s   4 	ww	zz|A1%A WW	B	B	Qw28a(.EE>WQ01Arq1b"	AD  1q5"b!	AD " 		!a A	!a A:aA&*A}}VA\""AMv1A}}VA\""AMv"1((QAq}.q44e  		s   G! !
G.-G.c                     SSK Jn  UR                  UR                  * /nU" U 5      R                  5        H-  u  pE[	        [        X4U5      X15      n[        X4US-
  -  U5      nM/     U$ )z1Efficiently generate n-th cyclotomic polynomial. r   r   rh   )r   r   r   itemsr4   r!   )r   rn   r   r   r   rq   s         rt   dup_zz_cyclotomic_polyr     s_    '	
A!""$Ka(!/q1u:q) % Hrv   c                    SSK Jn  UR                  UR                  * //nU" U 5      R                  5        H|  u  pEU Vs/ s H  n[	        [        XdU5      Xa5      PM     nnUR                  U5        [        SU5       H0  nU V	s/ s H  n	[        XU5      PM     nn	UR                  U5        M2     M~     U$ s  snf s  sn	f )Nr   r   rh   )r   r   r   r   r4   r!   extendr   )
r   rn   r   r   r   rq   r   Qr   rr   s
             rt   _dup_cyclotomic_decomposer   &  s    '
%%!%%A!""$;<>1agk!*A11>	q!A0131+aA&A3HHQK 	 % H ? 4s     B9B>c                 \   [        X5      [        X5      p2[        U 5      S::  a  gUS:w  d  US;  a  g[        S U SS  5       5      (       a  g[        U 5      n[	        XA5      nUR                  U5      (       d  U$ / n[	        SU-  U5       H  nXu;  d  M
  UR                  U5        M     U$ )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   Nrh   )r   rh   c              3   8   #    U  H  n[        U5      v   M     g 7f)N)boolr   s     rt   r   +dup_zz_cyclotomic_factor.<locals>.<genexpr>P  s     
&g488gs   r   r|   )r   r   r   anyr   is_onerk   )rl   rn   lc_ftc_fr   r   r   r   s           rt   dup_zz_cyclotomic_factorr   6  s    $ va|$!}qyD'

&a"g
&&&1A!!'A88D>>*1Q32Az 3 rv   c                 H   [        X5      u  p#[        U5      n[        X15      S:  a  U* [        X15      p2US::  a  U/ 4$ US:X  a  X#/4$ [	        S5      (       a  [        X15      (       a  X#/4$ Sn[	        S5      (       a  [        X15      nUc  [        X15      nU[        USS94$ )z:Factor square-free (non-primitive) polynomials in `Z[x]`. r   rh   USE_IRREDUCIBLE_IN_FACTORNUSE_CYCLOTOMIC_FACTORF)multiple)	rI   r   r   r(   r\   r   r   r   r[   )rl   rn   contr   r   rm   s         rt   dup_zz_factor_sqfr   b  s    A!GD1Aa|a%aAvRx	
aSy())%%9G$%%*10#A)w777rv   c                 Z   [         S:X  a\  [        U SSS2   5      nUR                  5       u  p4U VVs/ s H  u  pVUR                  5       SSS2   U4PM     nnnU[	        U5      4$ [        X5      u  p7[        U5      n[        Xq5      S:  a  U* [        Xq5      psUS::  a  U/ 4$ US:X  a  X7S4/4$ [        S5      (       a  [        Xq5      (       a  X7S4/4$ [        Xq5      nSn	[        S5      (       a  [        Xq5      n	U	c  [        Xq5      n	[        X	U5      n[        X5        X44$ s  snnf )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]_

re   Nr   r   rh   r   r   )r   rf   rp   coeffsr[   rI   r   r   r(   r\   r   rW   r   r   ru   rY   )
rl   rn   f_flintr   rm   facexpr   r   r   s
             rt   dup_zz_factorr    s6   \ wAddG$(=DEWCJJL2&,WE]7+++A!GD1Aa|a%aAvRx	
a!fX~())%%a&>!QAA$%%$Q*ya# q)Gq"=A Fs   $D'c                     X-  /nU  Hm  n[        U5      n[        U5       H?  nUS:w  a  UR                  Xe5      nXV-  nUS:w  a  M  UR                  U5      (       d  M>      g   UR	                  U5        Mo     USS $ )z,Wang/EEZ: Compute a set of valid divisors.  rh   N)r   reversedgcdr   rk   )Ecsctrn   ro   rr   rs   s          rt   dmp_zz_wang_non_divisorsr    s    uYFF&!Aq&EE!KF q& xx{{ " 	a  !":rv   c           
         [        [        X5      X4S-
  U5      (       d  [        S5      e[        XXE5      n[        Xe5      (       d  [        S5      e[	        Xe5      u  pxUR                  [        X5      5      (       a  U* [        X5      pUS-
  n	U V
Vs/ s H  u  p[        XX5      PM     nn
n[        XX%5      nUb  XxU4$ [        S5      es  snn
f )z2Wang/EEZ: Test evaluation points for suitability. rh   zno luck)	rK   r   r`   rT   rI   r   r   r(   r  )rl   r   r  r   rx   rn   r   r   r   vr   r   r
  Ds                 rt   dmp_zz_wang_test_pointsr    s    qa%33y))aA!AQ??y))DA}}VA\""r71=1	AA013-a
#A3 r-A}Qwy)) 	4s   Cc                 
   / S/[        U5      -  US-
  pnU H  n[        X5      n[        X5      U-  n[        [	        [        U5      5      5       HU  nSX>   X   snnu  nnUU-  (       d  UU-  US-   pUU-  (       d  M  US:w  d  M8  [        U[        UXU5      X5      SsoU'   MW     UR                  U5        M     [        U	5      (       d  [        e/ / nn[        X5       H  u  p[        XX5      n[        X5      nUR                  U5      (       a  UU-  nO+UR                  UU5      nUU-  UU-  nn[        XU5      X--  p+[        UUX5      nUR                  U5        UR                  U5        M     UR                  U5      (       a  U UU4$ / / nn[        UU5       H<  u  pUR                  [        XX5      5        UR                  [        XSU5      5        M>     [        X[        U5      S-
  -  Xg5      n U UU4$ )z0Wang/EEZ: Compute correct leading coefficients. r   rh   )r   r   r   r  r   r/   r1   rk   allr]   ziprK   r   r	  r>   r?   )rl   r   r  r
  r   r   rx   rn   r   Jr  r   r   r   r   rq   r   r   r   CCHHr   ccr   CCCHHHs                             rt   dmp_zz_wang_lead_coeffsr    s   1#c!f*a!e!AAM1LO%A-(AadADLAq&1a1u!tQU1 1uu Av!!WQa%8!?Q4 ) 	
  q66BA	!%A\88B<<QBb!AqD"a%rA"1+RUr1b!'
		!
		!   	xx||"by2CB

>!./

>!A./  	qs1vz*A1Ac3;rv   c           
         [        U 5      S:X  aw  U u  pE[        XB5      n[        XR5      n[        XvX#5      u  pn
[        XU5      n[        XU5      n	[	        XX#5      u  p[        XXrU5      n	[        X5      n[        X5      n	X/nU$ U S   /n
[        U SS 5       H"  nU
R                  S[        XjS   U5      5        M$     / S//p[        X
5       H>  u  pg[        Xv/US   / SUSU5      u  pUR                  U	5        UR                  U5        M@     / XS   /-   p[        X5       HN  u  p[        X5      n[        Xb5      n[        [        XU5      XbU5      n[        X5      nUR                  U5        MP     U$ )z2Wang/EEZ: Solve univariate Diophantine equations. r|   r   rh   r   )r   r   r   r   r
   r   r   r  r   r.   r  dmp_zz_diophantinerk   r   )r   r   r   rn   r   r   rl   r   r   r   r   rr   ro   r   r   rs   s                   rt   dup_zz_diophantiner  7  s   
1v{Q"Q"1&aaAaAaA!qQ1%1 1 2 M/ rUG!Ab'"AHHQQ4+, # QC51IDA%qfaeRAq!DDAHHQKHHQK 
 rUGIDA &A &Ayq)13Aq$AMM!  Mrv   c           
         U(       d  U  Vs/ s H  n/ PM     nn[        U5      n	[        U5       Ha  u  pU(       d  M  [        X	U
-
  XF5      n[        [        X5      5       H,  u  nu  p[	        XU5      n[        [        XU5      XF5      X'   M.     Mc     U$ [        U5      n	[        XU5      nUS   USS nn/ / nnU  H<  nUR                  [        UUXV5      5        UR                  [        UUXU5      5        M>     [        UUXU5      nUS-
  n[        UUX#UUU5      nU Vs/ s H  n[        USUU5      PM     nn[        UU5       H  u  nn[        XUXV5      nM     [        XXV5      n[!        UR"                  U* /X5      n[%        X5      n['        SU5       GH
  n[)        X5      (       a    O[+        UUXV5      n[-        UUS-   UXU5      n[)        UU5      (       a  MH  [/        UUR1                  U" U5      S-   5      UU5      n[        UUX#UUU5      n[        U5       H   u  p[+        [        USUU5      UXV5      X'   M"     [        [        X5      5       H  u  n
u  p[3        XXV5      X'   M     [        UU5       H  u  nn[        XUXV5      nM     [        XXV5      nGM     U Vs/ s H  n[        XXV5      PM     nnU$ s  snf s  snf s  snf )z4Wang/EEZ: Solve multivariate Diophantine equations. r   Nrh   r   )r   	enumerater  r  r>   rD   r*   r   r6   rk   r5   rL   r  r   r9   rE   r   r   r   r   r   r/   rM   rA   	factorialr+   )r   r   r   r   r   rx   rn   r   r   r   r   r   r   jr   r   r   r   r   r   rl   r   r  r   r   r   rq   s                              rt   r  r  g  s   !Qb!qM!!HA"1!eQ2A&s1y1	6A"1Q/ q!118 2 %v Hc FqQuaf121AHHWQ1()HH[AqQ/0  1aA&Eq!Q1a3-.0Qi1a#Q01IDAqA!Q*A  Q1(aeeaR[!'AMq!A!1a#A AE1aA6Aa##"1akk!A$(&;QB&q!Q1a;%aLDA"9Q1a#8!QBAD ) "+3q9!5IAv"1.AD "6  1IDAq#A!Q2A & %Q10) , 567AqqQ*A7H} 8 1@ 8s   K%K1Kc                 8   U /[        U5      US-
  pn[        U5      n[        [        USS 5      5       H:  u  p[	        US   XU
-
  XZ-
  U5      nUR                  S[        XX-
  U5      5        M<     [        [        X5      SS 5      n[        [        SUS-   5      Xs5       GH  u  pn[        U5      US-
  nnUSUS-
   X>S-
  S nn[        [        X5      5       H?  u  n
u  nn[        [        UUX5      UUS-
  U5      nU/[        USS SUS-
  U5      -   X'   MA     [        UR                  U* /UU5      n[        UU5      n[!        U[#        UUU5      UU5      n[%        UUU5      n[        SU5       GH  n['        UU5      (       a    M  [)        UUUU5      n[+        UUS-   UUUU5      n['        UUS-
  5      (       a  MO  [-        UUR/                  U" U5      S-   5      US-
  U5      n[1        UUUXUS-
  U5      n[        [        UU5      5       H7  u  n
u  nn[3        U[        USUS-
  U5      UUU5      n[        UUUU5      X'   M9     [!        U[#        UUU5      UU5      n[        UUUU5      nGM     GM     [#        XU5      U :w  a  [4        eU$ )z-Wang/EEZ: Parallel Hensel lifting algorithm. rh   Nr   r|   )r   listr   r  rL   r   rE   maxr   r  r   rK   r   r   r   r   r-   r6   r   r   r/   rM   rA   r!  r  r7   r]   )rl   r   LCr   r   rx   rn   r   r   r  r   r   r   r   r"  r   wIr  r   r   r   r   r   djrq   r   r   r   s                                rt   dmp_zz_wang_hensel_liftingr*    s   c3q61q5!AQA(1QR5/*!aQq1	$Q15!45 + 	OA!!"%&AuQA-aAwA1!a%y!EF)1#CJ/JAw2!-Aq"<aQJB4)AabE1a!eQ77AD 0 aeeaR[!Q'AqMAz!Q*Aq11a#q"A!Q1a#A AE1aA6AaQ''"1akk!A$(&;QUAF&q!Qa!eQ?!*3q!9!5IAv1#AyAq1ua'@!QJA+Aq!Q7AD "6 Az!Q2Aq9$Q1a0! ! .D !arv   c           
         SSK Jn  [        U5      n[        [	        X5      US-
  U5      u  px[        XU5      n	U" U" U	5      5      n
Uc  US:X  a  SnOSn[        5       / UR                  /U-  S4u  pp [        XX}X5      u  nnn[        UU5      u  nn[        U5      nUS:X  a  U /$ UUUUU4/n[        S5      n[        S5      n[        S5      n[        U5      U:  a  [        U5       H  n[        U5       Vs/ s H  nU" U" U* U5      5      PM     nn[        U5      U;  a  UR                  [        U5      5        OMX   [        XX}X5      u  nnn[        UU5      u  nn[        U5      nUb  UU:w  a  UU:  a  / UpOM  OUnUS:X  a  U /s  $ UR!                  UUUUU45        [        U5      U:X  d  M    O   UU-  n[        U5      U:  a  M  S	u  nnnU H*  u  n      n[#        UU5      nUb  UU:  a  UnUnOUnUS-  nM,     UU   u  nnnnnU n [%        XUUUXU5      u  n nn['        U UUXX5      n/ nU HO  n [-        XU5      u  nn UR/                  [1        XU5      5      (       a  [3        XU5      n UR!                  U 5        MQ     U$ ! [         a     GNf = fs  snf ! [         a     GM  f = f! [(         a.    [        S
5      (       a  [+        UXUS-   5      s $ [)        S5      ef = f)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   )	nextprimerh   Nr|   EEZ_NUMBER_OF_CONFIGSEEZ_NUMBER_OF_TRIESEEZ_MODULUS_STEP)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addrk   r;   r  r*  r]   dmp_zz_wangrJ   r   r   r)   ) rl   rx   rn   modseedr,  randintr  r   r   r   historyconfigsr   rs   r  r   r
  r   r   eez_num_configseez_num_trieseez_mod_steprrs_norms_argr   _s_normorig_fr&  rm   ro   s                                    rt   r5  r5    sc   < (tnG&,Aq1EBaA&A	)A,A
{6CC UB
D8Ga*1=Aq A&1F63Jr1a#$ 34O/0M+,L
g,
(}%A16q;A!GSD#&'A;Qxw&E!H%21EAq %Q*DAqQB}7Av%' 	  Avs
NNAr1a+,7|.A &D <CG g,
(J "FE1 1aAq!$ F	Q ! U^NAr1aFG*1Q1C1b,Q2qQB F#A!,1==qQ/00a Aa  Mc   < $ \  G())vqS1W55#EG G	GsB   53J )J <J%J*#J< 
J"!J"*
J98J9<*K4(K4c                    U(       d  [        X5      $ [        X5      (       a  UR                  / 4$ [        XU5      u  p4[	        XAU5      S:  a  U* [        XAU5      pC[        S [        XA5       5       5      (       a  U/ 4$ [        XAU5      u  pT/ n[        XA5      S:  a$  [        XAU5      n[        XAU5      n[        XX5      n[        XQS-
  U5      S    H  u  pHUR                  SU/U45        M     [        XU5        U[!        U5      4$ )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              3   *   #    U  H	  oS :*  v   M     g7fr   Nr~   r   r   s     rt   r    dmp_zz_factor.<locals>.<genexpr>       
10a60r   rh   )r  r   r2  rJ   r   r)   r  r   rQ   r   rX   r5  ry   r1  r   rZ   r[   )	rl   rx   rn   r   r   r   rm   r   rq   s	            rt   r1  r1  m  s   H Q""!vvrz"1+GDQ1!%q)a

1?10
111Rxq!DAG!!q!a $Q10aQ*1-qA3(# . qW%w'''rv   c           	          UR                  5       n[        XU5      n [        X5      u  p4U VVs/ s H  u  pV[        XRU5      U4PM     nnnUR                  X25      nX44$ s  snnf )z>Factor univariate polynomials into irreducibles in `QQ_I[x]`. )as_AlgebraicFieldr   r   r   )rl   r   K1r   rm   r  r   s          rt   dup_qq_i_factorrL    sh     
			BA2A$Q+NE;BC7CR(!,7GCJJu!E> Ds   A c                 &   UR                  5       n[        XU5      n [        X5      u  p4/ nU HK  u  pg[        Xb5      u  p[        XU5      n
[	        U
SU5      u  pX;U-  -  X-  -  nUR                  X45        MM     UnUR                  X25      nX44$ )z>Factor univariate polynomials into irreducibles in `ZZ_I[x]`. r   )	get_fieldr   rL  rB   rJ   rk   r   )rl   r   rK  r   rm   new_factorsr  r   	fac_denomfac_numfac_num_ZZ_Icontentfac_prims                rt   dup_zz_i_factorrU    s     
BA2A$Q+NEK-c6	"730q"EA%).8H=)  GJJu!E>rv   c           
          UR                  5       n[        XX#5      n [        XU5      u  pEU VVs/ s H  u  pg[        XaX25      U4PM     nnnUR                  XC5      nXE4$ s  snnf )z@Factor multivariate polynomials into irreducibles in `QQ_I[X]`. )rJ  r   dmp_factor_listr   )rl   rx   r   rK  r   rm   r  r   s           rt   dmp_qq_i_factorrX    sj     
			BA"!A$Q2.NE>EFgFCCB+Q/gGFJJu!E> Gs   A!c                 (   UR                  5       n[        XX#5      n [        XU5      u  pE/ nU HK  u  px[        XqU5      u  p[        XX25      n[	        XU5      u  pXLU-  -  X-  -  nUR                  X45        MM     UnUR                  XC5      nXE4$ )z@Factor multivariate polynomials into irreducibles in `ZZ_I[X]`. )rN  r   rX  rC   rJ   rk   r   )rl   rx   r   rK  r   rm   rO  r  r   rP  rQ  rR  rS  rT  s                 rt   dmp_zz_i_factorrZ    s     
BA"!A$Q2.NEK-cb9	"7r60"EA%).8H=)  GJJu!E>rv   c                    [        U 5      [        X5      p2[        X5      n US::  a  U/ 4$ US:X  a  X0S4/4$ [        X5      U p@[	        X5      u  pVn[        XqR                  5      n[        U5      S:X  a  X0U[        U 5      -  4/4$ XQR                  -  n	[        U5       H=  u  n
u  p[        XR                  U5      n[        XU5      u  pn[        XU5      nXU
'   M?     [        XHU5      n[        XH5        X84$ )a  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   rh   )r   r   rG   rW   rU   dup_factor_list_includedomr   unitr   r   rR   rN   ru   rY   )rl   rn   r   r   r   r   r   rs   rm   r   r   rp   r   r   s                 rt   dup_ext_factorr_    s   D qM6!<r!AAv2vAvF8|qq1 GA!%a/G
7|q:a=()***	&&A#G,;Fq)a(aaA
	 - !Q/Gq";rv   c                 >   U(       d  [        X5      $ [        XU5      n[        XU5      n [        S [	        X5       5       5      (       a  U/ 4$ [        XU5      U p@[        XU5      u  pVn[        XqUR                  5      n[        U5      S:X  a  U /nOk[        U5       H\  u  n	u  p[        XUR                  U5      n[        XX5      u  pnU Vs/ s H  oUR                  -  PM     nn[        XX5      nXU	'   M^     [        XHX5      n[!        XAU5        X?4$ s  snf )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              3   *   #    U  H	  oS :*  v   M     g7frE  r~   rF  s     rt   r   !dmp_ext_factor.<locals>.<genexpr>  rH  r   rh   )r_  r   rH   r  r   rX   rV   dmp_factor_list_includer]  r   r   r   rS   r^  rO   ry   rZ   )rl   rx   rn   r   r   r   r   rs   rm   r   rp   r   r   sir   ro   s                   rt   dmp_ext_factorre  T  s   ^ a##	qQ	Bq!A

1?10
1112va !q1#GA!%aAEE2G
7|q#'0NA{Fquua0A#A!/GA!%&'QrAFFQA'!%AAJ 1  A1FqV$: (s   Dc                    [        XUR                  5      n [        XR                  UR                  5      u  p#[	        U5       H"  u  nu  p[        XR                  U5      U4X4'   M$     UR                  X!R                  5      U4$ )z2Factor univariate polynomials over finite fields. )r   r]  r   r6  r   r   )rl   rn   r   rm   r   rq   s         rt   dup_gf_factorrg    sn    A!%% Aq%%/NEw'	6A!!UUA.2
 ( 99UEE"G++rv   c                     [        S5      e)z4Factor multivariate polynomials over finite fields. z+multivariate polynomials over finite fields)NotImplementedError)rl   rx   rn   s      rt   dmp_gf_factorrj    s    
K
LLrv   c                    [        X5      u  p [        X5      u  p0UR                  (       a  [        X5      u  pEGOJUR                  (       a  [        X5      u  pEGO*UR                  (       a  [        X5      u  pEGO
UR                  (       a  [        X5      u  pEGOUR                  (       d  XR                  5       p[        XU5      n OSnUR                  (       a+  UR                  5       n[        XU5      u  p[        XU5      n OUnUR                   (       a  [#        X5      u  pEOUR$                  (       aj  ['        U SU5      u  p	[)        X	UR*                  5      u  pE[-        U5       H  u  n
u  p[/        X	U5      U4XZ'   M     UR1                  XGR*                  5      nO[3        SU-  5      eUR                  (       a  [-        U5       H  u  n
u  p[        XU5      U4XZ'   M     UR1                  XG5      nUR5                  UW5      nU(       ar  [-        U5       HP  u  n
u  p[7        X5      n[9        XU5      n [        XU5      n X4XZ'   UR;                  XAR=                  X5      5      nMR     UR1                  XA5      nUnU(       a*  UR?                  SUR@                  URB                  /U45        XC-  [E        U5      4$ );Factor univariate polynomials into irreducibles in `K[x]`. Nr   #factorization not supported over %s)#r&   rI   is_FiniteFieldrg  is_Algebraicr_  is_GaussianRingrU  is_GaussianFieldrL  is_Exact	get_exactr   is_Fieldr   rB   r   r  is_Polyr$   rW  r]  r   r%   r   r^   quor;   r@   mulpowr   r   r2  r[   )rl   r   r"  r   r   rm   
K0_inexactrn   denomrx   r   rq   max_norms                rt   r   r     sH   DAA"GD	&q-w	'.w			(/w			(/w{{A2.AJ;;A'q1HEA1%AA77*10NE7YYaA&DA,Q1559NE&w/	6A'a0!4
 0 IIeUU+ECbHII;;&w/	6A)!3Q7
 0 JJu(EFF5%(E!*7!3IAv+A2H&qB7A#A:6A"#GJFF5&&*=>E "4 #**55qBFFBGG,a01:}W---rv   c                     [        X5      u  p#U(       d  [        U/5      S4/$ [        US   S   X!5      nXCS   S   4/USS -   $ )rl  rh   r   N)r   r   r>   )rl   rn   r   rm   r   s        rt   r\  r\    sY    $Q*NEE7#Q'((71:a=%3AJqM"#gabk11rv   c           	         U(       d  [        X5      $ [        XU5      u  p0[        XU5      u  p@UR                  (       a  [	        XU5      u  pVGOUR
                  (       a  [        XU5      u  pVGOcUR                  (       a  [        XU5      u  pVGOBUR                  (       a  [        XU5      u  pVGO!UR                  (       d  X"R                  5       p'[        XXr5      n OSnUR                  (       a+  UR                  5       n[!        XX(5      u  p[        XX(5      n OUnUR"                  (       aE  [%        XU5      u  pn['        XU5      u  pV[)        U5       H  u  nu  p[+        X
X5      U4Xl'   M     OUR,                  (       ai  [/        XU5      u  p[1        XUR2                  5      u  pV[)        U5       H  u  nu  p[5        XU5      U4Xl'   M     UR7                  XXR2                  5      nO[9        SU-  5      eUR                  (       a  [)        U5       H  u  nu  p[        XX5      U4Xl'   M     UR7                  XX5      nUR;                  UW	5      nU(       as  [)        U5       HQ  u  nu  p[=        XU5      n[?        XX5      n [        XX'5      n X4Xl'   URA                  XRRC                  X5      5      nMS     UR7                  XR5      nUn[)        [E        U5      5       HH  u  pU(       d  M  SX-
  -  S-   SU-  -   URF                  0nURI                  S[K        UX5      U45        MJ     XT-  [M        U5      4$ )=Factor multivariate polynomials into irreducibles in `K[X]`. Nrm  )r   )rh   r   )'r   r'   rJ   rn  rj  ro  re  rp  rZ  rq  rX  rr  rs  r   rt  r   rC   r   r"   r1  r   r#   ru  r$   rW  r]  r%   r   r^   rv  r<   rA   rw  rx  r  r   r   r   r[   )rl   rx   r   r  r   r   rm   ry  rn   rz  levelsr  r   rq   r{  r"  terms                    rt   rW  rW     s   q%%r"DA"1,GD	&qR0w	'b1w			(r2w			(r2w{{A*1AJ;;A'b4HEA"(AA77&qQ/LFq*13NE&w/	6A)!Q:A>
 0YYaA&DA,Q1559NE&w/	6A'a0!4
 0 IIeUU+ECbHII;;&w/	6A)!6:
 0 JJu(EFF5%(E!*7!3IAv+A"5H&qA:A#A"9A"#GJFF5&&*=>E "4 #**55(1+&aet#d1f,bff5q=q5q9: ' :}W---rv   c                     U(       d  [        X5      $ [        XU5      u  p4U(       d  [        X15      S4/$ [        US   S   X1U5      nXTS   S   4/USS -   $ )r~  rh   r   N)r\  rW  r    r?   )rl   rx   rn   r   rm   r   s         rt   rc  rc  M  si    &q,,$Q1-NEE%q)**71:a=%A6AJqM"#gabk11rv   c                     [        U SU5      $ )zS
Returns ``True`` if a univariate polynomial ``f`` has no factors
over its domain.
r   )dmp_irreducible_p)rl   rn   s     rt   dup_irreducible_pr  [  s    
 Q1%%rv   c                 f    [        XU5      u  p4U(       d  g[        U5      S:  a  gUS   u  p5US:H  $ )zU
Returns ``True`` if a multivariate polynomial ``f`` has no factors
over its domain.
Trh   Fr   )rW  r   )rl   rx   rn   r   rm   rq   s         rt   r  r  c  s;    
 !q)JA	W	qzAvrv   )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/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   sympy.polys.densetoolsrB   rC   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   sympy.polys.euclidtoolsrQ   rR   rS   sympy.polys.sqfreetoolsrT   rU   rV   rW   rX   rY   rZ   sympy.polys.polyutilsr[   sympy.polys.polyconfigr\   sympy.polys.polyerrorsr]   r^   r_   r`   sympy.utilitiesra   mathrb   r   rc   r   rd   r   re   rf   ru   ry   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r  r  r*  r5  r1  rL  rU  rX  rZ  r_  re  rg  rj  r   r\  rW  rc  r  r  r~   rv   rt   <module>r     s   @ , &   " " " " " " ""$ $ $ $ $ $ $$& & & & &" "   0 (F F $ : : 7I!8!8:x%6r75rfR Pf	 )X8:Qh(*43l-`AH1hK\@(F,,_DK\	,M
?.D2J.Z2&rv   