+
    i                       a  0 t $ R t^ RIHt ^ RIHt ^ RIt^ RIHt ^ RI	H
t
 ^ RIHt ^ RIHt ^ RIHt ] ! R	 R
]]4      4       t/ tR]R&   R tR# )z1Implementation of :class:`ModularInteger` class. )annotations)AnyN)PicklableWithSlots)CoercionFailed)DomainElement)public)sympy_deprecation_warningc                     ] tR t^tRtR%w  ttttR$t	R t
R tR tR tR tR tR	 tR
 tR tR t]R 4       tR tR tR tR tR tR tR tR tR tR tR t R t!R t"R t#R t$R t%R t&R t'R  t(R! t)]R" 4       t*R# t+R$t,R# )&ModularIntegerz(A class representing a modular integer. Nc                	    V P                   # N)_parentselfs   &ڂ/Users/tonyclaw/.openclaw/workspace/skills/math-calculator/venv/lib/python3.14/site-packages/sympy/polys/domains/modularinteger.pyparentModularInteger.parent   s    ||    c                	    \        WP                  4      '       d%   VP                  V P                  ,          V n        R # V P                  P                  V4      V P                  ,          V n        R # r   )
isinstance	__class__valmoddomconvert)r   r   s   &&r   __init__ModularInteger.__init__   sD    c>>**ww)DHxx'',txx7DHr   c                	    V P                   # r   )r   r   s   &r   modulusModularInteger.modulus    s    xxr   c                	D    \        V P                  V P                  34      # r   )hashr   r   r   s   &r   __hash__ModularInteger.__hash__#   s    TXXtxx())r   c                	R    V P                   P                  : R V P                  : R2# )())r   __name__r   r   s   &r   __repr__ModularInteger.__repr__&   s    >>22DHH==r   c                	<    V P                   : R V P                  : 2# )z mod )r   r   r   s   &r   __str__ModularInteger.__str__)   s    "hh11r   c                	,    \        V P                  4      # r   )intr   r   s   &r   __int__ModularInteger.__int__,   s    488}r   c                	    \        R RRR7       V P                  '       dL   V P                  V P                  ^,          8:  d   V P                  # V P                  V P                  ,
          # V P                  # )z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/   s[    ! &,'>	
 888xx488q=(xxxx$((**88Or   c                	    V # r    r   s   &r   __pos__ModularInteger.__pos__B   s    r   c                	:    V P                  V P                  ) 4      # r   )r   r   r   s   &r   __neg__ModularInteger.__neg__E   s    ~~txxi((r   c                	    \        W4      '       d   VP                  #  V P                  P                  V4      #   \         d     R # i ; ir   )r   r   r   r   r   )clsothers   &&r   _get_valModularInteger._get_valH   sA    e!!99wwu--! s   : A	A	c                	|    V P                  V4      pVe#   V P                  V P                  V,           4      # \        # r   rB   r   r   NotImplementedr   rA   r   s   && r   __add__ModularInteger.__add__R   2    mmE"?>>$((S.11!!r   c                	$    V P                  V4      # r   rH   r   rA   s   &&r   __radd__ModularInteger.__radd__Z       ||E""r   c                	|    V P                  V4      pVe#   V P                  V P                  V,
          4      # \        # r   rE   rG   s   && r   __sub__ModularInteger.__sub__]   rJ   r   c                	&    V ) P                  V4      # r   rL   rM   s   &&r   __rsub__ModularInteger.__rsub__e   s    u%%r   c                	|    V P                  V4      pVe#   V P                  V P                  V,          4      # \        # r   rE   rG   s   && r   __mul__ModularInteger.__mul__h   rJ   r   c                	$    V P                  V4      # r   )rX   rM   s   &&r   __rmul__ModularInteger.__rmul__p   rP   r   c                	    V P                  V4      pVe2   V P                  V P                  V P                  V4      ,          4      # \        # r   )rB   r   r   _invertrF   rG   s   && r   __truediv__ModularInteger.__truediv__s   s<    mmE"?>>$((T\\#->">??!!r   c                	@    V P                  4       P                  V4      # r   )invertrX   rM   s   &&r   __rtruediv__ModularInteger.__rtruediv__{   s    {{}$$U++r   c                	|    V P                  V4      pVe#   V P                  V P                  V,          4      # \        # r   rE   rG   s   && r   __mod__ModularInteger.__mod__~   rJ   r   c                	z    V P                  V4      pVe"   V P                  W P                  ,          4      # \        # r   rE   rG   s   && r   __rmod__ModularInteger.__rmod__   s0    mmE"?>>#.11!!r   c                	   V'       g&   V P                  V P                  P                  4      # V^ 8  d   V P                  4       P                  V) rMV P                  pV P                  \        V\        V4      V P                  4      4      # )    )r   r   onerb   r   powr.   r   )r   expr   s   && r   __pow__ModularInteger.__pow__   sa    >>$((,,//7{{}((3$((C~~c#s3x:;;r   c                	~    V P                  V4      pVf   \        # V! V P                  W0P                  ,          4      # r   )rB   rF   r   r   r   rA   opr   s   &&& r   _compareModularInteger._compare   s2    mmE";!!$((C((N++r   c                	    V P                  V4      pVf   \        # \        RRR^R7       V! V P                  W0P                  ,          4      # )Nz~Ordered comparisons with modular integers are deprecated.

            Use e.g. int(a) < int(b) instead of a < b.
            r2   zmodularinteger-compare)r3   r4   
stacklevel)rB   rF   r   r   r   rs   s   &&& r   _compare_deprecated"ModularInteger._compare_deprecated   sL    mmE";!!! &,'?	
 $((C((N++r   c                	B    V P                  V\        P                  4      # r   )ru   operatoreqrM   s   &&r   __eq__ModularInteger.__eq__       }}UHKK00r   c                	B    V P                  V\        P                  4      # r   )ru   r|   nerM   s   &&r   __ne__ModularInteger.__ne__   r   r   c                	B    V P                  V\        P                  4      # r   )ry   r|   ltrM   s   &&r   __lt__ModularInteger.__lt__       ''x{{;;r   c                	B    V P                  V\        P                  4      # r   )ry   r|   lerM   s   &&r   __le__ModularInteger.__le__   r   r   c                	B    V P                  V\        P                  4      # r   )ry   r|   gtrM   s   &&r   __gt__ModularInteger.__gt__   r   r   c                	B    V P                  V\        P                  4      # r   )ry   r|   gerM   s   &&r   __ge__ModularInteger.__ge__   r   r   c                	,    \        V P                  4      # r   )boolr   r   s   &r   __bool__ModularInteger.__bool__   s    DHH~r   c                	L    V P                   P                  WP                  4      # r   )r   rb   r   )r@   values   &&r   r^   ModularInteger._invert   s    ww~~eWW--r   c                	V    V P                  V P                  V P                  4      4      # r   )r   r^   r   r   s   &r   rb   ModularInteger.invert   s    ~~dll488455r   )r   )NNNN)-r'   
__module____qualname____firstlineno____doc__r   r   r5   r   	__slots__r   r   r   r"   r(   r+   r/   r6   r:   r=   classmethodrB   rH   rN   rR   rU   rX   r[   r_   rc   rf   ri   rp   ru   ry   r~   r   r   r   r   r   r   r^   rb   __static_attributes__r9   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                n  a aaa  SP                  S 4      o RpV'       d   S ^8  d   \        RS ,          4      hS SS3p \        V,          pV#   \         d    Rp LEi ; i  \         dH     ! TT TT3R lR\
        4      pS'       d   RS ,          Tn        MRS ,          Tn        T\        T&    T# i ; i)z1Create custom class for specific integer modulus.TFz*modulus must be a positive integer, got %sc                  2   < ] tR t^t Z Z  Zuttt ZtRtR# )"ModularIntegerFactory.<locals>.clsr9   N)	r'   r   r   r   r   r   r5   r   r   )_dom_mod_symr   s   r   r@   r      s     $MCcGr   r@   zSymmetricModularIntegerMod%szModularIntegerMod%s)r   r   
ValueErrorr   KeyErrorr
   r'   )r   r   r   r   okkeyr@   s   ffff   r   ModularIntegerFactoryr      s    ||D! ELMM
d
C*$S) J1    
*	 	. 	 9D@CL047CL&)s#J
*s)   A  A" AA"'B4
&B43B4)__conditional_annotations__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   s   @r   <module>r      sV    7 "   4 1 ; " @}6' }6 }6~ LN H Mr   