o
    8VaH                     @   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	m
Z
 d dl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)explog)default_sort_keyTevaluatec                C   "   t tt| |dt||d|dS Nr
   )r   r   r   x1x2r    r   ;/usr/lib/python3/dist-packages/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   selfZargindexZ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 r2   Zrewriter   Zevalfr-   r&   r4   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   r4   r   r   <lambda>?   s    z*logaddexp._eval_simplify.<locals>.<lambda>Fr
   )mapr&   r   r   r-   r&   r4   ab	candidater   r@   r   _eval_simplify>   
   

zlogaddexp._eval_simplifyNr(   
__name__
__module____qualname____doc__nargsr"   r/   r5   r:   rG   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   r/   V   r0   zlogaddexp2.fdiffc                 K   r1   r2   )r   r3   r   r   r   r5   b   r6   zlogaddexp2._eval_rewrite_as_logc                 O   r7   r2   r8   r9   r   r   r   r:   e   r;   zlogaddexp2._eval_evalfc                    r<   )Nc                    s   | j di   S r=   )r>   Zfactorr?   r@   r   r   rA   i   s    z+logaddexp2._eval_simplify.<locals>.<lambda>Fr
   )rB   r&   r   rQ   rC   r   r@   r   rG   h   rH   zlogaddexp2._eval_simplifyNrI   rJ   r   r   r   r   rQ   G   rP   rQ   N)Zsympy.core.functionr   r   r   Zsympy.core.powerr   Zsympy.core.singletonr   Z&sympy.functions.elementary.exponentialr   r   Zsympy.utilitiesr	   r   r+   r   r   r   r   r   r   rQ   r   r   r   r   <module>   s    
*