Ë
    7^(h  ã                   óp   — d Z ddlmZ ddlmZ ddlmZmZ ddlm	Z	 e	 G d„ d«      «       Z
 G d„ d	e«      Zy
)z.Implementation of :class:`QuotientRing` class.é    ©ÚFreeModuleQuotientRing)ÚRing)ÚNotReversibleÚCoercionFailed)Úpublicc                   ój   — e Zd ZdZd„ Zd„ ZeZd„ Zd„ ZeZ	d„ Z
d„ Zd„ Zd	„ ZeZd
„ Zd„ Zd„ Zd„ Zd„ Zy)ÚQuotientRingElementzº
    Class representing elements of (commutative) quotient rings.

    Attributes:

    - ring - containing ring
    - data - element of ring.ring (i.e. base ring) representing self
    c                 ó    — || _         || _        y ©N)ÚringÚdata)Úselfr   r   s      ú^/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/sympy/polys/domains/quotientring.pyÚ__init__zQuotientRingElement.__init__   s   € ØˆŒ	Øˆ�	ó    c                 óÂ   — ddl m} | j                  j                  j                  | j                  «      } ||«      dz   t        | j                  j                  «      z   S )Nr   )Ússtrz + )Úsympy.printing.strr   r   Úto_sympyr   ÚstrÚ
base_ideal)r   r   r   s      r   Ú__str__zQuotientRingElement.__str__   sD   € Ý+Ø�y‰y�~‰~×&Ñ& t§y¡yÓ1ˆÙ�D‹z˜EÑ!¤C¨¯	©	×(<Ñ(<Ó$=Ñ=Ð=r   c                 ó:   — | j                   j                  | «       S r   )r   Úis_zero©r   s    r   Ú__bool__zQuotientRingElement.__bool__$   s   € Ø—9‘9×$Ñ$ TÓ*Ð*Ð*r   c                 ó  — t        || j                  «      r|j                  | j                  k7  r	 | j                  j                  |«      }| j                  | j                  |j                  z   «      S # t        t
        f$ r	 t        cY S w xY wr   ©Ú
isinstanceÚ	__class__r   ÚconvertÚNotImplementedErrorr   ÚNotImplementedr   ©r   Úoms     r   Ú__add__zQuotientRingElement.__add__'   sr   € Ü˜"˜dŸn™nÔ-°·±¸D¿I¹IÒ1Eð&Ø—Y‘Y×&Ñ& rÓ*�ð �y‰y˜Ÿ™ R§W¡WÑ,Ó-Ð-øô (¬Ð8ò &Ü%Ò%ð&ús   ±A4 Á4BÂBc                 ó„   — | j                  | j                  | j                   j                   j                  d«      z  «      S )Néÿÿÿÿ)r   r   r"   r   s    r   Ú__neg__zQuotientRingElement.__neg__1   s-   € Ø�y‰y˜Ÿ™ 4§9¡9§>¡>×#9Ñ#9¸"Ó#=Ñ=Ó>Ð>r   c                 ó&   — | j                  | «      S r   ©r'   r%   s     r   Ú__sub__zQuotientRingElement.__sub__4   s   € Ø�|‰|˜R˜CÓ Ð r   c                 ó&   — |  j                  |«      S r   r,   r%   s     r   Ú__rsub__zQuotientRingElement.__rsub__7   s   € Ø��‰˜rÓ"Ð"r   c                 óì   — t        || j                  «      s	 | j                  j                  |«      }| j                  | j                  |j                  z  «      S # t        t
        f$ r	 t        cY S w xY wr   r   ©r   Úos     r   Ú__mul__zQuotientRingElement.__mul__:   sc   € Ü˜!˜TŸ^™^Ô,ð&Ø—I‘I×%Ñ% aÓ(�ð �y‰y˜Ÿ™ 1§6¡6Ñ)Ó*Ð*øô (¬Ð8ò &Ü%Ò%ð&ús   ˜A ÁA3Á2A3c                 ó>   — | j                   j                  | «      |z  S r   )r   Úrevertr1   s     r   Ú__rtruediv__z QuotientRingElement.__rtruediv__D   s   € Ø�y‰y×Ñ Ó% aÑ'Ð'r   c                 óØ   — t        || j                  «      s	 | j                  j                  |«      }| j                  j                  |«      | z  S # t        t
        f$ r	 t        cY S w xY wr   )r    r!   r   r"   r#   r   r$   r5   r1   s     r   Ú__truediv__zQuotientRingElement.__truediv__G   sa   € Ü˜!˜TŸ^™^Ô,ð&Ø—I‘I×%Ñ% aÓ(�ð �y‰y×Ñ Ó" 4Ñ'Ð'øô (¬Ð8ò &Ü%Ò%ð&ús   ˜A ÁA)Á(A)c                 ó†   — |dk  r| j                   j                  | «      | z  S | j                  | j                  |z  «      S )Nr   )r   r5   r   )r   Úoths     r   Ú__pow__zQuotientRingElement.__pow__O   s=   € Ø�Š7Ø—9‘9×#Ñ# DÓ)¨c¨TÑ1Ð1Ø�y‰y˜Ÿ™ cÑ)Ó*Ð*r   c                 óž   — t        || j                  «      r|j                  | j                  k7  ry| j                  j                  | |z
  «      S )NF)r    r!   r   r   r%   s     r   Ú__eq__zQuotientRingElement.__eq__T   s;   € Ü˜"˜dŸn™nÔ-°·±¸D¿I¹IÒ1EØØ�y‰y× Ñ  ¨¡Ó+Ð+r   c                 ó   — | |k(   S r   © r%   s     r   Ú__ne__zQuotientRingElement.__ne__Y   s   € Ø˜2‘:ˆ~Ðr   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   Ú__repr__r   r'   Ú__radd__r*   r-   r/   r3   Ú__rmul__r6   r8   r;   r=   r@   r?   r   r   r
   r
      s]   „ ñòò>ð
 €Hò+ò.ð €Hò?ò!ò#ò+ð €Hò(ò(ò+ò
,ó
r   r
   c                   óŒ   — e Zd ZdZdZdZeZd„ Zd„ Z	d„ Z
d„ Zd„ Zd	„ ZeZeZeZeZeZeZeZd
„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zy)ÚQuotientRingaa  
    Class representing (commutative) quotient rings.

    You should not usually instantiate this by hand, instead use the constructor
    from the base ring in the construction.

    >>> from sympy.abc import x
    >>> from sympy import QQ
    >>> I = QQ.old_poly_ring(x).ideal(x**3 + 1)
    >>> QQ.old_poly_ring(x).quotient_ring(I)
    QQ[x]/<x**3 + 1>

    Shorter versions are possible:

    >>> QQ.old_poly_ring(x)/I
    QQ[x]/<x**3 + 1>

    >>> QQ.old_poly_ring(x)/[x**3 + 1]
    QQ[x]/<x**3 + 1>

    Attributes:

    - ring - the base ring
    - base_ideal - the ideal used to form the quotient
    TFc                 óä   — |j                   |k(  st        d|›d|›�«      ‚|| _         || _         | | j                   j                  «      | _         | | j                   j                  «      | _        y )NzIdeal must belong to z, got )r   Ú
ValueErrorr   ÚzeroÚone)r   r   Úideals      r   r   zQuotientRing.__init__|   sT   € Ø�z‰z˜TÒ!ÝÂ$ÉÐNÓOÐOØˆŒ	ØˆŒÙ˜Ÿ™Ÿ™Ó(ˆŒ	Ù˜Ÿ	™	Ÿ™Ó&ˆ�r   c                 ó^   — t        | j                  «      dz   t        | j                  «      z   S )Nú/)r   r   r   r   s    r   r   zQuotientRing.__str__„   s#   € Ü�4—9‘9‹~ Ñ#¤c¨$¯/©/Ó&:Ñ:Ð:r   c                 ó„   — t        | j                  j                  | j                  | j                  | j
                  f«      S r   )Úhashr!   rA   Údtyper   r   r   s    r   Ú__hash__zQuotientRing.__hash__‡   s,   € Ü�T—^‘^×,Ñ,¨d¯j©j¸$¿)¹)ÀTÇ_Á_ÐUÓVÐVr   c                 óº   — t        || j                  j                  «      s| j                  |«      }| j                  | | j                  j	                  |«      «      S )z4Construct an element of ``self`` domain from ``a``. )r    r   rS   r   Úreduce_element©r   Úas     r   ÚnewzQuotientRing.newŠ   sA   € ä˜!˜TŸY™YŸ_™_Ô-Ø—	‘	˜!“ˆAà�z‰z˜$ §¡× >Ñ >¸qÓ AÓBÐBr   c                 óŽ   — t        |t        «      xr4 | j                  |j                  k(  xr | j                  |j                  k(  S )z0Returns ``True`` if two domains are equivalent. )r    rI   r   r   )r   Úothers     r   r=   zQuotientRing.__eq__‘   s@   € ä˜%¤Ó.ò LØ�I‰I˜Ÿ™Ñ#òLØ(,¯©¸5×;KÑ;KÑ(Kð	Lr   c                 óF   —  | | j                   j                  ||«      «      S )z.Convert a Python ``int`` object to ``dtype``. )r   r"   )ÚK1rX   ÚK0s      r   Úfrom_ZZzQuotientRing.from_ZZ–   s   € á�"—'‘'—/‘/ ! RÓ(Ó)Ð)r   c                 óD   —  | | j                   j                  |«      «      S r   )r   Ú
from_sympyrW   s     r   ra   zQuotientRing.from_sympy¢   s   € Ù�D—I‘I×(Ñ(¨Ó+Ó,Ð,r   c                 óL   — | j                   j                  |j                  «      S r   )r   r   r   rW   s     r   r   zQuotientRing.to_sympy¥   s   € Ø�y‰y×!Ñ! !§&¡&Ó)Ð)r   c                 ó   — || k(  r|S y r   r?   )r   rX   r^   s      r   Úfrom_QuotientRingzQuotientRing.from_QuotientRing¨   s   € Ø�Š:ØˆHð r   c                 ó   — t        d«      ‚)z*Returns a polynomial ring, i.e. ``K[X]``. únested domains not allowed©r#   ©r   Úgenss     r   Ú	poly_ringzQuotientRing.poly_ring¬   ó   € ä!Ð">Ó?Ð?r   c                 ó   — t        d«      ‚)z)Returns a fraction field, i.e. ``K(X)``. rf   rg   rh   s     r   Ú
frac_fieldzQuotientRing.frac_field°   rk   r   c                 óÖ   — | j                   j                  |j                  «      | j                  z   }	  | |j	                  d«      d   «      S # t
        $ r t        |›d| ›�«      ‚w xY w)z/
        Compute a**(-1), if possible.
        é   r   z not a unit in )r   rN   r   r   Úin_terms_of_generatorsrK   r   )r   rX   ÚIs      r   r5   zQuotientRing.revert´   se   € ð �I‰I�O‰O˜AŸF™FÓ# d§o¡oÑ5ˆð	CÙ˜×0Ñ0°Ó3°AÑ6Ó7Ð7øÜò 	CÜº¹DÐ AÓBÐBð	Cús   ´A ÁA(c                 óL   — | j                   j                  |j                  «      S r   )r   Úcontainsr   rW   s     r   r   zQuotientRing.is_zero¾   s   € Ø�‰×'Ñ'¨¯©Ó/Ð/r   c                 ó   — t        | |«      S )zè
        Generate a free module of rank ``rank`` over ``self``.

        >>> from sympy.abc import x
        >>> from sympy import QQ
        >>> (QQ.old_poly_ring(x)/[x**2 + 1]).free_module(2)
        (QQ[x]/<x**2 + 1>)**2
        r   )r   Úranks     r   Úfree_modulezQuotientRing.free_moduleÁ   s   € ô & d¨DÓ1Ð1r   N)rA   rB   rC   rD   Úhas_assoc_RingÚhas_assoc_Fieldr
   rS   r   r   rT   rY   r=   r_   Úfrom_ZZ_pythonÚfrom_QQ_pythonÚfrom_ZZ_gmpyÚfrom_QQ_gmpyÚfrom_RealFieldÚfrom_GlobalPolynomialRingÚfrom_FractionFieldra   r   rd   rj   rm   r5   r   rv   r?   r   r   rI   rI   ]   s‹   „ ñð4 €NØ€OØ€Eò'ò;òWòCòLò
*ð €NØ#€NØ!€LØ!€LØ#€NØ .ÐØ'Ðò-ò*òò@ò@òCò0ó	2r   rI   N)rD   Úsympy.polys.agca.modulesr   Úsympy.polys.domains.ringr   Úsympy.polys.polyerrorsr   r   Úsympy.utilitiesr   r
   rI   r?   r   r   ú<module>r„      sA   ðÙ 4õ <Ý )ß @Ý "ð ÷Kð Kó ðKô\m2�4õ m2r   