o
    wZh,                     @   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   I/var/www/auris/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'   Zis_extended_nonnegative__truediv__r)   r   r   r   r5   d   s   zIntInfinity.__truediv__c                 C      t jS r   r   r	   r   r   r   r   __abs__t      zIntInfinity.__abs__c                 C   r6   r   r   r&   r8   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_negativeZZeror'   ComplexInfinityis_extended_real	is_numberZ$sympy.functions.elementary.complexesr=   Zis_positiveZis_negativer0   Zevalf)r   exptr=   Z	expt_realr   r   r   _eval_powerz   s&   

zIntInfinity._eval_powerc                 C   r6   r   )mlibZfinfr   precr   r   r   _as_mpf_val   r:   zIntInfinity._as_mpf_valc                    
   t   S r   super__hash__r8   	__class__r   r   rK      r   zIntInfinity.__hash__c                 C   
   |t ju S r   r7   r)   r   r   r   __eq__   r   zIntInfinity.__eq__c                 C   
   |t juS r   r7   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   rS   r)   r   r   r   __ge__   rX   zIntInfinity.__ge__c                 C   rY   r   r   r$   rT   rV   r	   rU   r)   r   r   r   __lt__   rX   zIntInfinity.__lt__c                 C   rR   r   r[   r)   r   r   r   __le__   rX   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   r8   r   r   r   floor   r   zIntInfinity.floorc                 C   rc   r   r   r8   r   r   r   ceiling   r   zIntInfinity.ceiling))__name__
__module____qualname____doc__
is_integeris_commutativerA   r@   is_comparabler1   is_prime_op_priority	__slots__r   r   r   r   r`   r(   __radd__r*   r-   r2   __rmul__r5   r9   r<   rC   rG   rK   rO   rQ   rW   rZ   r\   r]   ra   __rmod__rd   re   __classcell__r   r   rL   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*     ru   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   r5     s   zNegativeIntInfinity.__truediv__c                 C   r6   r   r7   r8   r   r   r   r9   /  r:   zNegativeIntInfinity.__abs__c                 C   r6   r   r7   r8   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   )rA   r   r'   r$   r%   r	   r&   r"   rT   Integerr1   Zis_oddNegativeOne	is_finiter?   r0   )r   rB   Zinf_partZs_partr   r   r   rC   5  s2   


zNegativeIntInfinity._eval_powerc                 C   r6   r   )rD   ZfninfrE   r   r   r   rG   R  r:   zNegativeIntInfinity._as_mpf_valc                    rH   r   rI   r8   rL   r   r   rK   U  r   zNegativeIntInfinity.__hash__c                 C   rN   r   r;   r)   r   r   r   rO   X  r   zNegativeIntInfinity.__eq__c                 C   rP   r   r;   r)   r   r   r   rQ   [  r   zNegativeIntInfinity.__ne__c                 C   rY   r   r   r%   rT   rV   r&   rU   r)   r   r   r   rW   ^  rX   zNegativeIntInfinity.__gt__c                 C   rR   r   ry   r)   r   r   r   rZ   f  rX   zNegativeIntInfinity.__ge__c                 C   rR   r   r   r%   rT   rU   r&   rV   r)   r   r   r   r\   n  rX   zNegativeIntInfinity.__lt__c                 C   rY   r   rz   r)   r   r   r   r]   v  rX   zNegativeIntInfinity.__le__c                 C   r^   r   r_   r)   r   r   r   ra   ~  rb   zNegativeIntInfinity.__mod__c                 C   rc   r   r   r8   r   r   r   rd     r   zNegativeIntInfinity.floorc                 C   rc   r   r   r8   r   r   r   re     r   zNegativeIntInfinity.ceilingc                 C   s   t jdt jdiS )N   )r   rw   r	   r8   r   r   r   as_powers_dict  s   z"NegativeIntInfinity.as_powers_dict)*rf   rg   rh   ri   rn   rj   r@   rk   rl   r>   rA   rm   ro   r   r   r   r   r`   r(   rp   r*   r-   r2   rq   r5   r9   r<   rC   rG   rK   rO   rQ   rW   rZ   r\   r]   ra   rr   rd   re   r|   rs   r   r   rL   r   r&      sX    
	
	

	

r&   )Zmpmath.libmpZlibmprD   rT   r   Zsympy.core.decoratorsr   Zsympy.core.exprr   Zsympy.core.numbersr   Zsympy.core.parametersr   Zsympy.core.singletonr   r   r	   r   r&   r   r   r   r   <module>   s    @