o
    Tæ«d#  ã                   @   sT   d Z ddlZddlZddlmZ ddlmZ ddlm	Z	m
Z
 dd„ Zedd	„ ƒZdS )
aD  Contains information on how to translate different ufuncs for the CUDA
target. It is a database of different ufuncs and how each of its loops maps to
a function that implements the inner kernel of that ufunc (the inner kernel
being the per-element function).

Use get_ufunc_info() to get the information related to a ufunc.
é    N)Ú	lru_cache)Útyping)Úget_unary_impl_for_fn_and_tyÚget_binary_impl_for_fn_and_tyc                 C   s
   t ƒ |  S ©N)Úufunc_db)Ú	ufunc_key© r	   úd/home/ncw/WWW/www-new/content/articles/pi-bbp/venv/lib/python3.10/site-packages/numba/cuda/ufuncs.pyÚget_ufunc_info   s   
r   c                     s¤  ddl m} m} ddlm‰  ddlm}m}m} ‡ fdd„‰‡ fdd„‰‡fd	d
„‰‡fdd„‰‡fdd„}‡fdd„}‡fdd„}‡fdd„}‡fdd„}	‡fdd„}
‡fdd„‰‡ ‡‡‡‡fdd„}‡fdd„‰‡ ‡‡‡‡fdd „}‡fd!d"„}‡ ‡‡‡‡fd#d$„}‡fd%d&„}‡fd'd(„}‡fd)d*„}i }ˆˆ||d+œ|tj	< ˆˆ||d+œ|tj
< ||| j| jd+œ|tj< ||| j| jd+œ|tj< ||| j| jd+œ|tj< ||| j| jd+œ|tj< |	|	d,œ|tj< |
|
d,œ|tj< ˆˆ||d+œ|tj< ˆˆ||d+œ|tj< ||||d+œ|tj< ||| j| jd+œ|tj< ||||d+œ|tj< ||| j| jd+œ|tj< |j|jd-œ|tj< |tj |tj< |j |j d-œ|tj!< |tj! |tj"< |S ).Nr   )Ú	cmathimplÚmathimpl©Ú_check_arity_and_homogeneity)Únp_complex_acosh_implÚnp_complex_cos_implÚnp_complex_sin_implc                    ó*   ˆ ||dƒ t | |jd ƒ}|||||ƒS )Né   r   )r   Úargs©ÚfnÚcontextÚbuilderÚsigr   Úimplr   r	   r
   Únp_unary_impl   ó   zufunc_db.<locals>.np_unary_implc                    r   )Né   r   )r   r   r   r   r	   r
   Únp_binary_impl"   r   z ufunc_db.<locals>.np_binary_implc                    ó   ˆ t j| |||ƒS r   )ÚmathÚsin©r   r   r   r   ©r   r	   r
   Únp_real_sin_impl'   ó   z"ufunc_db.<locals>.np_real_sin_implc                    r    r   )r!   Úcosr#   r$   r	   r
   Únp_real_cos_impl*   r&   z"ufunc_db.<locals>.np_real_cos_implc                    r    r   )r!   Útanr#   r$   r	   r
   Únp_real_tan_impl-   r&   z"ufunc_db.<locals>.np_real_tan_implc                    r    r   )r!   Úasinr#   r$   r	   r
   Únp_real_asin_impl0   r&   z#ufunc_db.<locals>.np_real_asin_implc                    r    r   )r!   Úacosr#   r$   r	   r
   Únp_real_acos_impl3   r&   z#ufunc_db.<locals>.np_real_acos_implc                    r    r   )r!   Úatanr#   r$   r	   r
   Únp_real_atan_impl6   r&   z#ufunc_db.<locals>.np_real_atan_implc                    r    r   )r!   Úatan2r#   ©r   r	   r
   Únp_real_atan2_impl9   r&   z$ufunc_db.<locals>.np_real_atan2_implc                    r    r   )r!   Úhypotr#   r2   r	   r
   Únp_real_hypot_impl<   r&   z$ufunc_db.<locals>.np_real_hypot_implc                    r    r   )r!   Úsinhr#   r$   r	   r
   Únp_real_sinh_impl?   r&   z#ufunc_db.<locals>.np_real_sinh_implc                    sº   ˆ ||dƒ |j d }|j}tj|gd Ž }|  |||d ¡}|  ||¡}|j}	|j}
ˆ| |||
gƒ}ˆ| |||	gƒ}ˆ| |||
gƒ}ˆ| |||	gƒ}| ||¡|_| ||¡|_| ¡ S ©Nr   r   r   ©	r   Úunderlying_floatr   Ú	signatureÚmake_complexÚrealÚimagÚfmulÚ	_getvalue)r   r   r   r   ÚtyÚftyÚfsig1ÚxÚoutÚxrÚxiÚsxiÚshxrÚcxiÚchxr©r   r(   Únp_real_cosh_implr%   r7   r	   r
   Únp_complex_sinh_implB   ó   
z&ufunc_db.<locals>.np_complex_sinh_implc                    r    r   )r!   Úcoshr#   r$   r	   r
   rM   Y   r&   z#ufunc_db.<locals>.np_real_cosh_implc                    sº   ˆ ||dƒ |j d }|j}tj|gd Ž }|  |||d ¡}|  ||¡}|j}	|j}
ˆ| |||
gƒ}ˆ| |||	gƒ}ˆ| |||
gƒ}ˆ| |||	gƒ}| ||¡|_| ||¡|_| ¡ S r8   r9   )r   r   r   r   rA   rB   rC   rD   rE   rF   rG   rJ   rK   rH   rI   rL   r	   r
   Únp_complex_cosh_impl\   rO   z&ufunc_db.<locals>.np_complex_cosh_implc                    r    r   )r!   Útanhr#   r$   r	   r
   Únp_real_tanh_impls   r&   z#ufunc_db.<locals>.np_real_tanh_implc                    sn  ˆ ||dƒ |j d }|j}tj|gd Ž }|  |d¡}|  |||d ¡}|  ||¡}	|j}
|j}ˆ| |||gƒ}ˆ| |||gƒ}ˆ| |||
gƒ}ˆ| |||
gƒ}| ||¡}| ||¡}| ||¡}| ||¡}| ||¡}| ||¡}| 	||¡}| 
||¡}| ||¡}| ||¡}| ||¡}| ||¡}| 	||¡}| ||¡}| ||¡|	_| ||¡|	_|	 ¡ S )Nr   r   r   g      ð?)r   r:   r   r;   Úget_constantr<   r=   r>   r?   ÚfaddÚfdivÚfsubr@   )r   r   r   r   rA   rB   rC   ÚONErD   rE   rF   rG   ÚsiÚciÚshrÚchr_ÚrsÚis_ÚrcÚicÚsqr_rcÚsqr_icÚdÚinv_dÚrs_rcÚis_icÚis_rcÚrs_icÚnumrÚnumirL   r	   r
   Únp_complex_tanh_implv   s<   
z&ufunc_db.<locals>.np_complex_tanh_implc                    r    r   )r!   Úasinhr#   r$   r	   r
   Únp_real_asinh_implœ   r&   z$ufunc_db.<locals>.np_real_asinh_implc                    r    r   )r!   Úacoshr#   r$   r	   r
   Únp_real_acosh_implŸ   r&   z$ufunc_db.<locals>.np_real_acosh_implc                    r    r   )r!   Úatanhr#   r$   r	   r
   Únp_real_atanh_impl¢   r&   z$ufunc_db.<locals>.np_real_atanh_impl)úf->fúd->dzF->FzD->D)zff->fzdd->d)rr   rs   )#Únumba.cpythonr   r   Únumba.np.npyfuncsr   r   r   r   Únpr"   r'   Útan_implr)   Ú	asin_implÚarcsinÚ	acos_implÚarccosÚ	atan_implÚarctanÚarctan2r4   r6   rP   rR   Ú
asinh_implÚarcsinhÚarccoshÚ
atanh_implÚarctanhÚradians_float_implÚdeg2radÚradiansÚdegrees_float_implÚrad2degÚdegrees)r   r   r   r   r   r*   r,   r.   r0   r3   r5   rN   rQ   rS   rk   rm   ro   rq   Údbr	   )r   r   r(   rM   r%   r7   r   r
   r      sÄ   &üüüüüüþþüüüüüüþþr   )Ú__doc__r!   Únumpyrv   Ú	functoolsr   Ú
numba.corer   Únumba.cuda.mathimplr   r   r   r   r	   r	   r	   r
   Ú<module>   s    