
    Цi	                     ^    S r SSKJr  SSKJr  SSKJrJr  SSKJ	r	  \	 " S S\\5      5       r
g)	z1Implementation of :class:`PolynomialRing` class.     )Ring)CompositeDomain)CoercionFailedGeneratorsError)publicc                      \ rS rSrSrS=rrSrSrS)S jr	S r
\S 5       r\S 5       r\S	 5       rS
 rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS r S r!S r"S r#S r$S  r%S! r&S" r'S# r(S$ r)S% r*S& r+S' r,S(r-g)*PolynomialRing
   z8A class for representing multivariate polynomial rings. TNc                    SSK Jn  [        X5      (       a	  Uc  Uc  UnO	U" X!U5      nXPl        UR                  U l        UR
                  U l        UR                  U l        UR                  U l        UR                  U l        U(       aL  UR                  R                  (       a1  UR                  R                  (       a  [        U5      S:X  a  SU l        U R                  U l        g )Nr   )PolyRing   T)sympy.polys.ringsr   
isinstanceringdtypegensngenssymbolsdomainis_Fieldis_Exactlenis_PIDdom)selfdomain_or_ringr   orderr   r   s         a/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/sympy/polys/domains/polynomialring.py__init__PolynomialRing.__init__   s    .n//GO!DGU;D	ZZ
II	ZZ
||kk {{##(<(<Wq" ;;    c                 8    U R                   R                  U5      $ N)r   ring_new)r   elements     r   newPolynomialRing.new+   s    yy!!'**r!   c                 .    U R                   R                  $ r#   )r   zeror   s    r   r)   PolynomialRing.zero.   s    yy~~r!   c                 .    U R                   R                  $ r#   )r   oner*   s    r   r-   PolynomialRing.one2   s    yy}}r!   c                 .    U R                   R                  $ r#   )r   r   r*   s    r   r   PolynomialRing.order6   s    yyr!   c                     [        U R                  5      S-   SR                  [        [         U R                  5      5      -   S-   $ )N[,])strr   joinmapr   r*   s    r   __str__PolynomialRing.__str__:   s4    4;;#%S$,,1G(HH3NNr!   c                     [        U R                  R                  U R                  R                  U R
                  U R                  45      $ r#   )hash	__class____name__r   r   r   r   r*   s    r   __hash__PolynomialRing.__hash__=   s0    T^^,,djjoot{{DLLYZZr!   c                     [        U[        5      =(       a[    U R                  R                  U R                  U R
                  4UR                  R                  UR                  UR
                  4:H  $ )z.Returns `True` if two domains are equivalent. )r   r	   r   r   r   r   )r   others     r   __eq__PolynomialRing.__eq__@   sQ    %0 <ZZ__dkk4<<8[[u||U]];<	<r!   c                 ~    UR                   (       d  gU R                  nUR                  UR                  X5      5      $ )z/Returns ``True`` if ``a`` is a unit of ``self``F)	is_groundr   is_unitconvert_from)r   aKs      r   rF   PolynomialRing.is_unitF   s-    {{KKyy011r!   c                     U R                   R                  UR                  5      nU R                  R	                  U5      $ r#   )r   canonical_unitLCr   
ground_new)r   rH   us      r   rL   PolynomialRing.canonical_unitM   s/    KK&&qtt,yy##A&&r!   c                 "    UR                  5       $ )zConvert `a` to a SymPy object. )as_exprr   rH   s     r   to_sympyPolynomialRing.to_sympyQ   s    yy{r!   c                 8    U R                   R                  U5      $ )z'Convert SymPy's expression to `dtype`. )r   	from_exprrS   s     r   
from_sympyPolynomialRing.from_sympyU   s    yy""1%%r!   c                 D    U " U R                   R                  X5      5      $ z*Convert a Python `int` object to `dtype`. r   convertK1rH   K0s      r   from_ZZPolynomialRing.from_ZZY       "))##A*++r!   c                 D    U " U R                   R                  X5      5      $ r[   r\   r^   s      r   from_ZZ_pythonPolynomialRing.from_ZZ_python]   rc   r!   c                 D    U " U R                   R                  X5      5      $ z/Convert a Python `Fraction` object to `dtype`. r\   r^   s      r   from_QQPolynomialRing.from_QQa   rc   r!   c                 D    U " U R                   R                  X5      5      $ rh   r\   r^   s      r   from_QQ_pythonPolynomialRing.from_QQ_pythone   rc   r!   c                 D    U " U R                   R                  X5      5      $ )z(Convert a GMPY `mpz` object to `dtype`. r\   r^   s      r   from_ZZ_gmpyPolynomialRing.from_ZZ_gmpyi   rc   r!   c                 D    U " U R                   R                  X5      5      $ )z(Convert a GMPY `mpq` object to `dtype`. r\   r^   s      r   from_QQ_gmpyPolynomialRing.from_QQ_gmpym   rc   r!   c                 D    U " U R                   R                  X5      5      $ )z/Convert a `GaussianInteger` object to `dtype`. r\   r^   s      r   from_GaussianIntegerRing'PolynomialRing.from_GaussianIntegerRingq   rc   r!   c                 D    U " U R                   R                  X5      5      $ )z0Convert a `GaussianRational` object to `dtype`. r\   r^   s      r   from_GaussianRationalField)PolynomialRing.from_GaussianRationalFieldu   rc   r!   c                 D    U " U R                   R                  X5      5      $ z*Convert a mpmath `mpf` object to `dtype`. r\   r^   s      r   from_RealFieldPolynomialRing.from_RealFieldy   rc   r!   c                 D    U " U R                   R                  X5      5      $ r{   r\   r^   s      r   from_ComplexField PolynomialRing.from_ComplexField}   rc   r!   c                     U R                   U:w  a  U R                   R                  X5      nUb  U R                  U5      $ g)z*Convert an algebraic number to ``dtype``. N)r   rG   r&   r^   s      r   from_AlgebraicField"PolynomialRing.from_AlgebraicField   s9    99?		&&q-A=66!9 r!   c                 f     UR                  U R                  5      $ ! [        [        4 a     gf = f)z#Convert a polynomial to ``dtype``. N)set_ringr   r   r   r^   s      r   from_PolynomialRing"PolynomialRing.from_PolynomialRing   s1    	::bgg&&0 		s    00c                 F   U R                   U:X  a  U R                  R                  U/5      $ UR                  U5      R	                  UR                  U5      5      u  p4UR                  (       a3  U R                  X2R                  R                  R                  5       5      $ g)z*Convert a rational function to ``dtype``. N)
r   r   	from_listnumerdivdenomis_zeror   field	to_domain)r_   rH   r`   qrs        r   from_FractionField!PolynomialRing.from_FractionField   sp    99?77$$aS))xx{rxx{+99))!XX]]-D-D-FGGr!   c                    U R                   UR                  :X  ao  UR                  5       nU R                  UR                  :w  a=  UR	                  5        VVs0 s H   u  pEX@R                  R                  U5      _M"     nnnU " U5      $ UR                  (       a>  UR                  U :X  a-  U R                  UR                  5       S   UR                  5      $ ggs  snnf )z)Convert from old poly ring to ``dtype``. r   N)	r   r   to_dictr   itemsr]   rE   rG   to_list)r_   rH   r`   admcs         r   from_GlobalPolynomialRing(PolynomialRing.from_GlobalPolynomialRing   s    :: ByyBII%:<((*E*$!a**1--*Eb6M[[RYY"_??199;q>299== -[ Fs   'Cc                 R    U R                   R                  5       R                  5       $ )z(Returns a field associated with `self`. )r   to_fieldr   r*   s    r   	get_fieldPolynomialRing.get_field   s    yy!!#--//r!   c                 L    U R                   R                  UR                  5      $ )z%Returns True if `LC(a)` is positive. )r   is_positiverM   rS   s     r   r   PolynomialRing.is_positive       {{&&qtt,,r!   c                 L    U R                   R                  UR                  5      $ )z%Returns True if `LC(a)` is negative. )r   is_negativerM   rS   s     r   r   PolynomialRing.is_negative   r   r!   c                 L    U R                   R                  UR                  5      $ )z)Returns True if `LC(a)` is non-positive. )r   is_nonpositiverM   rS   s     r   r   PolynomialRing.is_nonpositive       {{))!$$//r!   c                 L    U R                   R                  UR                  5      $ )z)Returns True if `LC(a)` is non-negative. )r   is_nonnegativerM   rS   s     r   r   PolynomialRing.is_nonnegative   r   r!   c                 $    UR                  U5      $ )zExtended GCD of `a` and `b`. )gcdexr   rH   bs      r   r   PolynomialRing.gcdex   s    wwqzr!   c                 $    UR                  U5      $ )zReturns GCD of `a` and `b`. )gcdr   s      r   r   PolynomialRing.gcd       uuQxr!   c                 $    UR                  U5      $ )zReturns LCM of `a` and `b`. )lcmr   s      r   r   PolynomialRing.lcm   r   r!   c                 V    U R                  U R                  R                  U5      5      $ )zReturns factorial of `a`. )r   r   	factorialrS   s     r   r   PolynomialRing.factorial   s     zz$++//233r!   )r   r   r   r   r   r   r   r   )NN).r=   
__module____qualname____firstlineno____doc__is_PolynomialRingis_Polyhas_assoc_Ringhas_assoc_Fieldr   r&   propertyr)   r-   r   r8   r>   rB   rF   rL   rT   rX   ra   re   ri   rl   ro   rr   ru   rx   r|   r   r   r   r   r   r   r   r   r   r   r   r   r   r   __static_attributes__ r!   r   r	   r	   
   s    B"&&NO0+      O[<2'&,,,,,,,,,,
>0--004r!   r	   N)r   sympy.polys.domains.ringr   #sympy.polys.domains.compositedomainr   sympy.polys.polyerrorsr   r   sympy.utilitiesr   r	   r   r!   r   <module>r      s4    7 * ? B "|4T? |4 |4r!   