
    wg                        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 Zud Zvd Zwd Zxd Zyd Zzd Z{d Z|d Z}d7dZ~d Zd Zd Zd Zd  Zd! Zd" Zd# Zd$ Zd% Zd& Zd8d'Zd( Zd) Zd* Zd+ Zd, Zd- Zd. Zd/ Zd0 Zd1 Zd2 Zd3 Zd4 Zd5 Zd6 Zy)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                     g }|D ]D  }d}	 t        | ||      \  }}|s||dz   }} nn|dk(  rt        d      |j                  ||f       F 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)r2   RuntimeErrorappendr[   )ffactorsKresultfactorkqrs           \/home/mcse/projects/flask/flask-venv/lib/python3.12/site-packages/sympy/polys/factortools.pydup_trial_divisionru   X   s|     F #1fa(DAq!a%1  6677vqk"#        c                     g }|D ]O  }d}	 t        | |||      \  }}t        ||      r||dz   }} nn'|dk(  rt        d      |j                  ||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   rh   ri   )r3   r   rj   rk   r[   )	rl   rm   urn   ro   rp   rq   rr   rs   s	            rt   dmp_trial_divisionry   t   s     F #1fa+DAq!Q!a%1  6677vqk"#    rv   c                 d   ddl m} t        |       }t        |dz        }t        |dz        }|j	                  t        d | D                    } ||dz
  |      } ||dz
  |dz
        }|j                  t        | |            }	||z  ||	z  z   }
|
t        | |      z  }
t        |
dz        dz  }
|
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              3   &   K   | ]	  }|d z    yw)r|   N .0cfs     rt   	<genexpr>z(dup_zz_mignotte_bound.<locals>.<genexpr>   s     0rRU0   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NR"W$E	\!QE%!)q ELrv   c                     t        | ||      }t        t        | ||            }t        t	        | |            }|j                   ||dz               d|z  z  |z  |z  S )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      s^    Q1AM!Q"#AOAq!"A66!AE(AqD "1$$rv   c                    | dz  }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]_

    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      s   8 	
1AAq!QA!QA71a#Q*DAq!QA!QA1a '!Q"2A6A'!Q"Aq)A'!Q"Aq)A1a '!Q"2A6A'!aeeWa(!Q/A71a#Q*DAq!QA!QA1a '!Q"2A6A'!Q"Aq)A'!Q"Aq)AaA:rv   c           
         t        |      }t        ||      }|dk(  r4t        ||j                  || |z        d   |      }t	        || |z  |      gS | }|dz  }	t        t        t        |                  }
t        |g|       }|d|	 D ]  }t        |t        ||       | |      } t        ||	   |       }||	dz   d D ]  }t        |t        ||       | |      } t        ||| |      \  }}}t        ||       }t        ||       }t        ||       }t        ||       }t        d|
dz         D ]  }t        |||||||      |dz  c\  }}}}}  t        | ||d|	 ||      t        | |||	d ||      z   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]_

    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     s   . 	FA	1BAv1aggb!Q$/2A61adA&((	A	QAE%(OA"q!Abqz 61&sA.156 	A&Aa!ef~ 61&sA.156 q!Q"GAq!q!Aq!Aq!Aq!A1a!e_ H,Q1aAqA1a4Aq!aH aF2AJ15
Q6!":q!
45 5rv   c                 2    ||dz  kD  r||z
  }|sy| |z  dk(  S )Nr|   Tr   r~   )fcrr   pls      rt   _test_plr   G  s*    27{F6Q;rv   c           
         t        |       }|dk(  r| gS ddlm} | d   }t        | |      }t	        | |      }t        t        |j                   ||dz               d|z  z  |z  |z              }t        |dz   d|z  z  |d|z  dz
  z  z        }t        t        dt        |      z              }	t        d|	z  t        |	      z        }
g }t        d|
dz         D ]  } ||      r||z  dk(  r|j                  |      }t        | |      }t        |||      s?t        |||      d   }|j!                  ||f       t#        |      dk  st#        |      dkD  s n t%        |d	 
      \  }}t        t        t        d|z  dz   |                  }|D cg c]  }t'        ||       }}t)        || |||      }t        t#        |            }t+        |      }g d}}||z  }d|z  t#        |      k  rrt-        ||      D ]J  }|dk(  r'd}|D ]  }|||   d   z  } ||z  }t/        |||      sG0|g}|D ]  }t1        |||   |      } t3        |||      }t5        ||      d   }|d   }|r	||z  dk7  rv|g}t+        |      }||z
  }|dk(  r'|g}|D ]  }t1        |||   |      } t3        |||      }|D ]  }t1        |||   |      } t3        |||      }t7        |      } t7        ||      }!| |!z  |k  s|}|D cg c]	  }||vs| }}t5        ||      d   }t5        ||      d   } |j!                  |       t	        | |      } n |dz  }d|z  t#        |      k  rr|| gz   S c c}w c c}w )z4Factor primitive square-free polynomials in `Z[x]`. rh   r   )isprimer|            c                     t        | d         S )Nrh   )r   )xs    rt   <lambda>z#dup_zz_zassenhaus.<locals>.<lambda>p  s    3qt9 rv   )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{a"fkYYr]Q#2q!aQ'*	"eu:?c!fqj !,-GAtE$qsQw"#$A/34~b!$4G41a!Q/ASV}HHAQQG	
AB
A#Q-1% 4	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}!'/>!1A:A>>!!Q'*!!Q'*q!1aLe4	h FAk A#Q-n aS=A 5h ?s   M+?	M0	M0c                     t        | |      }t        | |      }t        | dd |      }|r=ddlm}  |t        |            }|j                         D ]  }||z  s	||dz  z  s y yy)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     sl    	1B	1Bqua D+T# 	AQR!Q$Y		 rv   c                    |j                   r!	 ||j                         }}t        | ||      } n|j                  syt        | |      }t        | |      }|dk7  s
|dk7  r|dk7  ry|s't        | |      \  }}||j                  k7  s|| dfgk7  ryt        |       }g g }
}	t        |dd      D ]  }|	j                  d| |           t        |dz
  dd      D ]  }|
j                  d| |           t        t        |	      |      }	t        t        |
      |      }
t        |	t        |
d|      |      }|j!                  t        ||            rt#        ||      }|| k(  ryt%        | |      }	|j!                  t        |	|            rt#        |	|      }	||	k(  rt'        |	|      ryt)        ||      }t        ||      |k(  rt'        ||      ryy# t        $ r Y yw xY w)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.

    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	qzz|BAr1%A WW	1B	1B	Qw28a(A.wAEE>W!Q01ArqA1b" 	AaD 1q5"b! 	AaD 		!a A	!a A:aA&*A}}VAq\"AqMAv1aA}}VAq\"AqMAv"1a(QAq!}.q!4e  		s   G	 		GGc                     ddl m} |j                  |j                   g} ||       j                         D ]0  \  }}t	        t        |||      ||      }t        |||dz
  z  |      }2 |S )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     sl    '	
A!""$ *1K1a(!Q/1q1u:q)* Hrv   c                 z   ddl m} |j                  |j                   gg} ||       j                         D ]w  \  }}|D cg c]  }t	        t        |||      ||       }}|j                  |       t        d|      D ]-  }|D 	cg c]  }	t        |	||       }}	|j                  |       / y |S c c}w c c}	w )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!""$ 1;<>agk!Q*Aq1>>	q! 	A0131+aA&3A3HHQK		 H ? 4s   B3B8c                 @   t        | |      t        | |      }}t        |       dk  ry|dk7  s|dvryt        d | dd D              ryt        |       }t	        ||      }|j                  |      s|S g }t	        d|z  |      D ]  }||vs|j                  |        |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   Nrh   )r   rh   c              3   2   K   | ]  }t        |        y w)N)boolr   s     rt   r   z+dup_zz_cyclotomic_factor.<locals>.<genexpr>P  s     
&48
&s   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    $ 1va|$D!}qyD'

&a"g
&&1A!!Q'A88D>*1Q32 	Az	 rv   c                 <   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      rt        ||      }|t        ||      }|t        |d      fS )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    Aq!GD!1Aa|a%AaAvRx	
aaSy()1%!9G$%*1a0#Aq)w777rv   c                 L   t         dk(  r[t        | ddd         }|j                         \  }}|D cg c]  \  }}|j                         ddd   |f }}}|t	        |      fS t        | |      \  }}t        |      }t        ||      dk  r| 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        ||      }	|	t        ||      }	t        | |	|      }t        | |       ||fS c c}}w )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    sL   \ wAddG$(g=DEcCJJL2&,EE]7+++Aq!GD!1Aa|a%AaAvRx	
aq!fX~()1%1a&>!QAA$%$Q*ya# Aq)Gq'"=A Fs   "D c                     ||z  g}| D ]d  }t        |      }t        |      D ]8  }|dk7  r|j                  ||      }||z  }|dk7  r|j                  |      s7  y |j	                  |       f |dd 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!QKF q& xx{	 	a !":rv   c           
         t        t        | |      ||dz
  |      st        d      t        | |||      }t        ||      st        d      t	        ||      \  }}|j                  t        ||            r| t        ||      }}|dz
  }	|D 
cg c]  \  }
}t        |
||	|       }}
}t        ||||      }||||fS t        d      c c}}
w )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    1q!a%3y))aAq!AQ?y))ADAq}}VAq\"r71a=1	AA0131-1a
#3A3 Ar1-A}!Qwy)) 	4s   C
c                    g dgt        |      z  |dz
  }
}	}|D ]  }t        |
|      }t        ||      |z  }t        t	        t        |                  D ]M  }d||   ||   c}}\  }}||z  s||z  |dz   }}||z  s|dk7  s.t        |t        |||
|      |
|      dc}|	|<   O |j                  |        t        |	      st        g g }}t        ||      D ]  \  }}t        |||
|      }t        ||      }|j                  |      r||z  }n.|j                  ||      }||z  ||z  }}t        |||      ||z  }}t        |||
|      }|j                  |       |j                  |        |j                  |      r| ||fS g g }}t        ||      D ]?  \  }}|j                  t        |||
|             |j                  t        ||d|             A t        | |t        |      dz
  z  ||      } | ||fS )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!qA AqM1aLO%A-( 	CAadAaDLAq&1a1u!tQU1 1u Av!!WQ1a%8!Q?1Q4	C 	
 q6BAq	 1!Q1%Aq\88B<QBb!AqD"a%rA"1a+RUrA1b!Q'
		!
		!  	xx|"by2CB 01

>!RA./

>!RA./0 	q"s1vz*Aq1Ac3;rv   c           
      &   t        |       dk(  r| \  }}t        ||      }t        ||      }t        ||||      \  }}	}
t        |||      }t        |	||      }	t	        ||||      \  }}t        |	||||      }	t        ||      }t        |	|      }	||	g}|S | d   g}
t        | dd       D ]"  }|
j                  dt        ||
d   |             $ g dgg}}t        | |
      D ]@  \  }}t        ||g|d   g d|d|      \  }	}|j                  |	       |j                  |       B g ||d   gz   }}t        ||       D ]S  \  }}t        ||      }t        ||      }t        t        |||      |||      }t        ||      }|j                  |       U |S )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{1Q"Q"1aA&1aaAaAaAq!1q!Q1%1a 1a Q2 M/ rUG!Ab'" 	-AHHQ1Q4+,	- QC511I 	DAq%q!faeRAq!DDAqHHQKHHQK	
 QrUG1I 	DAq A&A A&AyAq)1a3Aq!$AMM!	 Mrv   c           
         |s| D cg c]  }g  }}t        |      }	t        |      D ]a  \  }
}|s	t        | |	|
z
  ||      }t        t        ||            D ]0  \  }\  }}t	        |||      }t        t        |||      ||      ||<   2 c |S t        |      }	t        | ||      }|d   |dd }}g g }}| D ]=  }|j                  t        ||||             |j                  t        |||	||             ? t        |||	||      }|dz
  }t        |||||||      }|D cg c]  }t        |d||       }}t        ||      D ]  \  }}t        |||||      } t        ||||      }t!        |j"                  | g|	|      }t%        |	|      }t'        d|      D ]  }t)        ||      r nt+        ||||      }t-        ||dz   ||	||      }t)        ||      r@t/        ||j1                   ||      dz         ||      }t        |||||||      }t        |      D ]"  \  }
}t+        t        |d||      |||      ||
<   $ t        t        ||            D ]  \  }
\  }}t3        ||||      ||
<    t        ||      D ]  \  }}t        |||||      } t        ||||      } |D cg c]  }t        ||||       }}|S c c}w c c}w c c}w )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!! 	9HAu"1a!eQ2A&s1ay1 9	6Aq"1eQ/ Aq!11a8!9	9v Hc Fq!Quaf121 	1AHHWQ1a()HH[Aq!Q/0	1 1aA&Eq!Q1a3-.0i1a#001I 	+DAqAq!Q*A	+ Q1a(aeeaR[!Q'AqMq! 	1A!Q1a#A AE1aA6Aa#"1akk!A$(&;QB&q!Q1a;%aL CDAq"9Q1a#8!QBAaDC "+3q!9!5 /IAv1"1aA.AaD/  1I 3DAq#Aq!Q2A3 %Q1a0)	1, 567qq!Q*77H} 8 1@ 8s   	KK)Kc                 &   | gt        |      |dz
  }	}}t        |      }t        t        |dd             D ]>  \  }
}t	        |d   |||
z
  ||
z
  |      }|j                  dt        |||	|
z
  |             @ t        t        | |      dd       }t        t        d|dz         ||      D ]  \  }}}t        |      |dz
  }}|d|dz
   ||dz
  d }}t        t        ||            D ]@  \  }
\  }}t        t        |||	|      ||dz
  |      }|gt        |dd d|dz
  |      z   ||
<   B t        |j                  | g||      }t        ||      }t!        |t#        |||      ||      }t%        |||      }t        d|      D ]  }t'        ||      r t)        ||||      }t+        ||dz   ||||      }t'        ||dz
        rBt-        ||j/                   ||      dz         |dz
  |      }t1        ||||||dz
  |      }t        t        ||            D ]7  \  }
\  }}t3        |t        |d|dz
  |      |||      }t        ||||      ||
<   9 t!        |t#        |||      ||      }t        ||||      }  t#        |||      | k7  rt4        |S )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!qAQA(1QR5/* 61!aQAq1	$Q1q5!456 	OAq!!"%&AuQA1-  11aAwA1!a%y!AEF)1#C2J/ 	8JAw2!-Aq!"<aQJB4)AabE1a!eQ77AaD	8 aeeaR[!Q'AqMAz!Q*Aq11a#q" 	1A!Q1a#A AE1aA6AaQ'"1akk!A$(&;QUAF&q!Q1a!eQ?!*3q!9!5 8IAv1#AyAq1ua'@!QJA+Aq!Q7AaD8 Az!Q2Aq9$Q1a0!	1! 1D !Qarv   c           
         ddl m} t        |      }t        t	        | |      |dz
  |      \  }}t        | ||      }	 | ||	            }
|
|dk(  rd}nd}t               g |j                  g|z  df\  }}}}	 t        | |||||      \  }}}t        ||      \  }}t        |      }|dk(  r| gS |||||fg}t        d      }t        d      }t        d      }t        |      |k  rt        |      D ]  }t        |      D cg c]  } | || |             }}t        |      |vr|j                  t        |             nR	 t        | |||||      \  }}}t        ||      \  }}t        |      }|||k7  r||k  rg |}}n|}|dk(  r| gc S |j!                  |||||f       t        |      |k(  s n ||z  }t        |      |k  rd	\  }}}|D ]'  \  }}}}}t#        ||      }|
||k  r|}|}n|}|dz  }) ||   \  }}}}}| }	 t%        | |||||||      \  } }}t'        | ||||
||      }g }|D ]L  } t-        | ||      \  }} |j/                  t1        | ||            rt3        | ||      } |j!                  |        N |S # t        $ r Y w xY wc c}w # t        $ r Y w xY w# t(        $ r* t        d
      rt+        ||||dz         cY S t)        d      w xY w)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   r2  r2    s   < (tnG&A,Aq1EBaA&A	)A,A
{6CC UB
D8GWa*1aQ1=Aq A&1F63Jr1a#$ 34O/0M+,L
g,
(}% "	 A16q;A!GSD#&';A;Qxw&E!H%21aQ1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*1aQ1aC1b,Q2q!QB F #Aq!,1==q!Q/01a Aa Mc   < $ \  G()vq!S1W55#EG G	GsB   85J .J  JJ'J, 	JJ	J)(J),%KKc                    |st        | |      S t        | |      r|j                  g fS t        | ||      \  }}t	        |||      dk  r| t        |||      }}t        d t        ||      D              r|g fS t        |||      \  }}g }t        ||      dkD  r(t        |||      }t        |||      }t        | |||      }t        ||dz
  |      d   D ]  \  }}|j                  d|g|f        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              3   &   K   | ]	  }|d k    ywr   Nr~   r   r   s     rt   r   z dmp_zz_factor.<locals>.<genexpr>       
1a16
1r   rh   )r  r   r/  rJ   r   r)   r  r   rQ   r   rX   r2  ry   r.  r   rZ   r[   )	rl   rx   rn   r   r   r   rm   r   rq   s	            rt   r.  r.  m  s+   H Q""!Qvvrz"1a+GD!Q1!%Aq)a

1?1a0
11RxAq!DAqG!Q!Aq!1a $Q1a0aQ*1- $1qA3(#$ q!W%w'''rv   c           	          |j                         }t        | ||      } t        | |      \  }}|D cg c]  \  }}t        |||      |f }}}|j                  ||      }||fS c c}}w )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_factorrH    su     
			BAr2A$Q+NE7;BCaCR(!,CGCJJub!E'> Ds   A$c                 <   |j                         }t        | ||      } t        | |      \  }}g }|D ]R  \  }}t        ||      \  }}	t        |	||      }
t	        |
d|      \  }}|||z  z  ||z  z  }|j                  ||f       T |}|j                  ||      }||fS )z>Factor univariate polynomials into irreducibles in `ZZ_I[x]`. r   )	get_fieldr   rH  rB   rJ   rk   r   )rl   r   rG  r   rm   new_factorsr  r   	fac_denomfac_numfac_num_ZZ_Icontentfac_prims                rt   dup_zz_i_factorrQ    s     
BAr2A$Q+NE7K *Q-c26	7"7B30q"EA%)q.8Ha=)* GJJub!E'>rv   c           
          |j                         }t        | |||      } t        | ||      \  }}|D cg c]  \  }}t        ||||      |f }}}|j                  ||      }||fS c c}}w )z@Factor multivariate polynomials into irreducibles in `QQ_I[X]`. )rF  r   dmp_factor_listr   )rl   rx   r   rG  r   rm   r  r   s           rt   dmp_qq_i_factorrT    s{     
			BAq"b!A$Q2.NE7>EFFCCB+Q/FGFJJub!E'> Gs   A'c                 D   |j                         }t        | |||      } t        | ||      \  }}g }|D ]T  \  }}t        |||      \  }	}
t        |
|||      }t	        |||      \  }}|||z  z  |	|z  z  }|j                  ||f       V |}|j                  ||      }||fS )z@Factor multivariate polynomials into irreducibles in `ZZ_I[X]`. )rJ  r   rT  rC   rJ   rk   r   )rl   rx   r   rG  r   rm   rK  r  r   rL  rM  rN  rO  rP  s                 rt   dmp_zz_i_factorrV    s     
BAq"b!A$Q2.NE7K *Q-c1b9	7"7Ar260q"EA%)q.8Ha=)* GJJub!E'>rv   c                    t        |       t        | |      }}t        | |      } |dk  r|g fS |dk(  r|| dfgfS t        | |      | }} t	        | |      \  }}}t        ||j                        }t        |      dk(  r|| |t        |       z  fgfS ||j                  z  }	t        |      D ]B  \  }
\  }}t        ||j                  |      }t        |||      \  }}}t        ||	|      }|||
<   D 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   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!Q<rA!QAAv2vAvQF8|1qqA1a GAq!%a/G
7|qQ:a=()***	!&&A#G, ;FAq)1a(1aaA
	 !GQ/Gq'"w;rv   c                 J   |st        | |      S t        | ||      }t        | ||      } t        d t	        | |      D              r|g fS t        | ||      | }} t        | ||      \  }}}t        |||j                        }t        |      dk(  r| g}not        |      D ]a  \  }	\  }
}t        |
||j                  |      }t        ||||      \  }}}|D cg c]  }||j                  z   }}t        ||||      }|||	<   c t        ||||      }t!        |||       ||fS c c}w )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   &   K   | ]	  }|d k    ywrB  r~   rC  s     rt   r   z!dmp_ext_factor.<locals>.<genexpr>  rD  r   rh   )r[  r   rH   r  r   rX   rV   dmp_factor_list_includerY  r   r  r   rS   rZ  rO   ry   rZ   )rl   rx   rn   r   r   r   r   rs   rm   r   rp   r   r   sir   ro   s                   rt   dmp_ext_factorr`  T  sA   ^ a##	q!Q	BAq!A

1?1a0
112v1a !qA1a#GAq!%aAEE2G
7|q#'0 	NA{FAquua0A#Aq!Q/GAq!%&'rAFF'A'!Q1%AGAJ	  7Aq1Fq!V$v: (s   D c                    t        | ||j                        } t        | |j                  |j                        \  }}t	        |      D ]$  \  }\  } }t        | |j                  |      |f||<   & |j                  ||j                        |fS )z2Factor univariate polynomials over finite fields. )r   rY  r   r3  r  r   )rl   rn   r   rm   r   rq   s         rt   dup_gf_factorrb    s    Aq!%% Aq!%%/NE7w' 3	6Aq!!QUUA.2
3 99UAEE"G++rv   c                     t        d      )z4Factor multivariate polynomials over finite fields. z+multivariate polynomials over finite fields)NotImplementedError)rl   rx   rn   s      rt   dmp_gf_factorre    s    
K
LLrv   c                 b   t        | |      \  }} t        | |      \  }} |j                  rt        | |      \  }}n9|j                  rt        | |      \  }}n|j                  rt        | |      \  }}n|j                  rt        | |      \  }}n|j                  s ||j                         }}t        | ||      } nd}|j                  r.|j                         }t        | ||      \  }} t        | ||      } n|}|j                   rt#        | |      \  }}n|j$                  rot'        | d|      \  } }	t)        | |	|j*                        \  }}t-        |      D ]  \  }
\  } }t/        | |	|      |f||
<    |j1                  ||j*                        }nt3        d|z        |j                  rt-        |      D ]  \  }
\  } }t        | ||      |f||
<    |j1                  ||      }|j5                  |      }|ryt-        |      D ]W  \  }
\  } }t7        | |      }t9        | ||      } t        | ||      } | |f||
<   |j;                  ||j=                  ||            }Y |j1                  ||      }|}|r*|j?                  d|j@                  |jB                  g|f       ||z  tE        |      fS );Factor univariate polynomials into irreducibles in `K[x]`. Nr   #factorization not supported over %s)#r&   rI   is_FiniteFieldrb  is_Algebraicr[  is_GaussianRingrQ  is_GaussianFieldrH  is_Exact	get_exactr   is_Fieldr   rB   r   r  is_Polyr$   rS  rY  r  r%   r   r^   quor;   r@   mulpowr   r   r/  r[   )rl   r   r  r   r   rm   
K0_inexactrn   denomrx   r   rq   max_norms                rt   r   r     s   BDAqAr"GD!	&q"-w	'2.w			(B/w			(B/w{{JAz2.AJ;;A'2q1HE1Ar1%AA77*1a0NE7YYaA&DAq,Q1559NE7&w/ 5	6Aq'1a0!4
5 IIeQUU+ECbHII;;&w/ 8	6Aq)!Q3Q7
8 JJua(EFF5%(E!*7!3 ?IAv1+Ar2H&q(B7A#Ar:6A"#QGAJFF5"&&1*=>E? #**5"5qBFFBGG,a01:}W---rv   c                     t        | |      \  }}|st        |g      dfgS t        |d   d   ||      }||d   d   fg|dd z   S )rg  rh   r   N)r   r   r>   )rl   rn   r   rm   r   s        rt   rX  rX    sa    $Q*NE7E7#Q'((71:a=%3GAJqM"#gabk11rv   c           	      l   |st        | |      S t        | ||      \  }} t        | ||      \  }} |j                  rt	        | ||      \  }}n~|j
                  rt        | ||      \  }}n`|j                  rt        | ||      \  }}nB|j                  rt        | ||      \  }}n$|j                  s!||j                         }}t        | |||      } nd}|j                  r0|j                         }t!        | |||      \  }	} t        | |||      } n|}|j"                  rKt%        | ||      \  }
} }t'        | ||      \  }}t)        |      D ]  \  }\  } }t+        | |
||      |f||<    n|j,                  rot/        | ||      \  } }t1        | ||j2                        \  }}t)        |      D ]  \  }\  } }t5        | ||      |f||<    |j7                  ||j2                        }nt9        d|z        |j                  rt)        |      D ]  \  }\  } }t        | |||      |f||<    |j7                  ||      }|j;                  |	      }|r|t)        |      D ]Z  \  }\  } }t=        | ||      }t?        | |||      } t        | |||      } | |f||<   |jA                  ||jC                  ||            }\ |j7                  ||      }|}t)        tE        |            D ]D  \  }}|s	d||z
  z  dz   d|z  z   |jF                  i}|jI                  dtK        |||      |f       F ||z  tM        |      fS )=Factor multivariate polynomials into irreducibles in `K[X]`. Nrh  )r   )rh   r   )'r   r'   rJ   ri  re  rj  r`  rk  rV  rl  rT  rm  rn  r   ro  r   rC   r   r"   r.  r  r#   rp  r$   rS  rY  r%   r   r^   rq  r<   rA   rr  rs  r  r   r   r   r[   )rl   rx   r   r  r   r   rm   rt  rn   ru  levelsr  r   rq   rv  r  terms                    rt   rS  rS     sU   q"%%Ar"DAq"1a,GD!	&q!R0w	'1b1w			(Ar2w			(Ar2w{{JAq*b1AJ;;A'1b!4HE1Aq"a(AA77&q!Q/LFAq*1a3NE7&w/ ?	6Aq)!VQ:A>
?YYaA&DAq,Q1559NE7&w/ 5	6Aq'1a0!4
5 IIeQUU+ECbHII;;&w/ ;	6Aq)!Q26:
; JJua(EFF5%(E!*7!3 ?IAv1+Aq"5H&q(Ar:A#Aq"j9A"#QGAJFF5"&&1*=>E? #**5"5(1+& ;1a!et#d1f,bff5q=q"5q9:; :}W---rv   c                     |st        | |      S t        | ||      \  }}|st        ||      dfgS t        |d   d   |||      }||d   d   fg|dd z   S )ry  rh   r   N)rX  rS  r    r?   )rl   rx   rn   r   rm   r   s         rt   r^  r^  M  su    &q!,,$Q1-NE7E1%q)**71:a=%A6GAJqM"#gabk11rv   c                     t        | d|      S )z_
    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                 `    t        | ||      \  }}|syt        |      dkD  ry|d   \  }}|dk(  S )za
    Returns ``True`` if a multivariate polynomial ``f`` has no factors
    over its domain.
    Trh   Fr   )rS  r   )rl   rx   rn   r   rm   rq   s         rt   r~  r~  c  sA    
 !Aq)JAw	W	qz1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'  r2  r.  rH  rQ  rT  rV  r[  r`  rb  re  r   rX  rS  r^  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   