
    sg,                         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 d dlmZmZ  G d d	e
e
      Zej                   Z G d de
e
      Zy)    N)Expr)
_sympifyit)
AtomicExpr)Number)global_parameters)S	Singletonc                   b    e 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	e      d
        ZeZ ed	e      d        Z ed	e      d        Z ed	e      d        ZeZ ed	e      d        Zd Zd Zd Zd Z fdZd Zd Zd Z d Z!d Z"d Z# ed	e      d        Z$e$Z%d Z&d Z' xZ(S )IntInfinityah  Positive integer infinite quantity.

    Integer infinity is a value in an extended integers which
    is greater than all other integers.  We distinguish it from
    sympy's existing notion of infinity in that it reports that
    it is_integer.

    Infinity is a singleton, and can be accessed by ``S.IntInfinity``,
    or can be imported as ``int_oo``.
    TF      Y@ c                 ,    t        j                  |       S Nr   __new__clss    M/var/www/html/venv/lib/python3.12/site-packages/torch/utils/_sympy/numbers.pyr   zIntInfinity.__new__)       !!#&&    c                      y)Nint_oor   selfprinters     r   	_sympystrzIntInfinity._sympystr,   s    r   c                     | |k(  r|S y r   r   r   oldnews      r   
_eval_subszIntInfinity._eval_subs/       3;J r   otherc                    t        |t              rht        j                  rX|t        j
                  t        j                  fv r|S |t        j                  t        j                  fv rt        j                  S | S t        j                  | |      S r   )

isinstancer   r   evaluater   InfinityNegativeInfinityNegativeIntInfinityNaN__add__r   r#   s     r   r+   zIntInfinity.__add__<   sg    eV$):)C)CQ%7%788..66uuK~~dE**r   c                 ^   t        |t              rt        j                  rx|t        j
                  u rt        j                  S |t        j                  u rt        j
                  S |t        j                  t        j                  fv rt        j                  S | S t        j                  | |      S r   )
r%   r   r   r&   r   r'   r(   r   r*   __sub__r,   s     r   r.   zIntInfinity.__sub__H   sy    eV$):)C)C

")))***zz!..uuK~~dE**r   c                 &    |  j                  |      S r   r+   r,   s     r   __rsub__zIntInfinity.__rsub__T       u%%r   c                    t        |t              r\t        j                  rL|j                  s|t
        j                  u rt
        j                  S |j                  r| S t
        j                  S t        j                  | |      S r   )
r%   r   r   r&   is_zeror   r*   is_extended_positiver)   __mul__r,   s     r   r6   zIntInfinity.__mul__X   sZ    eV$):)C)C}}uu))(((~~dE**r   c                    t        |t              rt        j                  r|t        j
                  t        j                  t        j                  t        j                  t        j                  fv rt        j                  S |j                  rt        j
                  S t        j                  S t        j                  | |      S r   r%   r   r   r&   r   r'   r   r(   r)   r*   is_extended_nonnegative__truediv__r,   s     r   r:   zIntInfinity.__truediv__d   s    eV$):)C)C

""%%  uu,,zz!%%%!!$..r   c                 "    t         j                  S r   r   r   r   s    r   __abs__zIntInfinity.__abs__t       }}r   c                 "    t         j                  S r   r   r)   r=   s    r   __neg__zIntInfinity.__neg__w   s    $$$r   c                    |j                   rt        j                  S |j                  rt        j                  S |t        j
                  u rt        j
                  S |t        j                  u rt        j
                  S |j                  du r|j                  ruddl	m
}  ||      }|j                  rt        j                  S |j                  rt        j                  S |j                  rt        j
                  S | |j                         z  S y y )NFr   )re)r5   r   r   is_extended_negativeZeror*   ComplexInfinityis_extended_real	is_number$sympy.functions.elementary.complexesrD   is_positiveis_negativer4   evalf)r   exptrD   	expt_reals       r   _eval_powerzIntInfinity._eval_powerz   s    $$== $$66M155=55L1$$$55L  E)dnn?4I$$((($$vv  uu4::<'' /=)r   c                 "    t         j                  S r   )mlibfinfr   precs     r   _as_mpf_valzIntInfinity._as_mpf_val   s    yyr   c                      t         |          S r   super__hash__r   	__class__s    r   rZ   zIntInfinity.__hash__       w!!r   c                 &    |t         j                  u S r   r<   r,   s     r   __eq__zIntInfinity.__eq__   s    %%r   c                 &    |t         j                  uS r   r<   r,   s     r   __ne__zIntInfinity.__ne__   s    AMM))r   c                     |t         j                  u rt        j                  S |t         j                  u rt        j                  S t        j
                  S r   r   r'   sympyfalser   truer,   s     r   __gt__zIntInfinity.__gt__   s8    AJJ;;amm#;;::r   c                     |t         j                  u rt        j                  S |t         j                  u rt        j
                  S t        j
                  S r   rc   r,   s     r   __ge__zIntInfinity.__ge__   s8    AJJ;;amm#::::r   c                     |t         j                  u rt        j                  S |t         j                  u rt        j
                  S t        j
                  S r   r   r'   rd   rf   r   re   r,   s     r   __lt__zIntInfinity.__lt__   s8    AJJ::amm#;;;;r   c                     |t         j                  u rt        j                  S |t         j                  u rt        j                  S t        j
                  S r   rk   r,   s     r   __le__zIntInfinity.__le__   s8    AJJ::amm#::;;r   c                 N    t        |t              st        S t        j                  S r   r%   r   NotImplementedr   r*   r,   s     r   __mod__zIntInfinity.__mod__       %&!!uur   c                     | S r   r   r=   s    r   floorzIntInfinity.floor       r   c                     | S r   r   r=   s    r   ceilingzIntInfinity.ceiling   rv   r   ))__name__
__module____qualname____doc__
is_integeris_commutativerI   rH   is_comparabler5   is_prime_op_priority	__slots__r   r   r!   r   rq   r+   __radd__r.   r1   r6   __rmul__r:   r>   rB   rP   rV   rZ   r_   ra   rg   ri   rl   rn   rr   __rmod__ru   rx   __classcell__r\   s   @r   r   r      sC   	 JNIMH LI'
 (+ )+ H(	+ )	+ (& )& (+ )+ H(/ )/%(,"&* ( )
 Hr   r   )	metaclassc                   h    e 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	e      d
        ZeZ ed	e      d        Z ed	e      d        Z ed	e      d        ZeZ ed	e      d        Zd Zd Zd Zd Z fdZd Zd Zd Z d Z!d Z"d Z# ed	e      d        Z$e$Z%d Z&d Z'd Z( xZ)S )r)   zNegative integer infinite quantity.

    NegativeInfinity is a singleton, and can be accessed
    by ``S.NegativeInfinity``.

    See Also
    ========

    IntInfinity
    r   TFr   c                 ,    t        j                  |       S r   r   r   s    r   r   zNegativeIntInfinity.__new__   r   r   c                     | |k(  r|S y r   r   r   s      r   r!   zNegativeIntInfinity._eval_subs   r"   r   c                      y)Nz-int_oor   r   s     r   r   zNegativeIntInfinity._sympystr   s    r   r#   c                    t        |t              rft        j                  rV|t        j
                  u rt        j
                  S |t        j                  t        j                  fv rt        j                  S | S t        j                  | |      S r   )	r%   r   r   r&   r   r'   r   r*   r+   r,   s     r   r+   zNegativeIntInfinity.__add__   s_    eV$):)C)C

"zz!..uuK~~dE**r   c                    t        |t              rft        j                  rV|t        j
                  u rt        j                  S |t        j                  t        j                  fv rt        j                  S | S t        j                  | |      S r   )
r%   r   r   r&   r   r(   r'   r)   r*   r.   r,   s     r   r.   zNegativeIntInfinity.__sub__  sc    eV$):)C)C***zz!..66uuK~~dE**r   c                 &    |  j                  |      S r   r0   r,   s     r   r1   zNegativeIntInfinity.__rsub__  r2   r   c                    t        |t              r\t        j                  rL|j                  s|t
        j                  u rt
        j                  S |j                  r| S t
        j                  S t        j                  | |      S r   )
r%   r   r   r&   r4   r   r*   r5   r   r6   r,   s     r   r6   zNegativeIntInfinity.__mul__  sX    eV$):)C)C}}uu))== ~~dE**r   c                 h   t        |t              rt        j                  r}|t        j
                  t        j                  t        j                  t        j                  t        j                  fv rt        j                  S |j                  r| S t        j
                  S t        j                  | |      S r   r8   r,   s     r   r:   zNegativeIntInfinity.__truediv__  s    eV$):)C)C

""%%  uu,,::!!$..r   c                 "    t         j                  S r   r<   r=   s    r   r>   zNegativeIntInfinity.__abs__/  r?   r   c                 "    t         j                  S r   r<   r=   s    r   rB   zNegativeIntInfinity.__neg__2  r?   r   c                 p   |j                   r)|t        j                  t        j                  t        j                  t        j
                  t        j                  fv rt        j                  S t        |t        j                        r8|j                  r,|j                  rt        j                  S t        j
                  S t        j
                  |z  }t        j                  |z  }|dk(  r|j                  r|S |t        j                  u r(|j                  r|j                  st        j                  S ||z  S y )Nr   )rI   r   r*   r'   r(   r   r)   r%   rd   Integerr5   is_oddNegativeOne	is_finiterG   r4   )r   rN   inf_parts_parts       r   rP   zNegativeIntInfinity._eval_power5  s    >>

""%%  uu$.43L3L;;000==(}}d*H]]D(F1}!1!1A---$$(((H$$5 r   c                 "    t         j                  S r   )rR   fninfrT   s     r   rV   zNegativeIntInfinity._as_mpf_valR  s    zzr   c                      t         |          S r   rX   r[   s    r   rZ   zNegativeIntInfinity.__hash__U  r]   r   c                 &    |t         j                  u S r   rA   r,   s     r   r_   zNegativeIntInfinity.__eq__X  s    ----r   c                 &    |t         j                  uS r   rA   r,   s     r   ra   zNegativeIntInfinity.__ne__[  s    A1111r   c                     |t         j                  u rt        j                  S |t         j                  u rt        j
                  S t        j
                  S r   r   r(   rd   rf   r)   re   r,   s     r   rg   zNegativeIntInfinity.__gt__^  s<    A&&&::a+++;;;;r   c                     |t         j                  u rt        j                  S |t         j                  u rt        j                  S t        j
                  S r   r   r,   s     r   ri   zNegativeIntInfinity.__ge__f  s<    A&&&::a+++::;;r   c                     |t         j                  u rt        j                  S |t         j                  u rt        j                  S t        j
                  S r   r   r(   rd   re   r)   rf   r,   s     r   rl   zNegativeIntInfinity.__lt__n  s<    A&&&;;a+++;;::r   c                     |t         j                  u rt        j                  S |t         j                  u rt        j
                  S t        j
                  S r   r   r,   s     r   rn   zNegativeIntInfinity.__le__v  s<    A&&&;;a+++::::r   c                 N    t        |t              st        S t        j                  S r   rp   r,   s     r   rr   zNegativeIntInfinity.__mod__~  rs   r   c                     | S r   r   r=   s    r   ru   zNegativeIntInfinity.floor  rv   r   c                     | S r   r   r=   s    r   rx   zNegativeIntInfinity.ceiling  rv   r   c                 F    t         j                  dt         j                  diS )N   )r   r   r   r=   s    r   as_powers_dictz"NegativeIntInfinity.as_powers_dict  s    q!--33r   )*ry   rz   r{   r|   r   r}   rH   r~   r   rE   rI   r   r   r   r!   r   r   rq   r+   r   r.   r1   r6   r   r:   r>   rB   rP   rV   rZ   r_   ra   rg   ri   rl   rn   rr   r   ru   rx   r   r   r   s   @r   r)   r)      sF   	 LJNMIHI' (+ )+ H(+ )+ (& )& (+ )+ H(/ )/%:".2 ( )
 H4r   r)   )mpmath.libmplibmprR   rd   r   sympy.core.decoratorsr   sympy.core.exprr   sympy.core.numbersr   sympy.core.parametersr   sympy.core.singletonr   r	   r   r   r)   r   r   r   <module>r      sI       , & % 3 -|&I |~ 
4&I 4r   