o
    *ήcK                     @   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ejd
 ZeeZddddZddddZddddZG dd deZG dd deZdS )    )AddArgumentIndexErrorFunction)Pow)S)default_sort_key)explogTevaluatec                C   "   t tt| |dt||d|dS Nr
   )r	   r   r   x1x2r    r   @/tmp/pip-target-vg8gfxp4/lib/python/sympy/codegen/numpy_nodes.py
_logaddexp   s   "r      c                C   s   t | |dt S r   )r	   _ln2xr   r   r   r   _lb   s   r   c                C   s   t t| |dS r   )r   _twor   r   r   r   _exp2   s   r   c                C   r   r   )r   r   r   r   r   r   r   _logaddexp2   s   r   c                   @   >   e Zd ZdZdZdd ZdddZdd	 Zd
d Zdd Z	dS )	logaddexpz Logarithm of the sum of exponentiations of the inputs.

    Helper class for use with e.g. numpy.logaddexp

    See Also
    ========

    https://numpy.org/doc/stable/reference/generated/numpy.logaddexp.html
    r   c                 G      t j| gt|tdR  S N)keyr   __new__sortedr   clsargsr   r   r   r"   )      zlogaddexp.__new__   c                 C   J   |dkr
| j \}}n|dkr| j \}}nt| |tjtjt||   S z@
        Returns the first derivative of this function.
        r(   r   )r&   r   r   Oner   selfargindexwrtotherr   r   r   fdiff,      
zlogaddexp.fdiffc                 K   
   t ||S N)r   r-   r   r   kwargsr   r   r   _eval_rewrite_as_log8      
zlogaddexp._eval_rewrite_as_logc                 O      |  tj|i |S r4   rewriter	   evalfr-   r&   r6   r   r   r   _eval_evalf;      zlogaddexp._eval_evalfc                    B   t  fdd| j\}}t||}|t||ddkr|S t||S )Nc                    s   | j di  S Nr   )simplifyr   r6   r   r   <lambda>?   s    z*logaddexp._eval_simplify.<locals>.<lambda>Fr
   )mapr&   r   r   r-   r&   r6   ab	candidater   rD   r   _eval_simplify>   
   

zlogaddexp._eval_simplifyNr(   
__name__
__module____qualname____doc__nargsr"   r1   r7   r>   rK   r   r   r   r   r          	
r   c                   @   r   )
logaddexp2z Logarithm of the sum of exponentiations of the inputs in base-2.

    Helper class for use with e.g. numpy.logaddexp2

    See Also
    ========

    https://numpy.org/doc/stable/reference/generated/numpy.logaddexp2.html
    r   c                 G   r   r   r!   r$   r   r   r   r"   S   r'   zlogaddexp2.__new__r(   c                 C   r)   r*   )r&   r   r   r+   r   r,   r   r   r   r1   V   r2   zlogaddexp2.fdiffc                 K   r3   r4   )r   r5   r   r   r   r7   b   r8   zlogaddexp2._eval_rewrite_as_logc                 O   r9   r4   r:   r=   r   r   r   r>   e   r?   zlogaddexp2._eval_evalfc                    r@   )Nc                    s   | j di   S rA   )rB   factorrC   rD   r   r   rE   i   s    z+logaddexp2._eval_simplify.<locals>.<lambda>Fr
   )rF   r&   r   rU   rG   r   rD   r   rK   h   rL   zlogaddexp2._eval_simplifyNrM   rN   r   r   r   r   rU   G   rT   rU   N)sympy.core.functionr   r   r   sympy.core.powerr   sympy.core.singletonr   sympy.core.sortingr   &sympy.functions.elementary.exponentialr   r	   r   r+   r   r   r   r   r   r   rU   r   r   r   r   <module>   s    
*