a
    <bK                     @   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   s"   t tt| |dt||d|dS Nr
   )r	   r   r   x1x2r    r   i/Users/vegardjervell/Documents/master/model/venv/lib/python3.9/site-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   s"   t tt| |dt||d|dS r   )r   r   r   r   r   r   r   _logaddexp2   s    r   c                   @   s>   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   s   t j| gt|tdR  S N)keyr   __new__sortedr   clsargsr   r   r   r   )   s    zlogaddexp.__new__   c                 C   sJ   |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,   s    
zlogaddexp.fdiffc                 K   s
   t ||S N)r   r(   r   r   kwargsr   r   r   _eval_rewrite_as_log8   s    zlogaddexp._eval_rewrite_as_logc                 O   s   |  tj|i |S r+   Zrewriter	   Zevalfr(   r#   r-   r   r   r   _eval_evalf;   s    zlogaddexp._eval_evalfc                    sF   t  fdd| j\}}t||}|t||ddkr8|S t||S d S )Nc                    s   | j f i  S r+   )simplifyr   r-   r   r   <lambda>?       z*logaddexp._eval_simplify.<locals>.<lambda>Fr
   )mapr#   r   r   r(   r#   r-   ab	candidater   r4   r   _eval_simplify>   s
    
zlogaddexp._eval_simplifyN)r$   
__name__
__module____qualname____doc__nargsr   r*   r.   r1   r<   r   r   r   r   r      s   	
r   c                   @   s>   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 )
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   s   t j| gt|tdR  S r   r   r!   r   r   r   r   S   s    zlogaddexp2.__new__r$   c                 C   sJ   |dkr| j \}}n|dkr(| j \}}n
t| |tjtjt||   S r%   )r#   r   r   r&   r   r'   r   r   r   r*   V   s    
zlogaddexp2.fdiffc                 K   s
   t ||S r+   )r   r,   r   r   r   r.   b   s    zlogaddexp2._eval_rewrite_as_logc                 O   s   |  tj|i |S r+   r/   r0   r   r   r   r1   e   s    zlogaddexp2._eval_evalfc                    sF   t  fdd| j\}}t||}|t||ddkr8|S t||S d S )Nc                    s   | j f i   S r+   )r2   Zfactorr3   r4   r   r   r5   i   r6   z+logaddexp2._eval_simplify.<locals>.<lambda>Fr
   )r7   r#   r   rC   r8   r   r4   r   r<   h   s
    
zlogaddexp2._eval_simplifyN)r$   r=   r   r   r   r   rC   G   s   	
rC   N)Zsympy.core.functionr   r   r   Zsympy.core.powerr   Zsympy.core.singletonr   Zsympy.core.sortingr   Z&sympy.functions.elementary.exponentialr   r	   r   r&   r   r   r   r   r   r   rC   r   r   r   r   <module>   s   
*