
    \h                        % S r SSKJr  SSKJr  SSKrSSKJr  SSKJ	r	  SSK
Jr  SSKJr  SS	KJr  \ " S
 S\\5      5       r0 rS\S'   S rg)z1Implementation of :class:`ModularInteger` class.     )annotations)AnyN)PicklableWithSlots)CoercionFailed)DomainElement)public)sympy_deprecation_warningc                     \ rS rSrSrSu  rrrrSr	S r
S rS rS rS	 rS
 rS rS rS rS 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$ 5       r*S% r+Sr,g&)'ModularInteger   z(A class representing a modular integer. )NNNN)valc                    U R                   $ N)_parentselfs    Z/var/www/auris/envauris/lib/python3.13/site-packages/sympy/polys/domains/modularinteger.pyparentModularInteger.parent   s    ||    c                    [        XR                  5      (       a  UR                  U R                  -  U l        g U R                  R                  U5      U R                  -  U l        g r   )
isinstance	__class__r   moddomconvert)r   r   s     r   __init__ModularInteger.__init__   sD    c>>**ww)DHxx'',txx7DHr   c                    U R                   $ r   )r   r   s    r   modulusModularInteger.modulus    s    xxr   c                D    [        U R                  U R                  45      $ r   )hashr   r   r   s    r   __hash__ModularInteger.__hash__#   s    TXXtxx())r   c                R    U R                   R                  < SU R                  < S3$ )N())r   __name__r   r   s    r   __repr__ModularInteger.__repr__&   s    >>22DHH==r   c                <    U R                   < SU R                  < 3$ )Nz mod )r   r   r   s    r   __str__ModularInteger.__str__)   s    "hh11r   c                ,    [        U R                  5      $ r   )intr   r   s    r   __int__ModularInteger.__int__,   s    488}r   c                    [        SSSS9  U R                  (       aB  U R                  U R                  S-  ::  a  U R                  $ U R                  U R                  -
  $ U R                  $ )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_intModularInteger.to_int/   sY    ! &,'>	
 88xx488q=(xxxx$((**88Or   c                    U $ r    r   s    r   __pos__ModularInteger.__pos__B   s    r   c                :    U R                  U R                  * 5      $ r   )r   r   r   s    r   __neg__ModularInteger.__neg__E   s    ~~txxi((r   c                    [        X5      (       a  UR                  $  U R                  R                  U5      $ ! [         a     g f = fr   )r   r   r   r   r   )clsothers     r   _get_valModularInteger._get_valH   sA    e!!99wwu--! s   9 
AAc                r    U R                  U5      nUb  U R                  U R                  U-   5      $ [        $ r   rE   r   r   NotImplementedr   rD   r   s      r   __add__ModularInteger.__add__R   2    mmE"?>>$((S.11!!r   c                $    U R                  U5      $ r   rK   r   rD   s     r   __radd__ModularInteger.__radd__Z       ||E""r   c                r    U R                  U5      nUb  U R                  U R                  U-
  5      $ [        $ r   rH   rJ   s      r   __sub__ModularInteger.__sub__]   rM   r   c                &    U * R                  U5      $ r   rO   rP   s     r   __rsub__ModularInteger.__rsub__e   s    u%%r   c                r    U R                  U5      nUb  U R                  U R                  U-  5      $ [        $ r   rH   rJ   s      r   __mul__ModularInteger.__mul__h   rM   r   c                $    U R                  U5      $ r   )r[   rP   s     r   __rmul__ModularInteger.__rmul__p   rS   r   c                    U R                  U5      nUb-  U R                  U R                  U R                  U5      -  5      $ [        $ r   )rE   r   r   _invertrI   rJ   s      r   __truediv__ModularInteger.__truediv__s   s<    mmE"?>>$((T\\#->">??!!r   c                @    U R                  5       R                  U5      $ r   )invertr[   rP   s     r   __rtruediv__ModularInteger.__rtruediv__{   s    {{}$$U++r   c                r    U R                  U5      nUb  U R                  U R                  U-  5      $ [        $ r   rH   rJ   s      r   __mod__ModularInteger.__mod__~   rM   r   c                p    U R                  U5      nUb  U R                  X R                  -  5      $ [        $ r   rH   rJ   s      r   __rmod__ModularInteger.__rmod__   s0    mmE"?>>#.11!!r   c                   U(       d%  U R                  U R                  R                  5      $ US:  a  U R                  5       R                  U* pOU R                  nU R                  [        U[        U5      U R                  5      5      $ )Nr   )r   r   onere   r   powr0   r   )r   expr   s      r   __pow__ModularInteger.__pow__   sa    >>$((,,//7{{}((3$((C~~c#s3x:;;r   c                t    U R                  U5      nUc  [        $ U" U R                  X0R                  -  5      $ r   )rE   rI   r   r   r   rD   opr   s       r   _compareModularInteger._compare   s2    mmE";!!$((C((N++r   c                    U R                  U5      nUc  [        $ [        SSSSS9  U" U R                  X0R                  -  5      $ )Nz~Ordered comparisons with modular integers are deprecated.

            Use e.g. int(a) < int(b) instead of a < b.
            r4   zmodularinteger-compare   )r5   r6   
stacklevel)rE   rI   r	   r   r   ru   s       r   _compare_deprecated"ModularInteger._compare_deprecated   sL    mmE";!!! &,'?	
 $((C((N++r   c                B    U R                  U[        R                  5      $ r   )rw   operatoreqrP   s     r   __eq__ModularInteger.__eq__       }}UHKK00r   c                B    U R                  U[        R                  5      $ r   )rw   r   nerP   s     r   __ne__ModularInteger.__ne__   r   r   c                B    U R                  U[        R                  5      $ r   )r|   r   ltrP   s     r   __lt__ModularInteger.__lt__       ''x{{;;r   c                B    U R                  U[        R                  5      $ r   )r|   r   lerP   s     r   __le__ModularInteger.__le__   r   r   c                B    U R                  U[        R                  5      $ r   )r|   r   gtrP   s     r   __gt__ModularInteger.__gt__   r   r   c                B    U R                  U[        R                  5      $ r   )r|   r   gerP   s     r   __ge__ModularInteger.__ge__   r   r   c                ,    [        U R                  5      $ r   )boolr   r   s    r   __bool__ModularInteger.__bool__   s    DHH~r   c                L    U R                   R                  XR                  5      $ r   )r   re   r   )rC   values     r   ra   ModularInteger._invert   s    ww~~eWW--r   c                V    U R                  U R                  U R                  5      5      $ r   )r   ra   r   r   s    r   re   ModularInteger.invert   s    ~~dll488455r   N)-r)   
__module____qualname____firstlineno____doc__r   r   r8   r   	__slots__r   r   r    r$   r*   r-   r1   r9   r=   r@   classmethodrE   rK   rQ   rU   rX   r[   r^   rb   rf   ri   rl   rr   rw   r|   r   r   r   r   r   r   r   ra   re   __static_attributes__r<   r   r   r   r      s    23Cc7I8*>2&)  "#"&"#",""	<,,$11<<<< . .6r   r   z0dict[tuple[Any, Any, Any], type[ModularInteger]]_modular_integer_cachec                D  ^ ^^^  TR                  T 5      m SnU(       a  T S:  a  [        ST -  5      eT TT4n [        U   nU$ ! [         a    Sn N:f = f! [         a>     " UU UU4S jS[
        5      nT(       a  ST -  Ul        O
ST -  Ul        U[        U'    U$ f = f)	z1Create custom class for specific integer modulus.TF   z*modulus must be a positive integer, got %sc                  0   > \ rS rSr Y Y  Ysrrr YrSrg)"ModularIntegerFactory.<locals>.cls   r<   N)	r)   r   r   r   r   r   r8   r   r   )_dom_mod_symr   s   r   rC   r      s     $MCcGr   rC   zSymmetricModularIntegerMod%szModularIntegerMod%s)r   r   
ValueErrorr   KeyErrorr   r)   )r   r   r   r   okkeyrC   s   ````   r   ModularIntegerFactoryr      s    ||D! ELMM
d
C*$S) J1    
*	 	. 	 9D@CL047CL&)s#J
*s#   A 	A AAABB)r   
__future__r   typingr   r   sympy.polys.polyutilsr   sympy.polys.polyerrorsr   !sympy.polys.domains.domainelementr   sympy.utilitiesr   sympy.utilities.exceptionsr	   r   r   __annotations__r   r<   r   r   <module>r      sU    7 "   4 1 ; " @}6' }6 }6~ LN H Mr   