o
    §ƒðj9R  ã                   @   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i d
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
ƒ qpeD ]Zeed#e› �e	ƒ q~i d$d%“d&d&“d'd'“d(d)“d*d+“d,d-“d.d/“d0d0“d1d1“d2d2“d3d3“d4d5“d6d7“d8d8“d9d:“d;d<“d=d>“d?d@dAdBdCdDdEdFdGœ¥ZdHddIœZdJd„ e ¡ D ƒZdKd„ e ¡ D ƒZG dLdM„ dMeƒZ eD ]Zee d#e› �e
ƒ qëeD ]Zee d#e› �e	ƒ qùdNd„ e ¡ D ƒZ!dOd„ e ¡ D ƒZ"G dPdQ„ dQeƒZ#e!D ]Zee#d#e› �e
ƒ �q!e"D ]Zee#d#e› �e	ƒ �q0dRd„ e ¡ D ƒZ$dSd„ e ¡ D ƒZ%G dTdU„ dUeƒZ&e$D ]Zee&d#e› �e
ƒ �qYe%D ]Zee&d#e› �e	ƒ �qhdVS )Wé    )Ú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 vr||f‘qS © )Ú_not_in_numpy©Ú.0ÚkÚvr   r   ú–/tmp/claude-1000/-var-www-html-academy/3f42efd1-c2b7-4d08-9b05-30d86bb35479/scratchpad/piper/venv/lib/python3.10/site-packages/sympy/printing/numpy.pyÚ
<listcomp>	   s     r   ÚarccosÚarccoshÚarcsinÚarcsinhÚarctanÚarctan2ÚarctanhÚexp2ÚsignÚ	logaddexpÚ
logaddexp2ÚisinfÚisnan)ÚacosÚacoshÚasinÚasinhÚatanÚatan2Úatanhr   r   r   r   r    r!   ÚeÚpiÚeuler_gammaÚnanÚinf)ÚExp1ÚPiÚ
EulerGammaÚNaNÚInfinityc                 C   ó   i | ]	\}}|d | “qS ©znumpy.r   r   r   r   r   Ú
<dictcomp>"   ó    r5   c                 C   r3   r4   r   r   r   r   r   r5   #   r6   c                       s–  e Zd ZdZdZeZeZdY‡ 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dZd1d2„Zd3e fd4d5„Z!d6d7„ Z"d8d9„ Z#d:d;„ Z$d<d=„ Z%d>d?„ Z&d@dA„ Z'dBdC„ Z(dDdE„ Z)dFdG„ Z*dHdI„ Z+dJdK„ Z,dLdM„ Z-dNdO„ Z.dPdQ„ Z/dRdS„ Z0dTZ1dUZ2dVZ3dWZ4dXZ5e6j7Z8e6j7Z9e6j7Z:e6j7Z;‡  Z<S )[ÚNumPyPrinterza
    Numpy printer which handles vectorized piecewise functions,
    logical operators, etc.
    ÚnumpyNc                    s@   d  | j¡| _d  | j¡| _i 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   rA   /   s   zNumPyPrinter.__init__c                    s"   d}d  | ‡ fdd„|D ƒ¡¡S )z+General sequence printer: converts to tupleú, z({},)c                 3   ó   � | ]}ˆ   |¡V  qd S ©N©Ú_print)r   Úitem©rC   r   r   Ú	<genexpr>B   ó   € z*NumPyPrinter._print_seq.<locals>.<genexpr>)r;   Újoin)rC   ÚseqÚ	delimiterr   rL   r   Ú
_print_seq=   s   zNumPyPrinter._print_seqc                 C   s   d|   tj¡ S )Nú-)rJ   r   r2   ©rC   Úexprr   r   r   Ú_print_NegativeInfinityD   s   z$NumPyPrinter._print_NegativeInfinityc                    sj   |  ¡ d tjur%|  ¡ 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   rG   rH   rI   ©r   ÚirL   r   r   rM   K   rN   z-NumPyPrinter._print_MatMul.<locals>.<genexpr>c                 3   rG   rH   rI   rX   rL   r   r   rM   L   rN   )Úas_coeff_matricesr   ÚOner;   rO   Úargs)rC   rU   Ú	expr_listr   rL   r   Ú_print_MatMulG   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<   rJ   r\   rT   r   r   r   Ú_print_MatPowN   s   ÿzNumPyPrinter._print_MatPowc                 C   ó$   d  |  | jd ¡|  |jd ¡¡S )zMatrix inverse printerú{}({})z.linalg.invr   r_   rT   r   r   r   Ú_print_InverseS   s   ÿzNumPyPrinter._print_Inversec                 C   sX   |j \}}|jd dkr|j}|jd dkr|j}d|  | jd ¡|  |¡|  |¡f S )Nr   r   ú
%s(%s, %s)z.dot)r\   ÚshapeÚTr`   r<   rJ   )rC   rU   Úarg1Úarg2r   r   r   Ú_print_DotProductX   s   
þzNumPyPrinter._print_DotProductc                 C   s*   d|   | jd ¡|  |j¡|  |j¡f S )Nre   z.linalg.solve)r`   r<   rJ   ÚmatrixÚvectorrT   r   r   r   Ú_print_MatrixSolvee   s   

þzNumPyPrinter._print_MatrixSolvec                 C   ó    d  |  | jd ¡|  |j¡¡S )Nrc   z.zeros©r;   r`   r<   rJ   rf   rT   r   r   r   Ú_print_ZeroMatrixj   ó   
ÿzNumPyPrinter._print_ZeroMatrixc                 C   rn   )Nrc   z.onesro   rT   r   r   r   Ú_print_OneMatrixn   rq   zNumPyPrinter._print_OneMatrixc                    s~   ddl m}m} |j}t|tƒst||f|||ƒƒ}d ˆ  ˆ jd ¡d 	‡ fdd„|j
d D ƒ¡ˆ  |j
d ¡ˆ  |j¡¡S )	Nr   )rY   Újz{}(lambda {}: {}, {})z.fromfunctionrF   c                 3   rG   rH   rI   ©r   ÚargrL   r   r   rM   x   rN   z5NumPyPrinter._print_FunctionMatrix.<locals>.<genexpr>r   )Ú	sympy.abcrY   rs   ÚlamdaÚ
isinstancer   r;   r`   r<   rO   r\   rJ   rf   )rC   rU   rY   rs   rw   r   rL   r   Ú_print_FunctionMatrixr   s   
þz"NumPyPrinter._print_FunctionMatrixc                    óZ   ˆ  ˆjd ¡‰ d ‡ ‡fdd„|jd d… D ƒ¡d ˆ |jd ¡dt|jƒd  ¡ S )	Nú	.multiplyÚ c                 3   ó"   � | ]}d   ˆ ˆ |¡¡V  qdS ©z{}({}, N©r;   rJ   rt   ©ÚfuncrC   r   r   rM   }   ó   € ÿz6NumPyPrinter._print_HadamardProduct.<locals>.<genexpr>éÿÿÿÿú{}{}ú)r   ©r`   r<   rO   r\   r;   rJ   ÚlenrT   r   r€   r   Ú_print_HadamardProduct{   ó   ÿÿÿz#NumPyPrinter._print_HadamardProductc                    rz   )	Nz.kronr|   c                 3   r}   r~   r   rt   r€   r   r   rM   ƒ   r‚   z7NumPyPrinter._print_KroneckerProduct.<locals>.<genexpr>rƒ   r„   r…   r   r†   rT   r   r€   r   Ú_print_KroneckerProduct�   r‰   z$NumPyPrinter._print_KroneckerProductc                 C   s2   d  |  | jd ¡|  | jd ¡|  |jd ¡¡S )Nz
{}({}({}))z
.conjugatez
.transposer   r_   rT   r   r   r   Ú_print_Adjoint‡   s
   ýzNumPyPrinter._print_Adjointc                 C   s8   d  |  | jd ¡|  |j¡¡}d  |  | jd ¡|¡S )Nrc   z.diagz{}({}, (-1, 1))z.reshape)r;   r`   r<   rJ   ru   )rC   rU   Úvectr   r   r   Ú_print_DiagonalOf�   s   
þÿzNumPyPrinter._print_DiagonalOfc                 C   rb   )Nrc   z	.diagflatr   r_   rT   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;   r`   r<   rJ   ru   rf   rT   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 )z$ Problem having an ITE in the cond. )ÚhasrJ   ©Úcond)r‘   rC   r’   r   r   Ú
print_cond    s   

z1NumPyPrinter._print_Piecewise.<locals>.print_condz[{}]ú,c                 3   s   � | ]	}ˆ   |j¡V  qd S rH   )rJ   rU   rt   rL   r   r   rM   ¦   s   € z0NumPyPrinter._print_Piecewise.<locals>.<genexpr>c                 3   s   � | ]}ˆ |j ƒV  qd S rH   r”   rt   )r–   r   r   rM   §   rN   z{}({}, {}, default={})z.select)Úsympy.logic.boolalgr‘   r’   r;   rO   r\   r`   r<   rJ   r   r1   )rC   rU   ÚexprsÚcondsr   )r‘   r–   rC   r’   r   Ú_print_Piecewise�   s     
þzNumPyPrinter._print_Piecewisec                    sf   dddddddœ}|j |v r-|  |j¡}|  |j¡}dj|  | jd	 ||j   ¡||d
�S tƒ  |¡S )z.Relational printer for Equality and UnequalityÚequalÚ	not_equalÚlessÚ
less_equalÚgreaterÚgreater_equal)z==z!=ú<z<=ú>z>=z{op}({lhs}, {rhs})Ú.)ÚopÚlhsÚrhs)	Úrel_oprJ   r¦   r§   r;   r`   r<   r@   Ú_print_Relational)rC   rU   r¥   r¦   r§   rD   r   r   r©   °   s   ú
ÿzNumPyPrinter._print_Relationalc                    ó.   d  ˆ  ˆ jd ¡d ‡ fdd„|jD ƒ¡¡S )úLogical And printerú{}.reduce(({}))z.logical_andr—   c                 3   rG   rH   rI   rX   rL   r   r   rM   Æ   rN   z*NumPyPrinter._print_And.<locals>.<genexpr>©r;   r`   r<   rO   r\   rT   r   rL   r   Ú
_print_AndÁ   ó   .zNumPyPrinter._print_Andc                    rª   )úLogical Or printerr¬   z.logical_orr—   c                 3   rG   rH   rI   rX   rL   r   r   rM   Í   rN   z)NumPyPrinter._print_Or.<locals>.<genexpr>r­   rT   r   rL   r   Ú	_print_OrÈ   r¯   zNumPyPrinter._print_Orc                    rª   )zLogical Not printerrc   z.logical_notr—   c                 3   rG   rH   rI   rX   rL   r   r   rM   Ô   rN   z*NumPyPrinter._print_Not.<locals>.<genexpr>r­   rT   r   rL   r   Ú
_print_NotÏ   r¯   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_integerÚis_negativer   ÚbaseÚevalfÚ_hprint_Powr<   )rC   rU   r´   r   r   r   Ú
_print_PowÖ   s   zNumPyPrinter._print_Powr¥   c                    sl   t |ƒdkrtd|› �ƒ‚t |ƒdkrˆ  |d ¡S ˆ  d¡}‡ fdd„|D ƒ}|› d|› dd	 |¡› d
�S )Nr   zNeed at least one argument for r   zfunctools.reducec                    ó   g | ]}ˆ   |¡‘qS r   rI   rt   rL   r   r   r   â   ó    z8NumPyPrinter._helper_minimum_maximum.<locals>.<listcomp>ú(z, [rF   z]))r‡   ÚNotImplementedErrorrJ   r`   rO   )rC   r¥   r\   Ú_reduceÚs_argsr   rL   r   Ú_helper_minimum_maximumÜ   s   
z$NumPyPrinter._helper_minimum_maximumc                 C   ó
   |   |¡S rH   )Ú_print_minimumrT   r   r   r   Ú
_print_Minå   ó   
zNumPyPrinter._print_Minc                 C   ó*   d  |  | jd ¡|  |j¡|  |j¡¡S )Nú{}({}, axis={})z.amin©r;   r`   r<   rJ   ÚarrayÚaxisrT   r   r   r   Ú_print_aminè   ó   *zNumPyPrinter._print_aminc                 C   ó$   |   | jd ¡}| j|g|j¢R Ž S )Nz.minimum©r`   r<   rÃ   r\   ©rC   rU   r¥   r   r   r   rÅ   ë   ó   zNumPyPrinter._print_minimumc                 C   rÄ   rH   )Ú_print_maximumrT   r   r   r   Ú
_print_Maxï   rÇ   zNumPyPrinter._print_Maxc                 C   rÈ   )NrÉ   z.amaxrÊ   rT   r   r   r   Ú_print_amaxò   rÎ   zNumPyPrinter._print_amaxc                 C   rÏ   )Nz.maximumrÐ   rÑ   r   r   r   rÓ   õ   rÒ   zNumPyPrinter._print_maximumc                 C   ó$   d|   | jd ¡|  |jd ¡f S )Nú%s(%s)z.angler   ©r`   r<   rJ   r\   rT   r   r   r   Ú
_print_argù   ó   $zNumPyPrinter._print_argc                 C   rÖ   )Nr×   z.imagr   rØ   rT   r   r   r   Ú	_print_imü   rÚ   zNumPyPrinter._print_imc                    s.   dˆ   ˆ jd ¡d ‡ fdd„|jD ƒ¡f S )Nr×   z.modrF   c                 3   rG   rH   rI   rt   rL   r   r   rM     rN   z*NumPyPrinter._print_Mod.<locals>.<genexpr>)r`   r<   rO   r\   rT   r   rL   r   Ú
_print_Modÿ   s   ÿzNumPyPrinter._print_Modc                 C   rÖ   )Nr×   z.realr   rØ   rT   r   r   r   Ú	_print_re  rÚ   zNumPyPrinter._print_rec                 C   s*   d|   | jd ¡|  |jd tj ¡f S )Nr×   z.sincr   )r`   r<   rJ   r\   r   r/   rT   r   r   r   Ú_print_sinc  rÎ   zNumPyPrinter._print_sincc                 C   s|   d|j v r|  | j› d| j› �¡}|› d|  |j ¡› d�S | j |jjd ¡}|d u r3|  | j› d�¡}d||  | 	¡ ¡f S )Nr   r¤   r¿   r…   ú.arrayr×   )
rf   r`   r<   Ú_zerosrJ   Úknown_functionsÚgetrE   Ú__name__Útolist©rC   rU   r�   r   r   r   Ú_print_MatrixBase	  s   
zNumPyPrinter._print_MatrixBasec                 C   sD   |j }tdd„ |D ƒƒrd|  | jd ¡|  |j d ¡f S tdƒ‚)Nc                 s   s   � | ]}|j V  qd S rH   )Ú
is_Integer)r   Údimr   r   r   rM     s   € z/NumPyPrinter._print_Identity.<locals>.<genexpr>r×   r�   r   zFSymbolic matrix dimensions are not yet supported for identity matrices)rf   Úallr`   r<   rJ   rÀ   )rC   rU   rf   r   r   r   Ú_print_Identity  s   $zNumPyPrinter._print_Identityc                 C   s(   d  |  | jd ¡|  |jd  ¡ ¡¡S )Nrc   z.blockr   )r;   r`   r<   rJ   r\   rä   rT   r   r   r   Ú_print_BlockMatrix  s   ÿzNumPyPrinter._print_BlockMatrixc                 C   sž   |  ¡ dkr|  | j› d�¡}|› d|  |d ¡› d�S d|jv r9|  | j› d| j› �¡}|› d|  |j¡› d�S |  | j› d�¡}|› d|  | ¡ ¡› d�S )Nr   rß   r¿   r   r…   r¤   )Úrankr`   r<   rJ   rf   rà   rä   rå   r   r   r   Ú_print_NDimArray  s   
zNumPyPrinter._print_NDimArrayÚaddÚeinsumÚ	transposeÚonesÚzerosrH   )F)=rã   Ú
__module__Ú__qualname__Ú__doc__r<   Ú_numpy_known_functionsr?   Ú_numpy_known_constantsÚ_kcrA   rR   rV   r^   ra   rd   rj   rm   rp   rr   ry   rˆ   rŠ   r‹   r�   rŽ   r�   r›   r©   r®   r±   r²   r¼   ÚstrrÃ   rÆ   rÍ   rÅ   rÔ   rÕ   rÓ   rÙ   rÛ   rÜ   rÝ   rÞ   ræ   rê   rë   rí   Ú_addÚ_einsumÚ
_transposeÚ_onesrà   r   Ú_print_not_supportedÚ_print_lowergammaÚ_print_uppergammaÚ_print_fresnelcÚ_print_fresnelsÚ__classcell__r   r   rD   r   r7   %   sj    	
		
r7   Ú_print_ÚEiÚexpiÚerfÚerfcÚbesseljÚjvÚbesselyÚyvÚbesseliÚivÚbesselkÚkvÚcosm1Úpowm1Ú	factorialÚgammaÚloggammaÚgammalnÚdigammaÚpsiÚ	polygammaÚRisingFactorialÚpochÚjacobiÚeval_jacobiÚ
gegenbauerÚeval_gegenbauerÚeval_chebytÚeval_chebyuÚeval_legendreÚeval_hermiteÚeval_laguerreÚeval_genlaguerreÚbetaÚlambertw)Ú
chebyshevtÚ
chebyshevuÚlegendreÚhermiteÚlaguerreÚassoc_laguerrer&  ÚLambertWÚgolden_ratio)ÚGoldenRatior/   c                 C   r3   )zscipy.special.r   r   r   r   r   r5   Y  r6   c                 C   r3   )zscipy.constants.r   r   r   r   r   r5   Z  r6   c                       sÆ   e Zd Zi ej¥e¥Zi 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                    ó   t ƒ j|d� d| _d S )Nr9   zPython with SciPy and NumPy)r@   rA   r=   rB   rD   r   r   rA   a  ó   
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ÚdatarY   rs   rf   )ÚtodokÚitemsÚappendr;   r`   rf   )rC   rU   rY   rs   r5  ÚrÚcr   r   r   r   Ú_print_SparseRepMatrixe  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`   rJ   r\   rT   r   r   r   Ú_print_assoc_legendret  s   üz"SciPyPrinter._print_assoc_legendrec              	   C   ó4   d  |  d¡|  d¡|  |jd ¡|  |jd ¡¡S )Nú{0}({2})*{1}({2}, {3})úscipy.special.gammazscipy.special.gammaincr   r   r=  rT   r   r   r   rÿ   {  ó   üzSciPyPrinter._print_lowergammac              	   C   r?  )Nr@  rA  zscipy.special.gammainccr   r   r=  rT   r   r   r   r   ‚  rB  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                    r½   r   rI   rt   rL   r   r   r   Œ  r¾   z/SciPyPrinter._print_betainc.<locals>.<listcomp>r¿   r   rF   r   é   z) - r<  z))             * r…   )r`   r\   )rC   rU   Úbetaincr&  r\   r   rL   r   Ú_print_betainc‰  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})rC  r   r   r<  rD  r=  rT   r   r   r   Ú_print_betainc_regularized�  s   ûz'SciPyPrinter._print_betainc_regularizedc                 C   ó   d  |  d¡|  |jd ¡¡S )Nú	{}({})[0]úscipy.special.fresnelr   r=  rT   r   r   r   r  ˜  ó   þzSciPyPrinter._print_fresnelsc                 C   rH  )Nú	{}({})[1]rJ  r   r=  rT   r   r   r   r  �  rK  zSciPyPrinter._print_fresnelcc                 C   rH  )NrI  úscipy.special.airyr   r=  rT   r   r   r   Ú_print_airyai¢  rK  zSciPyPrinter._print_airyaic                 C   rH  )NrL  rM  r   r=  rT   r   r   r   Ú_print_airyaiprime§  rK  zSciPyPrinter._print_airyaiprimec                 C   rH  )Nz	{}({})[2]rM  r   r=  rT   r   r   r   Ú_print_airybi¬  rK  zSciPyPrinter._print_airybic                 C   rH  )Nz	{}({})[3]rM  r   r=  rT   r   r   r   Ú_print_airybiprime±  rK  zSciPyPrinter._print_airybiprimec                 C   ó   |   |j|jŽ ¡S rH   ©rJ   Ú_eval_rewrite_as_zetar\   rT   r   r   r   Ú_print_bernoulli¶  s   zSciPyPrinter._print_bernoullic                 C   rR  rH   rS  rT   r   r   r   Ú_print_harmonicº  ó   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.nquadrW   rF   c                 3   s$   � | ]}d t tˆ j|ƒƒ V  qdS )z(%s, %s)N)ÚtupleÚmaprJ   )r   ÚlrL   r   r   rM   Æ  s   € 
ÿz/SciPyPrinter._print_Integral.<locals>.<genexpr>z{}(lambda {}: {}, {})[0])	r
   r‡   r`   rX  rY  rJ   r;   rO   r\   )rC   r)   Úintegration_varsÚlimitsÚ
module_strÚ	limit_strr   rL   r   Ú_print_Integral½  s   


ÿüzSciPyPrinter._print_Integralc                 C   rH  )NrI  úscipy.special.sicir   r=  rT   r   r   r   Ú	_print_SiÏ  rK  zSciPyPrinter._print_Sic                 C   rH  )NrL  r`  r   r=  rT   r   r   r   Ú	_print_CiÔ  rK  zSciPyPrinter._print_CirH   )rã   ró   rô   r7   r?   Ú_scipy_known_functionsrø   Ú_scipy_known_constantsrA   r;  Ú_print_ImmutableSparseMatrixr>  rÿ   r   rF  rG  r  r  rN  rO  rP  rQ  rU  rV  r_  ra  rb  r  r   r   rD   r   r1  \  s,    r1  c                 C   r3   ©zcupy.r   r   r   r   r   r5   à  r6   c                 C   r3   rf  r   r   r   r   r   r5   á  r6   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.
    ÚcupyNc                    s   t ƒ j|d� d S )Nr9   )r@   rA   rB   rD   r   r   rA   í  rW  zCuPyPrinter.__init__rH   )rã   ró   rô   rõ   r<   Ú_cupy_known_functionsr?   Ú_cupy_known_constantsrø   rA   r  r   r   rD   r   rg  ã  s    rg  c                 C   r3   ©z
jax.numpy.r   r   r   r   r   r5   ÷  r6   c                 C   r3   rk  r   r   r   r   r   r5   ø  r6   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                    r2  )Nr9   Ú_jaxcode)r@   rA   r>   rB   rD   r   r   rA     r3  zJaxPrinter.__init__c              	      ó8   d  ˆ  ˆ jd ¡ˆ  ˆ j¡d ‡ fdd„|jD ƒ¡¡S )r«   ú{}({}.asarray([{}]), axis=0)z.allr—   c                 3   rG   rH   rI   rX   rL   r   r   rM     rN   z(JaxPrinter._print_And.<locals>.<genexpr>r­   rT   r   rL   r   r®   	  ó
   
ýzJaxPrinter._print_Andc              	      rn  )r°   ro  z.anyr—   c                 3   rG   rH   rI   rX   rL   r   r   rM     rN   z'JaxPrinter._print_Or.<locals>.<genexpr>r­   rT   r   rL   r   r±     rp  zJaxPrinter._print_OrrH   )rã   ró   rô   rõ   r<   Ú_jax_known_functionsr?   Ú_jax_known_constantsrø   rA   r®   r±   r  r   r   rD   r   rl  ú  s    rl  N)'Ú
sympy.corer   Úsympy.core.functionr   Úsympy.core.powerr   Úpycoder   r   r   r	   r
   r   Úcodeprinterr   Úsplitr   r7  Ú	_in_numpyÚdictÚ_known_functions_numpyÚ_known_constants_numpyrö   r÷   r7   r�   ÚsetattrÚconstÚ_known_functions_scipy_specialÚ _known_constants_scipy_constantsrc  rd  r1  ri  rj  rg  rq  rr  rl  r   r   r   r   Ú<module>   sÔ     
óû  ÿþýüûúùø	÷
öõôóòñðïçþ}ÿ