o
    0h,                     @   s   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	 d	e
ed
ZejZG dd de
ed
ZdS )    N)Expr)
_sympifyit)
AtomicExpr)Number)global_parameters)S	Singletonc                       s6  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d Zdd	 Zd
d Z	 ededd ZeZededd Zededd Zededd ZeZededd Zdd Zdd Zdd Zdd Z fdd Zd!d" Zd#d$ Zd%d& Z d'd( Z!d)d* Z"d+d, Z#eded-d. Z$e$Z%d/d0 Z&d1d2 Z'  Z(S )3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                 C   
   t | S Nr   __new__clsr   r   N/var/www/vscode/kcb/lib/python3.10/site-packages/torch/utils/_sympy/numbers.pyr   )      
zIntInfinity.__new__c                 C      dS )Nint_oor   selfprinterr   r   r   	_sympystr,      zIntInfinity._sympystrc                 C      | |kr|S d S r   r   r   oldnewr   r   r   
_eval_subs/      zIntInfinity._eval_subsotherc                 C   sJ   t |trtjr|tjtjfv r|S |tjtjfv rtjS | S t	| |S r   )

isinstancer   r   evaluater   InfinityNegativeInfinityNegativeIntInfinityNaN__add__r   r!   r   r   r   r(   <   s   zIntInfinity.__add__c                 C   sV   t |tr%tjr%|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	| |S r   )
r"   r   r   r#   r   r$   r%   r	   r'   __sub__r)   r   r   r   r*   H   s   

zIntInfinity.__sub__c                 C      |   |S r   r(   r)   r   r   r   __rsub__T      zIntInfinity.__rsub__c                 C   B   t |trtjr|js|tju rtjS |jr| S tjS t	| |S r   )
r"   r   r   r#   is_zeror   r'   is_extended_positiver&   __mul__r)   r   r   r   r2   X      zIntInfinity.__mul__c                 C   sP   t |tr"t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| |S r   r"   r   r   r#   r   r$   r	   r%   r&   r'   is_extended_nonnegative__truediv__r)   r   r   r   r6   d   s   zIntInfinity.__truediv__c                 C      t jS r   r   r	   r   r   r   r   __abs__t      zIntInfinity.__abs__c                 C   r7   r   r   r&   r9   r   r   r   __neg__w   r;   zIntInfinity.__neg__c                 C   s   |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 rF|jrHddl	m
} ||}|jr4tjS |jr:tjS |jr@tjS | |  S d S d S )NFr   )re)r1   r   r	   is_extended_negativeZeror'   ComplexInfinityis_extended_real	is_number$sympy.functions.elementary.complexesr>   is_positiveis_negativer0   evalf)r   exptr>   	expt_realr   r   r   _eval_powerz   s&   

zIntInfinity._eval_powerc                 C   r7   r   )mlibfinfr   precr   r   r   _as_mpf_val   r;   zIntInfinity._as_mpf_valc                    
   t   S r   super__hash__r9   	__class__r   r   rS      r   zIntInfinity.__hash__c                 C   
   |t ju S r   r8   r)   r   r   r   __eq__   r   zIntInfinity.__eq__c                 C   
   |t juS r   r8   r)   r   r   r   __ne__   r   zIntInfinity.__ne__c                 C   &   |t ju rtjS |t ju rtjS tjS r   r   r$   sympyfalser	   truer)   r   r   r   __gt__   
   

zIntInfinity.__gt__c                 C   &   |t ju rtjS |t ju rtjS tjS r   r[   r)   r   r   r   __ge__   r`   zIntInfinity.__ge__c                 C   ra   r   r   r$   r\   r^   r	   r]   r)   r   r   r   __lt__   r`   zIntInfinity.__lt__c                 C   rZ   r   rc   r)   r   r   r   __le__   r`   zIntInfinity.__le__c                 C      t |tstS tjS r   r"   r   NotImplementedr   r'   r)   r   r   r   __mod__      
zIntInfinity.__mod__c                 C      | S r   r   r9   r   r   r   floor   r   zIntInfinity.floorc                 C   rk   r   r   r9   r   r   r   ceiling   r   zIntInfinity.ceiling))__name__
__module____qualname____doc__
is_integeris_commutativerC   rB   is_comparabler1   is_prime_op_priority	__slots__r   r   r   r   rh   r(   __radd__r*   r-   r2   __rmul__r6   r:   r=   rJ   rO   rS   rW   rY   r_   rb   rd   re   ri   __rmod__rl   rm   __classcell__r   r   rT   r   r	      sV    
	


	

r	   )	metaclassc                       s>  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d Zdd	 Zd
d Z	 ededd ZeZededd Zededd Zededd ZeZededd Zdd Zdd Zdd Zdd Z fdd Zd!d" Zd#d$ Zd%d& Z d'd( Z!d)d* Z"d+d, Z#eded-d. Z$e$Z%d/d0 Z&d1d2 Z'd3d4 Z(  Z)S )5r&   zNegative integer infinite quantity.

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

    See Also
    ========

    IntInfinity
    r
   TFr   c                 C   r   r   r   r   r   r   r   r      r   zNegativeIntInfinity.__new__c                 C   r   r   r   r   r   r   r   r      r    zNegativeIntInfinity._eval_subsc                 C   r   )Nz-int_oor   r   r   r   r   r      r   zNegativeIntInfinity._sympystrr!   c                 C   sF   t |trtjr|tju rtjS |tjtjfv rtjS | S t| |S r   )	r"   r   r   r#   r   r$   r	   r'   r(   r)   r   r   r   r(         
zNegativeIntInfinity.__add__c                 C   sF   t |trtjr|tju rtjS |tjtjfv rtjS | S t	| |S r   )
r"   r   r   r#   r   r%   r$   r&   r'   r*   r)   r   r   r   r*     r}   zNegativeIntInfinity.__sub__c                 C   r+   r   r,   r)   r   r   r   r-     r.   zNegativeIntInfinity.__rsub__c                 C   r/   r   )
r"   r   r   r#   r0   r   r'   r1   r	   r2   r)   r   r   r   r2     r3   zNegativeIntInfinity.__mul__c                 C   sN   t |tr!t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| |S r   r4   r)   r   r   r   r6     s   zNegativeIntInfinity.__truediv__c                 C   r7   r   r8   r9   r   r   r   r:   /  r;   zNegativeIntInfinity.__abs__c                 C   r7   r   r8   r9   r   r   r   r=   2  r;   zNegativeIntInfinity.__neg__c                 C   s   |j rK|tjtjtjtjtjfv rtjS t|tj	r&|j
r&|jr#tjS tjS tj| }tj| }|dkr9|jr9|S |tju rG|jrG|jsGtjS || S d S )Nr   )rC   r   r'   r$   r%   r	   r&   r"   r\   Integerr1   is_oddNegativeOne	is_finiterA   r0   )r   rH   inf_parts_partr   r   r   rJ   5  s2   


zNegativeIntInfinity._eval_powerc                 C   r7   r   )rK   fninfrM   r   r   r   rO   R  r;   zNegativeIntInfinity._as_mpf_valc                    rP   r   rQ   r9   rT   r   r   rS   U  r   zNegativeIntInfinity.__hash__c                 C   rV   r   r<   r)   r   r   r   rW   X  r   zNegativeIntInfinity.__eq__c                 C   rX   r   r<   r)   r   r   r   rY   [  r   zNegativeIntInfinity.__ne__c                 C   ra   r   r   r%   r\   r^   r&   r]   r)   r   r   r   r_   ^  r`   zNegativeIntInfinity.__gt__c                 C   rZ   r   r   r)   r   r   r   rb   f  r`   zNegativeIntInfinity.__ge__c                 C   rZ   r   r   r%   r\   r]   r&   r^   r)   r   r   r   rd   n  r`   zNegativeIntInfinity.__lt__c                 C   ra   r   r   r)   r   r   r   re   v  r`   zNegativeIntInfinity.__le__c                 C   rf   r   rg   r)   r   r   r   ri   ~  rj   zNegativeIntInfinity.__mod__c                 C   rk   r   r   r9   r   r   r   rl     r   zNegativeIntInfinity.floorc                 C   rk   r   r   r9   r   r   r   rm     r   zNegativeIntInfinity.ceilingc                 C   s   t jdt jdiS )N   )r   r   r	   r9   r   r   r   as_powers_dict  s   z"NegativeIntInfinity.as_powers_dict)*rn   ro   rp   rq   rv   rr   rB   rs   rt   r?   rC   ru   rw   r   r   r   r   rh   r(   rx   r*   r-   r2   ry   r6   r:   r=   rJ   rO   rS   rW   rY   r_   rb   rd   re   ri   rz   rl   rm   r   r{   r   r   rT   r   r&      sX    
	
	

	

r&   )mpmath.libmplibmprK   r\   r   sympy.core.decoratorsr   sympy.core.exprr   sympy.core.numbersr   sympy.core.parametersr   sympy.core.singletonr   r   r	   r   r&   r   r   r   r   <module>   s    @