§
    OŠtjš  ã                  óª   — U d Z ddlmZ ddlmZ ddlZddlmZ ddlm	Z	 ddl
mZ ddlmZ dd	lmZ e G d
„ dee¦  «        ¦   «         Zi Zded<   d„ ZdS )z1Implementation of :class:`ModularInteger` class. é    )Úannotations)ÚAnyN)ÚPicklableWithSlots)ÚCoercionFailed)ÚDomainElement)Úpublic)Úsympy_deprecation_warningc                  ó
  — e Zd ZdZd\  ZZZZdZd„ Z	d„ Z
d„ Zd„ Zd„ Zd	„ Zd
„ Zd„ Zd„ Zd„ Zed„ ¦   «         Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z d„ Z!d„ Z"d„ Z#d„ Z$d„ Z%d „ Z&d!„ Z'd"„ Z(ed#„ ¦   «         Z)d$„ Z*d%S )&ÚModularIntegerz(A class representing a modular integer. )NNNN)Úvalc                ó   — | j         S ©N)Ú_parent©Úselfs    ú`/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/sympy/polys/domains/modularinteger.pyÚparentzModularInteger.parent   s
   € ØŒ|Ðó    c                óª   — t          || j        ¦  «        r|j        | j        z  | _        d S | j                             |¦  «        | j        z  | _        d S r   )Ú
isinstanceÚ	__class__r   ÚmodÚdomÚconvert)r   r   s     r   Ú__init__zModularInteger.__init__   sL   € Ý�c˜4œ>Ñ*Ô*ð 	8Ø”w ¤Ñ)ˆDŒHˆHˆHà”x×'Ò'¨Ñ,Ô,¨t¬xÑ7ˆDŒHˆHˆHr   c                ó   — | j         S r   )r   r   s    r   ÚmoduluszModularInteger.modulus    s	   € ØŒxˆr   c                ó8   — t          | j        | j        f¦  «        S r   )Úhashr   r   r   s    r   Ú__hash__zModularInteger.__hash__#   s   € Ý�T”X˜tœxÐ(Ñ)Ô)Ð)r   c                ó0   — | j         j        ›d| j        ›d�S )Nú(ú))r   Ú__name__r   r   s    r   Ú__repr__zModularInteger.__repr__&   s   € Øœ>Ô2Ð2Ð2°D´H°H°HÐ=Ð=r   c                ó$   — | j         ›d| j        ›�S )Nz mod )r   r   r   s    r   Ú__str__zModularInteger.__str__)   s   € Ø"œh˜h˜h¨¬¨Ð1Ð1r   c                ó*   — t          | j        ¦  «        S r   )Úintr   r   s    r   Ú__int__zModularInteger.__int__,   s   € Ý�4”8‰}Œ}Ðr   c                ó”   — t          ddd¬¦  «         | j        r)| j        | j        dz  k    r| j        S | j        | j        z
  S | j        S )NzModularInteger.to_int() is deprecated.

            Use int(a) or K = GF(p) and K.to_int(a) instead of a.to_int().
            ú1.13zmodularinteger-to-int)Údeprecated_since_versionÚactive_deprecations_targeté   )r	   Úsymr   r   r   s    r   Úto_intzModularInteger.to_int/   sb   € å!ðð &,Ø'>ð	
ñ 	
ô 	
ð 	
ð Œ8ð 	ØŒx˜4œ8 q™=Ò(Ð(Ø”x�à”x $¤(Ñ*Ð*à”8ˆOr   c                ó   — | S r   © r   s    r   Ú__pos__zModularInteger.__pos__B   s   € Øˆr   c                ó8   — |                       | j         ¦  «        S r   )r   r   r   s    r   Ú__neg__zModularInteger.__neg__E   s   € Ø�~Š~˜tœx˜iÑ(Ô(Ð(r   c                óˆ   — t          || ¦  «        r|j        S 	 | j                             |¦  «        S # t          $ r Y d S w xY wr   )r   r   r   r   r   )ÚclsÚothers     r   Ú_get_valzModularInteger._get_valH   sW   € å�e˜SÑ!Ô!ð 	Ø”9ÐðØ”w—’ uÑ-Ô-Ð-øÝ!ð ð ð Ø�t�tðøøøs   ™3 ³
AÁ Ac                óx   — |                       |¦  «        }|�|                      | j        |z   ¦  «        S t          S r   ©r:   r   r   ÚNotImplemented©r   r9   r   s      r   Ú__add__zModularInteger.__add__R   ó6   € Ø�mŠm˜EÑ"Ô"ˆàˆ?Ø—>’> $¤(¨S¡.Ñ1Ô1Ð1å!Ð!r   c                ó,   — |                       |¦  «        S r   ©r?   ©r   r9   s     r   Ú__radd__zModularInteger.__radd__Z   ó   € Ø�|Š|˜EÑ"Ô"Ð"r   c                óx   — |                       |¦  «        }|�|                      | j        |z
  ¦  «        S t          S r   r<   r>   s      r   Ú__sub__zModularInteger.__sub__]   r@   r   c                ó.   — |                        |¦  «        S r   rB   rC   s     r   Ú__rsub__zModularInteger.__rsub__e   s   € Ø��Š˜uÑ%Ô%Ð%r   c                óx   — |                       |¦  «        }|�|                      | j        |z  ¦  «        S t          S r   r<   r>   s      r   Ú__mul__zModularInteger.__mul__h   r@   r   c                ó,   — |                       |¦  «        S r   )rK   rC   s     r   Ú__rmul__zModularInteger.__rmul__p   rE   r   c                óž   — |                       |¦  «        }|�0|                      | j        |                      |¦  «        z  ¦  «        S t          S r   )r:   r   r   Ú_invertr=   r>   s      r   Ú__truediv__zModularInteger.__truediv__s   sC   € Ø�mŠm˜EÑ"Ô"ˆàˆ?Ø—>’> $¤(¨T¯\ª\¸#Ñ->Ô->Ñ">Ñ?Ô?Ð?å!Ð!r   c                óP   — |                       ¦   «                              |¦  «        S r   )ÚinvertrK   rC   s     r   Ú__rtruediv__zModularInteger.__rtruediv__{   s   € Ø�{Š{‰}Œ}×$Ò$ UÑ+Ô+Ð+r   c                óx   — |                       |¦  «        }|�|                      | j        |z  ¦  «        S t          S r   r<   r>   s      r   Ú__mod__zModularInteger.__mod__~   r@   r   c                óx   — |                       |¦  «        }|�|                      || j        z  ¦  «        S t          S r   r<   r>   s      r   Ú__rmod__zModularInteger.__rmod__†   s6   € Ø�mŠm˜EÑ"Ô"ˆàˆ?Ø—>’> #¨¬¡.Ñ1Ô1Ð1å!Ð!r   c                ó  — |s|                       | j        j        ¦  «        S |dk     r|                      ¦   «         j        | }}n| j        }|                       t          |t          |¦  «        | j        ¦  «        ¦  «        S )Nr   )r   r   ÚonerR   r   Úpowr)   r   )r   Úexpr   s      r   Ú__pow__zModularInteger.__pow__Ž   sn   € Øð 	0Ø—>’> $¤(¤,Ñ/Ô/Ð/à�Š7ˆ7Ø—{’{‘}”}Ô(¨3¨$�ˆCˆCà”(ˆCà�~Š~�c #¥s¨3¡x¤x°´Ñ:Ô:Ñ;Ô;Ð;r   c                óp   — |                       |¦  «        }|€t          S  || j        || j        z  ¦  «        S r   )r:   r=   r   r   ©r   r9   Úopr   s       r   Ú_comparezModularInteger._compare™   s8   € Ø�mŠm˜EÑ"Ô"ˆàˆ;Ý!Ð!àˆr�$”(˜C $¤(™NÑ+Ô+Ð+r   c                ó–   — |                       |¦  «        }|€t          S t          dddd¬¦  «          || j        || j        z  ¦  «        S )Nz~Ordered comparisons with modular integers are deprecated.

            Use e.g. int(a) < int(b) instead of a < b.
            r,   zmodularinteger-compareé   )r-   r.   Ú
stacklevel)r:   r=   r	   r   r   r^   s       r   Ú_compare_deprecatedz"ModularInteger._compare_deprecated¡   sa   € Ø�mŠm˜EÑ"Ô"ˆàˆ;Ý!Ð!å!ðð &,Ø'?Øð	
ñ 	
ô 	
ð 	
ð ˆr�$”(˜C $¤(™NÑ+Ô+Ð+r   c                óB   — |                       |t          j        ¦  «        S r   )r`   ÚoperatorÚeqrC   s     r   Ú__eq__zModularInteger.__eq__³   ó   € Ø�}Š}˜U¥H¤KÑ0Ô0Ð0r   c                óB   — |                       |t          j        ¦  «        S r   )r`   rf   ÚnerC   s     r   Ú__ne__zModularInteger.__ne__¶   ri   r   c                óB   — |                       |t          j        ¦  «        S r   )rd   rf   ÚltrC   s     r   Ú__lt__zModularInteger.__lt__¹   ó   € Ø×'Ò'¨­x¬{Ñ;Ô;Ð;r   c                óB   — |                       |t          j        ¦  «        S r   )rd   rf   ÚlerC   s     r   Ú__le__zModularInteger.__le__¼   rp   r   c                óB   — |                       |t          j        ¦  «        S r   )rd   rf   ÚgtrC   s     r   Ú__gt__zModularInteger.__gt__¿   rp   r   c                óB   — |                       |t          j        ¦  «        S r   )rd   rf   ÚgerC   s     r   Ú__ge__zModularInteger.__ge__Â   rp   r   c                ó*   — t          | j        ¦  «        S r   )Úboolr   r   s    r   Ú__bool__zModularInteger.__bool__Å   s   € Ý�D”H‰~Œ~Ðr   c                óB   — | j                              || j        ¦  «        S r   )r   rR   r   )r8   Úvalues     r   rO   zModularInteger._invertÈ   s   € àŒw�~Š~˜e S¤WÑ-Ô-Ð-r   c                ó\   — |                       |                      | j        ¦  «        ¦  «        S r   )r   rO   r   r   s    r   rR   zModularInteger.invertÌ   s"   € Ø�~Š~˜dŸlšl¨4¬8Ñ4Ô4Ñ5Ô5Ð5r   N)+r$   Ú
__module__Ú__qualname__Ú__doc__r   r   r0   r   Ú	__slots__r   r   r   r    r%   r'   r*   r1   r4   r6   Úclassmethodr:   r?   rD   rG   rI   rK   rM   rP   rS   rU   rW   r\   r`   rd   rh   rl   ro   rs   rv   ry   r|   rO   rR   r3   r   r   r   r      s4  € € € € € à2Ð2à3Ñ€Cˆˆc�7à€Iðð ð ð8ð 8ð 8ðð ð ð*ð *ð *ð>ð >ð >ð2ð 2ð 2ðð ð ðð ð ð&ð ð ð)ð )ð )ð ðð ñ „[ðð"ð "ð "ð#ð #ð #ð"ð "ð "ð&ð &ð &ð"ð "ð "ð#ð #ð #ð"ð "ð "ð,ð ,ð ,ð"ð "ð "ð"ð "ð "ð	<ð 	<ð 	<ð,ð ,ð ,ð,ð ,ð ,ð$1ð 1ð 1ð1ð 1ð 1ð<ð <ð <ð<ð <ð <ð<ð <ð <ð<ð <ð <ðð ð ð ð.ð .ñ „[ð.ð6ð 6ð 6ð 6ð 6r   r   z0dict[tuple[Any, Any, Any], type[ModularInteger]]Ú_modular_integer_cachec                óR  ‡ ‡‡‡— 	 ‰                      ‰ ¦  «        Š d}n# t          $ r d}Y nw xY w|r‰ dk     rt          d‰ z  ¦  «        ‚‰ ‰‰f}	 t          |         }nI# t          $ r<  G ˆˆ ˆˆfd„dt
          ¦  «        }‰rd‰ z  |_        n
d‰ z  |_        |t          |<   Y nw xY w|S )	z1Create custom class for specific integer modulus.TFé   z*modulus must be a positive integer, got %sc                  ó"   •— e Zd Z”” ”cZZZ”ZdS )ú"ModularIntegerFactory.<locals>.clsN)r$   r€   r�   r   r   r0   r   )Ú_domÚ_modÚ_symr   s   €€€€r   r8   r‰   â   s#   ø€ € € € € Ø  $¨ˆMˆC��cØˆGˆGˆGr   r8   zSymmetricModularIntegerMod%szModularIntegerMod%s)r   r   Ú
ValueErrorr…   ÚKeyErrorr   r$   )r‹   rŠ   rŒ   r   ÚokÚkeyr8   s   ````   r   ÚModularIntegerFactoryr‘   Ñ   s)  øøøø€ ðØ�|Š|˜DÑ!Ô!ˆð ˆˆøõ ð ð ð Øˆˆˆðøøøð
 ð N�˜’�ÝÐEÈÑLÑMÔMÐMà
��dÐ
€Cð*Ý$ SÔ)ˆˆøÝð 
*ð 
*ð 
*ð	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	•.ñ 	ô 	ð 	ð ð 	8Ø9¸DÑ@ˆCŒLˆLà0°4Ñ7ˆCŒLà&)Õ˜sÑ#Ð#Ð#ð
*øøøð €Js   † ž-¬-ÁA ÁAB$Â#B$)r‚   Ú
__future__r   Útypingr   rf   Úsympy.polys.polyutilsr   Úsympy.polys.polyerrorsr   Ú!sympy.polys.domains.domainelementr   Úsympy.utilitiesr   Úsympy.utilities.exceptionsr	   r   r…   Ú__annotations__r‘   r3   r   r   ú<module>rš      s  ðØ 7Ð 7Ð 7à "Ð "Ð "Ð "Ð "Ð "Ø Ð Ð Ð Ð Ð à €€€à 4Ð 4Ð 4Ð 4Ð 4Ð 4Ø 1Ð 1Ð 1Ð 1Ð 1Ð 1Ø ;Ð ;Ð ;Ð ;Ð ;Ð ;à "Ð "Ð "Ð "Ð "Ð "Ø @Ð @Ð @Ð @Ð @Ð @àð}6ð }6ð }6ð }6ð }6Ð'¨ñ }6ô }6ñ „ð}6ð~ LNÐ Ð MÐ MÐ MÑ Mðð ð ð ð r   