o
    +< iÌ	  ã                   @   sˆ   d dl mZmZmZ d dlmZ d dlmZ d dlm	Z	 d dl
mZmZ ddœdd	„ZG d
d„ deƒZddœdd„ZG dd„ deƒZdS )é    )ÚAddÚArgumentIndexErrorÚFunction)ÚPow)ÚS)Úlog)ÚcosÚsinT©Úevaluatec                C   s   t t| |dtj |dS ©Nr
   )r   r   r   ÚOne)Úxr   © r   úT/home/app/PyTorch/.pytorch/lib/python3.10/site-packages/sympy/codegen/scipy_nodes.pyÚ_cosm1   s   r   c                   @   s6   e Zd ZdZdZddd„Zdd„ Zdd„ Zd	d
„ ZdS )Úcosm1zâ Minus one plus cosine of x, i.e. cos(x) - 1. For use when x is close to zero.

    Helper class for use with e.g. scipy.special.cosm1
    See: https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.cosm1.html
    é   c                 C   s   |dkr
t | jŽ  S t| |ƒ‚)ú@
        Returns the first derivative of this function.
        r   )r	   Úargsr   ©ÚselfZargindexr   r   r   Úfdiff   s   
zcosm1.fdiffc                 K   s   t |ƒS ©N)r   )r   r   Úkwargsr   r   r   Ú_eval_rewrite_as_cos   s   zcosm1._eval_rewrite_as_cosc                 O   ó   |   t¡j|i |¤ŽS r   )Úrewriter   Úevalf©r   r   r   r   r   r   Ú_eval_evalf    ó   zcosm1._eval_evalfc                 K   s8   | j \}t|jdi |¤Žƒ}|t|ddkr|S t|ƒS ©NFr
   r   )r   r   Úsimplifyr   )r   r   r   Ú	candidater   r   r   Ú_eval_simplify#   s
   zcosm1._eval_simplifyN©r   )	Ú__name__Ú
__module__Ú__qualname__Ú__doc__Únargsr   r   r    r%   r   r   r   r   r      s    
	r   c                C   s   t t| ||dtj |dS r   )r   r   r   r   )r   Úyr   r   r   r   Ú_powm1,   s   r-   c                   @   s6   e Zd ZdZdZddd„Zdd„ Zdd	„ Zd
d„ ZdS )Úpowm1zý Minus one plus x to the power of y, i.e. x**y - 1. For use when x is close to one or y is close to zero.

    Helper class for use with e.g. scipy.special.powm1
    See: https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.powm1.html
    é   r   c                 C   s\   |dkrt | jd | jd ƒ| jd  | jd  S |dkr)t| jd ƒt | jŽ  S t| |ƒ‚)r   r   r   r/   )r   r   r   r   r   r   r   r   r   8   s
   *
zpowm1.fdiffc                 K   s
   t ||ƒS r   )r-   )r   r   r,   r   r   r   r   Ú_eval_rewrite_as_PowC   s   
zpowm1._eval_rewrite_as_Powc                 O   r   r   )r   r   r   r   r   r   r   r    F   r!   zpowm1._eval_evalfc                 K   sL   | j \}}t|jdi |¤Ž|jdi |¤Žƒ}|t||ddkr!|S t||ƒS r"   )r   r-   r#   r.   )r   r   r   r,   r$   r   r   r   r%   I   s
   
"
zpowm1._eval_simplifyNr&   )	r'   r(   r)   r*   r+   r   r0   r    r%   r   r   r   r   r.   0   s    
r.   N)Zsympy.core.functionr   r   r   Zsympy.core.powerr   Zsympy.core.singletonr   Z&sympy.functions.elementary.exponentialr   Z(sympy.functions.elementary.trigonometricr   r	   r   r   r-   r.   r   r   r   r   Ú<module>   s     