U
    Ã9%e]W  ã                   @   sT   d Z ddlZddlZddlmZ ddlmZ ddlm	Z	m
Z
 dd„ Zedd	„ ƒZdS )
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)Z	ufunc_key© r   úP/var/www/html/Darija-Ai-API/env/lib/python3.8/site-packages/numba/cuda/ufuncs.pyÚget_ufunc_info   s    r
   c                     sì  ddl m} m}m} ddlm‰ ddlm} ‡fdd„‰‡fdd„‰ ‡fd	d
„‰‡fdd„‰‡fdd„}‡fdd„}‡fdd„}‡fdd„}‡ fdd„}‡ fdd„}	‡fdd„‰‡‡‡‡‡fdd„}
‡fdd„‰‡‡‡‡‡fdd „}‡fd!d"„}‡‡‡‡‡fd#d$„}‡fd%d&„}‡fd'd(„}‡fd)d*„}i }ˆˆˆjˆjd+œ|t	j
< ˆˆˆjˆjd+œ|t	j< ||| j| jd+œ|t	j< ||| j| jd+œ|t	j< ||| j| jd+œ|t	j< ||| j| jd+œ|t	j< ||d,œ|t	j< |	|	d,œ|t	j< ˆˆ|
|
d+œ|t	j< ˆˆ||d+œ|t	j< ||||d+œ|t	j< ||| j| jd+œ|t	j< ||ˆjˆjd+œ|t	j< ||| j| jd+œ|t	j< |j |j d-œ|t	j!< |t	j! |t	j"< |j#|j#d-œ|t	j$< |t	j$ |t	j%< |j&|j'|j&|j'|j&|j'|j&|j'|j&|j'|j&|j(|j(ˆj)ˆj)d.œ|t	j*< |d/kr|t	j*  +| ,d0¡| -d0¡d1œ¡ |j.|j/|j.|j/|j.|j/|j.|j/|j.|j/|j.|j0|j0ˆj1ˆj1d.œ|t	j2< |d/kr|t	j2  +| ,d2¡| -d2¡d1œ¡ |j3|j4|j3|j4|j3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|je|je|jed9œ|t	jf< |jg|jg|jg|jg|jg|jg|jg|jg|jg|jg|jgd:œ|t	jh< |ji|ji|ji|ji|ji|ji|ji|ji|ji|jid;œ
|t	jj< |jk|jk|jk|jk|jk|jk|jk|jk|jk|jkd;œ
|t	jl< |S )<Nr   )Ú	cmathimplÚmathimplÚnumbers©Únpyfuncs)Únumpy_versionc                    s,   ˆ   ||d¡ t| |jd ƒ}|||||ƒS )Né   r   )Ú_check_arity_and_homogeneityr   Úargs©ÚfnÚcontextÚbuilderÚsigr   Úimplr   r   r	   Únp_unary_impl   s    zufunc_db.<locals>.np_unary_implc                    s,   ˆ   ||d¡ t| |jd ƒ}|||||ƒS )Né   r   )r   r   r   r   r   r   r	   Únp_binary_impl!   s    z ufunc_db.<locals>.np_binary_implc                    s   ˆ t j| |||ƒS r   )ÚmathÚsin©r   r   r   r   ©r   r   r	   Únp_real_sin_impl&   s    z"ufunc_db.<locals>.np_real_sin_implc                    s   ˆ t j| |||ƒS r   )r   Úcosr   r    r   r	   Únp_real_cos_impl)   s    z"ufunc_db.<locals>.np_real_cos_implc                    s   ˆ t j| |||ƒS r   )r   Útanr   r    r   r	   Únp_real_tan_impl,   s    z"ufunc_db.<locals>.np_real_tan_implc                    s   ˆ t j| |||ƒS r   )r   Úasinr   r    r   r	   Únp_real_asin_impl/   s    z#ufunc_db.<locals>.np_real_asin_implc                    s   ˆ t j| |||ƒS r   )r   Úacosr   r    r   r	   Únp_real_acos_impl2   s    z#ufunc_db.<locals>.np_real_acos_implc                    s   ˆ t j| |||ƒS r   )r   Úatanr   r    r   r	   Únp_real_atan_impl5   s    z#ufunc_db.<locals>.np_real_atan_implc                    s   ˆ t j| |||ƒS r   )r   Úatan2r   ©r   r   r	   Únp_real_atan2_impl8   s    z$ufunc_db.<locals>.np_real_atan2_implc                    s   ˆ t j| |||ƒS r   )r   Úhypotr   r-   r   r	   Únp_real_hypot_impl;   s    z$ufunc_db.<locals>.np_real_hypot_implc                    s   ˆ t j| |||ƒS r   )r   Úsinhr   r    r   r	   Únp_real_sinh_impl>   s    z#ufunc_db.<locals>.np_real_sinh_implc                    s¼   ˆ  ||d¡ |jd }|j}tj|gd Ž }|  |||d ¡}|  ||¡}|j}	|j}
ˆ| |||
gƒ}ˆ| |||	gƒ}ˆ | |||
gƒ}ˆ| |||	gƒ}| ||¡|_| ||¡|_| 	¡ S ©Nr   r   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#   Únp_real_cosh_implr!   r2   r   r   r	   Únp_complex_sinh_implA   s    
z&ufunc_db.<locals>.np_complex_sinh_implc                    s   ˆ t j| |||ƒS r   )r   Úcoshr   r    r   r	   rH   X   s    z#ufunc_db.<locals>.np_real_cosh_implc                    s¼   ˆ  ||d¡ |jd }|j}tj|gd Ž }|  |||d ¡}|  ||¡}|j}	|j}
ˆ | |||
gƒ}ˆ| |||	gƒ}ˆ| |||
gƒ}ˆ| |||	gƒ}| ||¡|_| ||¡|_| 	¡ S r3   r4   )r   r   r   r   r<   r=   r>   r?   r@   rA   rB   rE   rF   rC   rD   rG   r   r	   Únp_complex_cosh_impl[   s    
z&ufunc_db.<locals>.np_complex_cosh_implc                    s   ˆ t j| |||ƒS r   )r   Útanhr   r    r   r	   Únp_real_tanh_implr   s    z#ufunc_db.<locals>.np_real_tanh_implc                    sp  ˆ  ||d¡ |jd }|j}tj|gd Ž }|  |d¡}|  |||d ¡}|  ||¡}	|j}
|j}ˆ| |||gƒ}ˆ | |||gƒ}ˆ| |||
gƒ}ˆ| |||
gƒ}| 	||¡}| 	||¡}| 	||¡}| 	||¡}| 	||¡}| 	||¡}| 
||¡}| ||¡}| 	||¡}| 	||¡}| 	||¡}| 	||¡}| 
||¡}| ||¡}| 	||¡|	_| 	||¡|	_|	 ¡ S )Nr   r   r   g      ð?)r   r   r5   r   r6   Zget_constantr7   r8   r9   r:   ZfaddZfdivZfsubr;   )r   r   r   r   r<   r=   r>   ZONEr?   r@   rA   rB   ÚsiÚciZshrZchr_ÚrsÚis_ÚrcZicZsqr_rcZsqr_icÚdZinv_dZrs_rcZis_icZis_rcZrs_icZnumrZnumirG   r   r	   Únp_complex_tanh_implu   s<    
z&ufunc_db.<locals>.np_complex_tanh_implc                    s   ˆ t j| |||ƒS r   )r   Úasinhr   r    r   r	   Únp_real_asinh_impl›   s    z$ufunc_db.<locals>.np_real_asinh_implc                    s   ˆ t j| |||ƒS r   )r   Úacoshr   r    r   r	   Únp_real_acosh_implž   s    z$ufunc_db.<locals>.np_real_acosh_implc                    s   ˆ t j| |||ƒS r   )r   Úatanhr   r    r   r	   Únp_real_atanh_impl¡   s    z$ufunc_db.<locals>.np_real_atanh_impl)úf->fúd->dzF->FzD->D)úff->fúdd->d)r[   r\   )ú??->?zbb->?zBB->?zhh->?zHH->?zii->?zII->?zll->?zLL->?zqq->?zQQ->?zff->?zdd->?zFF->?zDD->?)r   é   ú>)zqQ->?zQq->?z>=ú<z<=z!=z==)ú?->?zb->?zB->?zh->?zH->?zi->?zI->?zl->?zL->?zq->?zQ->?zf->?zd->?zF->?zD->?)r_   úbb->búBB->Búhh->húHH->Húii->iúII->Iúll->lúLL->Lúqq->qúQQ->Qr]   r^   zFF->FzDD->D)r_   rd   re   rf   rg   rh   ri   rj   rk   rl   rm   )rc   zb->bzB->Bzh->hzH->Hzi->izI->Izl->lzL->Lzq->qzQ->Q)
rd   re   rf   rg   rh   ri   rj   rk   rl   rm   )mZnumba.cpythonr   r   r   Znumba.npr   Znumba.np.numpy_supportr   Znp_complex_sin_implÚnpr   Znp_complex_cos_implr"   Ztan_implr$   Z	asin_implZarcsinZ	acos_implZarccosZ	atan_implZarctanZarctan2r/   r1   rJ   rL   Z
asinh_implZarcsinhZnp_complex_acosh_implZarccoshZ
atanh_implZarctanhZradians_float_implZdeg2radÚradiansZdegrees_float_implZrad2degÚdegreesZint_ugt_implZint_sgt_implZreal_gt_implZnp_complex_gt_implZgreaterÚupdateZint_signed_unsigned_cmpZint_unsigned_signed_cmpZint_uge_implZint_sge_implZreal_ge_implZnp_complex_ge_implZgreater_equalZint_ult_implZint_slt_implZreal_lt_implZnp_complex_lt_implÚlessZint_ule_implZint_sle_implZreal_le_implZnp_complex_le_implZ
less_equalZint_ne_implZreal_ne_implZnp_complex_ne_implÚ	not_equalZint_eq_implZreal_eq_implZnp_complex_eq_implÚequalZnp_logical_and_implZnp_complex_logical_and_implÚlogical_andZnp_logical_or_implZnp_complex_logical_or_implÚ
logical_orZnp_logical_xor_implZnp_complex_logical_xor_implÚlogical_xorZnp_logical_not_implZnp_complex_logical_not_implZlogical_notZnp_int_smax_implZnp_int_umax_implZnp_real_maximum_implZnp_complex_maximum_implÚmaximumZnp_int_smin_implZnp_int_umin_implZnp_real_minimum_implZnp_complex_minimum_implÚminimumZnp_real_fmax_implZnp_complex_fmax_implZfmaxZnp_real_fmin_implZnp_complex_fmin_implZfminZint_and_implZbitwise_andZint_or_implZ
bitwise_orZint_xor_implZbitwise_xorZint_invert_implÚinvertZint_shl_implZ
left_shiftZint_shr_implZright_shift)r   r   r   r   r%   r'   r)   r+   r.   r0   rI   rK   rM   rT   rV   rX   rZ   Údbr   )r   r#   rH   r!   r2   r   r   r	   r      sL   &üüüüüüþþüüüüüüþþñ

þñ

þñ

þñ

þñ

þñ

þññññññññõõõõöör   )Ú__doc__r   Únumpyrn   Ú	functoolsr   Z
numba.corer   Znumba.cuda.mathimplr   r   r
   r   r   r   r   r	   Ú<module>   s   