U
     ‹ÑhN  ã                   @   s¤  d dl mZ d dlmZ d dlmZ ddlmZmZm	Z	m
Z
mZmZ ddlmZ d ¡ Zdd	„ e ¡ D ƒZeefd
ddddddddddddœŽZddddddœZdd„ e ¡ D ƒZdd„ e ¡ D ƒZG d d!„ d!eeƒZeD ]Zeed"e› �e
ƒ qÚeD ]Zeed"e› �e	ƒ qöd#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<œZd=dd>œZd?d„ e ¡ D ƒZd@d„ e ¡ D ƒZG dAdB„ dBeƒZ eD ]Zee d"e› �e
ƒ �qˆeD ]Zee d"e› �e	ƒ �q¦dCd„ e ¡ D ƒZ!dDd„ e ¡ D ƒZ"G dEdF„ dFeƒZ#e!D ]Zee#d"e› �e
ƒ �qøe"D ]Zee#d"e› �e	ƒ �qdGd„ e ¡ D ƒZ$dHd„ e ¡ D ƒZ%G dIdJ„ dJeƒZ&e$D ]Zee&d"e› �e
ƒ �qhe%D ]Zee&d"e› �e	ƒ �q†dKS )Lé    )ÚS)ÚLambda)ÚPowé   )ÚPythonCodePrinterÚ_known_functions_mathÚ_print_known_constÚ_print_known_funcÚ_unpack_integral_limitsÚArrayPrinter)ÚCodePrinterz!erf erfc factorial gamma loggammac                 C   s    g | ]\}}|t kr||f‘qS © )Ú_not_in_numpy©Ú.0ÚkÚvr   r   úB/tmp/user/2202/pip-unpacked-wheel-qe3242ng/sympy/printing/numpy.pyÚ
<listcomp>	   s      r   ZarccosZarccoshZarcsinZarcsinhZarctanZarctan2ZarctanhÚexp2ÚsignÚ	logaddexpÚ
logaddexp2Úisnan)ÚacosÚacoshÚasinÚasinhÚatanÚatan2Úatanhr   r   r   r   r   ÚeÚpiZeuler_gammaÚnanÚinf)ZExp1ÚPiZ
EulerGammaÚNaNÚInfinityc                 C   s   i | ]\}}|d | “qS ©znumpy.r   r   r   r   r   Ú
<dictcomp>    s      r)   c                 C   s   i | ]\}}|d | “qS r(   r   r   r   r   r   r)   !   s      c                       sl  e Zd ZdZdZeZeZdN‡ fdd„	Z	dd„ Z
dd	„ Zd
d„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Z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dOd1d2„Zd3d4„ Z d5d6„ Z!d7d8„ Z"d9d:„ Z#d;d<„ Z$d=d>„ Z%d?d@„ Z&dAdB„ Z'dCdD„ Z(dEdF„ Z)‡ fdGdH„Z*dIZ+dJZ,dKZ-dLZ.dMZ/e0j1Z2e0j1Z3e0j1Z4e0j1Z5‡  Z6S )PÚNumPyPrinterza
    Numpy printer which handles vectorized piecewise functions,
    logical operators, etc.
    ZnumpyNc                    s<   d  | j¡| _d  | j¡| _tj| j–| _tƒ j|d� dS )z 
        `settings` is passed to CodePrinter.__init__()
        `module` specifies the array module to use, currently 'NumPy', 'CuPy'
        or 'JAX'.
        zPython with {}z_{}code©ÚsettingsN)ÚformatÚ_moduleÚlanguageÚprintmethodr   Ú_kfÚsuperÚ__init__©Úselfr,   ©Ú	__class__r   r   r3   -   s    zNumPyPrinter.__init__c                    s"   d}d  | ‡ fdd„|D ƒ¡¡S )z+General sequence printer: converts to tupleú, z({},)c                 3   s   | ]}ˆ   |¡V  qd S ©N©Ú_print)r   Úitem©r5   r   r   Ú	<genexpr>@   s     z*NumPyPrinter._print_seq.<locals>.<genexpr>)r-   Újoin)r5   ÚseqÚ	delimiterr   r=   r   Ú
_print_seq;   s    zNumPyPrinter._print_seqc                 C   s   d|   tj¡ S )Nú-)r;   r   r'   ©r5   Úexprr   r   r   Ú_print_NegativeInfinityB   s    z$NumPyPrinter._print_NegativeInfinityc                    sj   |  ¡ d tjk	rJ|  ¡ d |  ¡ d g }d d ‡ fdd„|D ƒ¡¡S d d ‡ fdd„|jD ƒ¡¡S )zMatrix multiplication printerr   r   ú({})z).dot(c                 3   s   | ]}ˆ   |¡V  qd S r9   r:   ©r   Úir=   r   r   r>   I   s     z-NumPyPrinter._print_MatMul.<locals>.<genexpr>c                 3   s   | ]}ˆ   |¡V  qd S r9   r:   rH   r=   r   r   r>   J   s     )Zas_coeff_matricesr   ZOner-   r?   Úargs)r5   rE   Z	expr_listr   r=   r   Ú_print_MatMulE   s    zNumPyPrinter._print_MatMulc                 C   s2   d  |  | jd ¡|  |jd ¡|  |jd ¡¡S )zMatrix power printerz
{}({}, {})z.linalg.matrix_powerr   r   ©r-   Ú_module_formatr.   r;   rJ   rD   r   r   r   Ú_print_MatPowL   s     ÿzNumPyPrinter._print_MatPowc                 C   s$   d  |  | jd ¡|  |jd ¡¡S )zMatrix inverse printerú{}({})z.linalg.invr   rL   rD   r   r   r   Ú_print_InverseQ   s    ÿzNumPyPrinter._print_Inversec                 C   sX   |j \}}|jd dkr|j}|jd dkr2|j}d|  | jd ¡|  |¡|  |¡f S )Nr   r   ú
%s(%s, %s)z.dot)rJ   ÚshapeÚTrM   r.   r;   )r5   rE   Zarg1Zarg2r   r   r   Ú_print_DotProductV   s    
þzNumPyPrinter._print_DotProductc                 C   s*   d|   | jd ¡|  |j¡|  |j¡f S )NrQ   z.linalg.solve)rM   r.   r;   ZmatrixZvectorrD   r   r   r   Ú_print_MatrixSolvec   s    

þzNumPyPrinter._print_MatrixSolvec                 C   s    d  |  | jd ¡|  |j¡¡S )NrO   z.zeros©r-   rM   r.   r;   rR   rD   r   r   r   Ú_print_ZeroMatrixh   s    
ÿzNumPyPrinter._print_ZeroMatrixc                 C   s    d  |  | jd ¡|  |j¡¡S )NrO   z.onesrV   rD   r   r   r   Ú_print_OneMatrixl   s    
ÿzNumPyPrinter._print_OneMatrixc                    s~   ddl m}m} |j}t|tƒs4t||f|||ƒƒ}d ˆ  ˆ jd ¡d 	‡ fdd„|j
d D ƒ¡ˆ  |j
d ¡ˆ  |j¡¡S )	Nr   )rI   Újz{}(lambda {}: {}, {})z.fromfunctionr8   c                 3   s   | ]}ˆ   |¡V  qd S r9   r:   ©r   Úargr=   r   r   r>   v   s     z5NumPyPrinter._print_FunctionMatrix.<locals>.<genexpr>r   )Z	sympy.abcrI   rY   ÚlamdaÚ
isinstancer   r-   rM   r.   r?   rJ   r;   rR   )r5   rE   rI   rY   r\   r   r=   r   Ú_print_FunctionMatrixp   s    
 
þz"NumPyPrinter._print_FunctionMatrixc                    sZ   ˆ  ˆjd ¡‰ d ‡ ‡fdd„|jd d… D ƒ¡d ˆ |jd ¡dt|jƒd  ¡ S )	Nú	.multiplyÚ c                 3   s    | ]}d   ˆ ˆ |¡¡V  qdS ©z{}({}, N©r-   r;   rZ   ©Úfuncr5   r   r   r>   {   s   ÿz6NumPyPrinter._print_HadamardProduct.<locals>.<genexpr>éÿÿÿÿú{}{}ú)r   ©rM   r.   r?   rJ   r-   r;   ÚlenrD   r   rc   r   Ú_print_HadamardProducty   s    ÿÿÿz#NumPyPrinter._print_HadamardProductc                    sZ   ˆ  ˆjd ¡‰ d ‡ ‡fdd„|jd d… D ƒ¡d ˆ |jd ¡dt|jƒd  ¡ S )	Nz.kronr`   c                 3   s    | ]}d   ˆ ˆ |¡¡V  qdS ra   rb   rZ   rc   r   r   r>   �   s   ÿz7NumPyPrinter._print_KroneckerProduct.<locals>.<genexpr>re   rf   rg   r   rh   rD   r   rc   r   Ú_print_KroneckerProduct   s    ÿÿÿz$NumPyPrinter._print_KroneckerProductc                 C   s2   d  |  | jd ¡|  | jd ¡|  |jd ¡¡S )Nz
{}({}({}))z
.conjugatez
.transposer   rL   rD   r   r   r   Ú_print_Adjoint…   s
    ýzNumPyPrinter._print_Adjointc                 C   s8   d  |  | jd ¡|  |j¡¡}d  |  | jd ¡|¡S )NrO   z.diagz{}({}, (-1, 1))z.reshape)r-   rM   r.   r;   r[   )r5   rE   Zvectr   r   r   Ú_print_DiagonalOf‹   s    
þ ÿzNumPyPrinter._print_DiagonalOfc                 C   s$   d  |  | jd ¡|  |jd ¡¡S )NrO   z	.diagflatr   rL   rD   r   r   r   Ú_print_DiagMatrix’   s    ÿzNumPyPrinter._print_DiagMatrixc              
   C   sJ   d  |  | jd ¡|  |j¡|  | jd ¡|  |jd ¡|  |jd ¡¡S )Nz{}({}, {}({}, {}))r_   ú.eyer   r   )r-   rM   r.   r;   r[   rR   rD   r   r   r   Ú_print_DiagonalMatrix–   s    
  þz"NumPyPrinter._print_DiagonalMatrixc                    s„   ddl m‰ m‰ ‡ ‡‡fdd„‰d d ‡fdd„|jD ƒ¡¡}d d ‡fd	d„|jD ƒ¡¡}d
 ˆ ˆjd ¡||ˆ t	j
¡¡S )zPiecewise function printerr   )ÚITEÚsimplify_logicc                    s&   |   ˆ ¡rˆ ˆ| ƒ¡S ˆ | ¡S dS )z$ Problem having an ITE in the cond. N)Zhasr;   ©Zcond)rq   r5   rr   r   r   Ú
print_condž   s    
z1NumPyPrinter._print_Piecewise.<locals>.print_condz[{}]ú,c                 3   s   | ]}ˆ   |j¡V  qd S r9   )r;   rE   rZ   r=   r   r   r>   ¤   s     z0NumPyPrinter._print_Piecewise.<locals>.<genexpr>c                 3   s   | ]}ˆ |j ƒV  qd S r9   rs   rZ   )rt   r   r   r>   ¥   s     z{}({}, {}, default={})z.select)Zsympy.logic.boolalgrq   rr   r-   r?   rJ   rM   r.   r;   r   r&   )r5   rE   ÚexprsZcondsr   )rq   rt   r5   rr   r   Ú_print_Piecewise›   s        
þzNumPyPrinter._print_Piecewisec                    sf   dddddddœ}|j |krZ|  |j¡}|  |j¡}dj|  | jd	 ||j   ¡||d
�S tƒ  |¡S )z.Relational printer for Equality and UnequalityÚequalÚ	not_equalZlessZ
less_equalZgreaterZgreater_equal)z==z!=ú<z<=ú>z>=z{op}({lhs}, {rhs})Ú.)ÚopÚlhsÚrhs)	Zrel_opr;   r~   r   r-   rM   r.   r2   Ú_print_Relational)r5   rE   r}   r~   r   r6   r   r   r€   ®   s    ú
 ÿzNumPyPrinter._print_Relationalc                    s.   d  ˆ  ˆ jd ¡d ‡ fdd„|jD ƒ¡¡S )úLogical And printerú{}.reduce(({}))z.logical_andru   c                 3   s   | ]}ˆ   |¡V  qd S r9   r:   rH   r=   r   r   r>   Ä   s     z*NumPyPrinter._print_And.<locals>.<genexpr>©r-   rM   r.   r?   rJ   rD   r   r=   r   Ú
_print_And¿   s    zNumPyPrinter._print_Andc                    s.   d  ˆ  ˆ jd ¡d ‡ fdd„|jD ƒ¡¡S )úLogical Or printerr‚   z.logical_orru   c                 3   s   | ]}ˆ   |¡V  qd S r9   r:   rH   r=   r   r   r>   Ë   s     z)NumPyPrinter._print_Or.<locals>.<genexpr>rƒ   rD   r   r=   r   Ú	_print_OrÆ   s    zNumPyPrinter._print_Orc                    s.   d  ˆ  ˆ jd ¡d ‡ fdd„|jD ƒ¡¡S )zLogical Not printerrO   z.logical_notru   c                 3   s   | ]}ˆ   |¡V  qd S r9   r:   rH   r=   r   r   r>   Ò   s     z*NumPyPrinter._print_Not.<locals>.<genexpr>rƒ   rD   r   r=   r   Ú
_print_NotÍ   s    zNumPyPrinter._print_NotFc                 C   s<   |j jr&|j jr&t|j|j  ¡ dd�}| j||| jd d�S )NF)Úevaluatez.sqrt)ÚrationalÚsqrt)ÚexpÚ
is_integerZis_negativer   ÚbaseZevalfZ_hprint_Powr.   )r5   rE   r‰   r   r   r   Ú
_print_PowÔ   s    zNumPyPrinter._print_Powc              	      s8   d  ˆ  ˆ jd ¡ˆ  ˆ j¡d ‡ fdd„|jD ƒ¡¡S )Nú{}({}.asarray([{}]), axis=0)z.aminru   c                 3   s   | ]}ˆ   |¡V  qd S r9   r:   rH   r=   r   r   r>   Û   s     z*NumPyPrinter._print_Min.<locals>.<genexpr>rƒ   rD   r   r=   r   Ú
_print_MinÚ   s    zNumPyPrinter._print_Minc              	      s8   d  ˆ  ˆ jd ¡ˆ  ˆ j¡d ‡ fdd„|jD ƒ¡¡S )Nr�   z.amaxru   c                 3   s   | ]}ˆ   |¡V  qd S r9   r:   rH   r=   r   r   r>   Þ   s     z*NumPyPrinter._print_Max.<locals>.<genexpr>rƒ   rD   r   r=   r   Ú
_print_MaxÝ   s    zNumPyPrinter._print_Maxc                 C   s$   d|   | jd ¡|  |jd ¡f S )Nú%s(%s)z.angler   ©rM   r.   r;   rJ   rD   r   r   r   Ú
_print_argß   s    zNumPyPrinter._print_argc                 C   s$   d|   | jd ¡|  |jd ¡f S )Nr’   z.imagr   r“   rD   r   r   r   Ú	_print_imâ   s    zNumPyPrinter._print_imc                    s.   dˆ   ˆ jd ¡d ‡ fdd„|jD ƒ¡f S )Nr’   z.modr8   c                 3   s   | ]}ˆ   |¡V  qd S r9   r:   rZ   r=   r   r   r>   ç   s     z*NumPyPrinter._print_Mod.<locals>.<genexpr>)rM   r.   r?   rJ   rD   r   r=   r   Ú
_print_Modå   s    ÿzNumPyPrinter._print_Modc                 C   s$   d|   | jd ¡|  |jd ¡f S )Nr’   z.realr   r“   rD   r   r   r   Ú	_print_reé   s    zNumPyPrinter._print_rec                 C   s*   d|   | jd ¡|  |jd tj ¡f S )Nr’   z.sincr   )rM   r.   r;   rJ   r   r%   rD   r   r   r   Ú_print_sincì   s    zNumPyPrinter._print_sincc                 C   s@   | j  |jjd ¡}|d kr*|  | jd ¡}d||  | ¡ ¡f S )Nz.arrayr’   )Zknown_functionsÚgetr7   Ú__name__rM   r.   r;   Útolist)r5   rE   rd   r   r   r   Ú_print_MatrixBaseï   s    zNumPyPrinter._print_MatrixBasec                 C   sH   |j }tdd„ |D ƒƒr<d|  | jd ¡|  |j d ¡f S tdƒ‚d S )Nc                 s   s   | ]}|j V  qd S r9   )Z
is_Integer)r   Zdimr   r   r   r>   ÷   s     z/NumPyPrinter._print_Identity.<locals>.<genexpr>r’   ro   r   zFSymbolic matrix dimensions are not yet supported for identity matrices)rR   ÚallrM   r.   r;   ÚNotImplementedError)r5   rE   rR   r   r   r   Ú_print_Identityõ   s    $zNumPyPrinter._print_Identityc                 C   s(   d  |  | jd ¡|  |jd  ¡ ¡¡S )NrO   z.blockr   )r-   rM   r.   r;   rJ   r›   rD   r   r   r   Ú_print_BlockMatrixü   s    ÿzNumPyPrinter._print_BlockMatrixc                    sV   t |jƒdkr,| jd |  |jd ¡ d S t |jƒdkrH|  | ¡ ¡S tƒ  | |¡S )Nr   z.array(r   rg   é   )ri   rR   r.   r;   rJ   Ztomatrixr2   Ú_print_not_supportedrD   r6   r   r   Ú_print_NDimArray   s
    zNumPyPrinter._print_NDimArrayÚaddZeinsumZ	transposeZonesÚzeros)N)F)7rš   Ú
__module__Ú__qualname__Ú__doc__r.   Ú_numpy_known_functionsr1   Ú_numpy_known_constantsÚ_kcr3   rB   rF   rK   rN   rP   rT   rU   rW   rX   r^   rj   rk   rl   rm   rn   rp   rw   r€   r„   r†   r‡   rŽ   r�   r‘   r”   r•   r–   r—   r˜   rœ   rŸ   r    r£   Z_addZ_einsumZ
_transposeZ_onesZ_zerosr   r¢   Ú_print_lowergammaÚ_print_uppergammaÚ_print_fresnelcÚ_print_fresnelsÚ__classcell__r   r   r6   r   r*   #   s^   	
r*   Z_print_ZexpiÚerfÚerfcZjvZyvZivÚkvÚcosm1Úpowm1Ú	factorialÚgammaZgammalnÚpsiÚ	polygammaZpochZeval_jacobiZeval_gegenbauerZeval_chebytZeval_chebyuZeval_legendreZeval_hermiteZeval_laguerreZeval_genlaguerreÚbetaZlambertw)ZEir±   r²   ZbesseljZbesselyZbesseliZbesselkr´   rµ   r¶   r·   ZloggammaZdigammar¹   ZRisingFactorialZjacobiZ
gegenbauerZ
chebyshevtZ
chebyshevuZlegendreZhermiteZlaguerreZassoc_laguerrerº   ZLambertWZgolden_ratio)ZGoldenRatior%   c                 C   s   i | ]\}}|d | “qS )zscipy.special.r   r   r   r   r   r)   :  s      c                 C   s   i | ]\}}|d | “qS )zscipy.constants.r   r   r   r   r   r)   ;  s      c                       s¾   e Zd Zeje–Zeje–Zd&‡ fdd„	Zdd„ Z	e	Z
dd„ Zdd	„ Zd
d„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zd d!„ Zd"d#„ Zd$d%„ Z‡  ZS )'ÚSciPyPrinterNc                    s   t ƒ j|d� d| _d S )Nr+   zPython with SciPy and NumPy)r2   r3   r/   r4   r6   r   r   r3   B  s    zSciPyPrinter.__init__c                 C   sd   g g g   }}}|  ¡  ¡ D ]*\\}}}| |¡ | |¡ | |¡ qdj|  d¡||||jd�S )Nz+{name}(({data}, ({i}, {j})), shape={shape})zscipy.sparse.coo_matrix)ÚnameÚdatarI   rY   rR   )ZtodokÚitemsÚappendr-   rM   rR   )r5   rE   rI   rY   r½   ÚrÚcr   r   r   r   Ú_print_SparseRepMatrixF  s    

   þz#SciPyPrinter._print_SparseRepMatrixc              	   C   s:   d  |  d¡|  |jd ¡|  |jd ¡|  |jd ¡¡S )Nz{0}({2}, {1}, {3})zscipy.special.lpmvr   r   r¡   ©r-   rM   r;   rJ   rD   r   r   r   Ú_print_assoc_legendreU  s    üz"SciPyPrinter._print_assoc_legendrec              	   C   s4   d  |  d¡|  d¡|  |jd ¡|  |jd ¡¡S )Nú{0}({2})*{1}({2}, {3})úscipy.special.gammazscipy.special.gammaincr   r   rÃ   rD   r   r   r   r¬   \  s    üzSciPyPrinter._print_lowergammac              	   C   s4   d  |  d¡|  d¡|  |jd ¡|  |jd ¡¡S )NrÅ   rÆ   zscipy.special.gammainccr   r   rÃ   rD   r   r   r   r­   c  s    üzSciPyPrinter._print_uppergammac                    s�   ˆ   d¡}ˆ   d¡}‡ fdd„|jD ƒ}d|› d|d › d|d › d|d	 › d
|› d|d › d|d › d|d › d|› d|d › d|d › d�S )Núscipy.special.betainczscipy.special.betac                    s   g | ]}ˆ   |¡‘qS r   r:   rZ   r=   r   r   r   m  s     z/SciPyPrinter._print_betainc.<locals>.<listcomp>ú(r   r8   r   é   z) - r¡   z))             * rg   )rM   rJ   )r5   rE   Zbetaincrº   rJ   r   r=   r   Ú_print_betaincj  s    

JÿzSciPyPrinter._print_betaincc              
   C   sH   d  |  d¡|  |jd ¡|  |jd ¡|  |jd ¡|  |jd ¡¡S )Nz'{0}({1}, {2}, {4}) - {0}({1}, {2}, {3})rÇ   r   r   r¡   rÉ   rÃ   rD   r   r   r   Ú_print_betainc_regularizedq  s    ûz'SciPyPrinter._print_betainc_regularizedc                 C   s   d  |  d¡|  |jd ¡¡S )Nú	{}({})[0]úscipy.special.fresnelr   rÃ   rD   r   r   r   r¯   y  s    þzSciPyPrinter._print_fresnelsc                 C   s   d  |  d¡|  |jd ¡¡S )Nú	{}({})[1]rÍ   r   rÃ   rD   r   r   r   r®   ~  s    þzSciPyPrinter._print_fresnelcc                 C   s   d  |  d¡|  |jd ¡¡S )NrÌ   úscipy.special.airyr   rÃ   rD   r   r   r   Ú_print_airyaiƒ  s    þzSciPyPrinter._print_airyaic                 C   s   d  |  d¡|  |jd ¡¡S )NrÎ   rÏ   r   rÃ   rD   r   r   r   Ú_print_airyaiprimeˆ  s    þzSciPyPrinter._print_airyaiprimec                 C   s   d  |  d¡|  |jd ¡¡S )Nz	{}({})[2]rÏ   r   rÃ   rD   r   r   r   Ú_print_airybi�  s    þzSciPyPrinter._print_airybic                 C   s   d  |  d¡|  |jd ¡¡S )Nz	{}({})[3]rÏ   r   rÃ   rD   r   r   r   Ú_print_airybiprime’  s    þzSciPyPrinter._print_airybiprimec                 C   s   |   |j|jŽ ¡S r9   ©r;   Z_eval_rewrite_as_zetarJ   rD   r   r   r   Ú_print_bernoulli—  s    zSciPyPrinter._print_bernoullic                 C   s   |   |j|jŽ ¡S r9   rÔ   rD   r   r   r   Ú_print_harmonic›  s    zSciPyPrinter._print_harmonicc                    sŽ   t |ƒ\}}t|ƒdkr<ˆ  d¡}dttˆ j|d ƒƒ }n(ˆ  d¡}d d ‡ fdd	„|D ƒ¡¡}d
 |d tˆ j|ƒ¡ˆ  |jd ¡|¡S )Nr   zscipy.integrate.quadz%s, %sr   zscipy.integrate.nquadrG   r8   c                 3   s"   | ]}d t tˆ j|ƒƒ V  qdS )z(%s, %s)N)ÚtupleÚmapr;   )r   Úlr=   r   r   r>   §  s    z/SciPyPrinter._print_Integral.<locals>.<genexpr>z{}(lambda {}: {}, {})[0])	r
   ri   rM   r×   rØ   r;   r-   r?   rJ   )r5   r!   Zintegration_varsZlimitsZ
module_strZ	limit_strr   r=   r   Ú_print_Integralž  s    

ÿ
üzSciPyPrinter._print_Integralc                 C   s   d  |  d¡|  |jd ¡¡S )NrÌ   úscipy.special.sicir   rÃ   rD   r   r   r   Ú	_print_Si°  s    þzSciPyPrinter._print_Sic                 C   s   d  |  d¡|  |jd ¡¡S )NrÎ   rÛ   r   rÃ   rD   r   r   r   Ú	_print_Ciµ  s    þzSciPyPrinter._print_Ci)N)rš   r¦   r§   r*   r1   Ú_scipy_known_functionsr«   Ú_scipy_known_constantsr3   rÂ   Z_print_ImmutableSparseMatrixrÄ   r¬   r­   rÊ   rË   r¯   r®   rÐ   rÑ   rÒ   rÓ   rÕ   rÖ   rÚ   rÜ   rÝ   r°   r   r   r6   r   r»   =  s*   

r»   c                 C   s   i | ]\}}|d | “qS ©zcupy.r   r   r   r   r   r)   Á  s      c                 C   s   i | ]\}}|d | “qS rà   r   r   r   r   r   r)   Â  s      c                       s.   e Zd ZdZdZeZeZd‡ fdd„	Z	‡  Z
S )ÚCuPyPrinterz`
    CuPy printer which handles vectorized piecewise functions,
    logical operators, etc.
    ZcupyNc                    s   t ƒ j|d� d S )Nr+   )r2   r3   r4   r6   r   r   r3   Î  s    zCuPyPrinter.__init__)N)rš   r¦   r§   r¨   r.   Ú_cupy_known_functionsr1   Ú_cupy_known_constantsr«   r3   r°   r   r   r6   r   rá   Ä  s
   rá   c                 C   s   i | ]\}}|d | “qS ©z
jax.numpy.r   r   r   r   r   r)   Ø  s      c                 C   s   i | ]\}}|d | “qS rä   r   r   r   r   r   r)   Ù  s      c                       s>   e Zd ZdZdZeZeZd
‡ fdd„	Z	dd„ Z
dd	„ Z‡  ZS )Ú
JaxPrinterz_
    JAX printer which handles vectorized piecewise functions,
    logical operators, etc.
    z	jax.numpyNc                    s   t ƒ j|d� d| _d S )Nr+   Z_jaxcode)r2   r3   r0   r4   r6   r   r   r3   å  s    zJaxPrinter.__init__c              	      s8   d  ˆ  ˆ jd ¡ˆ  ˆ j¡d ‡ fdd„|jD ƒ¡¡S )r�   r�   z.allru   c                 3   s   | ]}ˆ   |¡V  qd S r9   r:   rH   r=   r   r   r>   ï  s     z(JaxPrinter._print_And.<locals>.<genexpr>rƒ   rD   r   r=   r   r„   ê  s
    
ýzJaxPrinter._print_Andc              	      s8   d  ˆ  ˆ jd ¡ˆ  ˆ j¡d ‡ fdd„|jD ƒ¡¡S )r…   r�   z.anyru   c                 3   s   | ]}ˆ   |¡V  qd S r9   r:   rH   r=   r   r   r>   ÷  s     z'JaxPrinter._print_Or.<locals>.<genexpr>rƒ   rD   r   r=   r   r†   ò  s
    
ýzJaxPrinter._print_Or)N)rš   r¦   r§   r¨   r.   Ú_jax_known_functionsr1   Ú_jax_known_constantsr«   r3   r„   r†   r°   r   r   r6   r   rå   Û  s   rå   N)'Z
sympy.corer   Zsympy.core.functionr   Zsympy.core.powerr   Zpycoder   r   r   r	   r
   r   Zcodeprinterr   Úsplitr   r¾   Z	_in_numpyÚdictZ_known_functions_numpyZ_known_constants_numpyr©   rª   r*   rd   ÚsetattrÚconstZ_known_functions_scipy_specialZ _known_constants_scipy_constantsrÞ   rß   r»   râ   rã   rá   ræ   rç   rå   r   r   r   r   Ú<module>   s¨    ôû qçþ}