U
    ?h]W                     @   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)Z	ufunc_key r   C/var/www/html/venv/lib/python3.8/site-packages/numba/cuda/ufuncs.pyget_ufunc_info   s    r
   c                     s  ddl m} m}m} ddlm ddl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 }jjd+|t	j
< j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< ||j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%< |j&|j'|j&|j'|j&|j'|j&|j'|j&|j'|j&|j(|j(j)j)d.|t	j*< |d/kr|t	j* +|,d0|-d0d1 |j.|j/|j.|j/|j.|j/|j.|j/|j.|j/|j.|j0|j0j1j1d.|t	j2< |d/kr|t	j2 +|,d2|-d2d1 |j3|j4|j3|j4|j3|j4|j3|j4|j3|j4|j3|j5|j5j6j6d.|t	j7< |d/kr|t	j7 +|,d3|-d3d1 |j8|j9|j8|j9|j8|j9|j8|j9|j8|j9|j8|j:|j:j;j;d.|t	j<< |d/krx|t	j< +|,d4|-d4d1 |j=|j=|j=|j=|j=|j=|j=|j=|j=|j=|j=|j>|j>j?j?d.|t	j@< |d/kr|t	j@ +|,d5|-d5d1 |jA|jA|jA|jA|jA|jA|jA|jA|jA|jA|jA|jB|jBjCjCd.|t	jD< |d/kr`|t	jD +|,d6|-d6d1 jEjEjEjEjEjEjEjEjEjEjEjEjEjFjFd.|t	jG< jHjHjHjHjHjHjHjHjHjHjHjHjHjIjId.|t	jJ< jKjKjKjKjKjKjKjKjKjKjKjKjKjLjLd.|t	jM< jNjNjNjNjNjNjNjNjNjNjNjNjNjOjOd7|t	jP< jHjQjRjQjRjQjRjQjRjQjRjSjSjTjTd8|t	jU< jEjVjWjVjWjVjWjVjWjVjWjXjXjYjYd8|t	jZ< jHjQjRjQjRjQjRjQjRjQjRj[j[j\j\d8|t	j]< jEjVjWjVjWjVjWjVjWjVjWj^j^j_j_d8|t	j`< |ja|ja|ja|ja|ja|ja|ja|ja|ja|ja|jad9|t	jb< |jc|jc|jc|jc|jc|jc|jc|jc|jc|jc|jcd9|t	jd< |je|je|je|je|je|je|je|je|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| |jd }|||||S )N   r   )_check_arity_and_homogeneityr   argsfncontextbuildersigr   implr   r   r	   np_unary_impl   s    zufunc_db.<locals>.np_unary_implc                    s,     ||d t| |jd }|||||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 |jd }|j}tj|gd  }| |||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 |jd }|j}tj|gd  }| |||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 |jd }|j}tj|gd  }| |d}| |||d }| ||}	|j}
|j}| |||g} | |||g}| |||
g}| |||
g}|	||}|	||}|	||}|	||}|	||}|	||}|
||}|||}|	||}|	||}|	||}|	||}|
||}|||}|	|||	_|	|||	_|	 S )Nr   r   r   g      ?)r   r   r5   r   r6   Zget_constantr7   r8   r9   r:   ZfaddZfdivZfsubr;   )r   r   r   r   r<   r=   r>   ZONEr?   r@   rA   rB   siciZshrZchr_rsis_rcZicZsqr_rcZsqr_icdZinv_dZrs_rcZis_icZis_rcZrs_icZnumrZnumirG   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->dzF->FzD->D)ff->fdd->d)r[   r\   )??->?zbb->?zBB->?zhh->?zHH->?zii->?zII->?zll->?zLL->?zqq->?zQQ->?zff->?zdd->?zFF->?zDD->?)r      >)zqQ->?zQq->?z>=<z<=z!=z==)?->?zb->?zB->?zh->?zH->?zi->?zI->?zl->?zL->?zq->?zQ->?zf->?zd->?zF->?zD->?)r_   bb->bBB->Bhh->hHH->Hii->iII->Ill->lLL->Lqq->qQQ->Qr]   r^   zFF->FzDD->D)r_   rd   re   rf   rg   rh   ri   rj   rk   rl   rm   )rc   zb->bzB->Bzh->hzH->Hzi->izI->Izl->lzL->Lzq->qzQ->Q)
rd   re   rf   rg   rh   ri   rj   rk   rl   rm   )mZnumba.cpythonr   r   r   Znumba.npr   Znumba.np.numpy_supportr   Znp_complex_sin_implnpr   Znp_complex_cos_implr"   Ztan_implr$   Z	asin_implZarcsinZ	acos_implZarccosZ	atan_implZarctanZarctan2r/   r1   rJ   rL   Z
asinh_implZarcsinhZnp_complex_acosh_implZarccoshZ
atanh_implZarctanhZradians_float_implZdeg2radradiansZdegrees_float_implZrad2degdegreesZint_ugt_implZint_sgt_implZreal_gt_implZnp_complex_gt_implZgreaterupdateZint_signed_unsigned_cmpZint_unsigned_signed_cmpZint_uge_implZint_sge_implZreal_ge_implZnp_complex_ge_implZgreater_equalZint_ult_implZint_slt_implZreal_lt_implZnp_complex_lt_impllessZint_ule_implZint_sle_implZreal_le_implZnp_complex_le_implZ
less_equalZint_ne_implZreal_ne_implZnp_complex_ne_impl	not_equalZint_eq_implZreal_eq_implZnp_complex_eq_implequalZnp_logical_and_implZnp_complex_logical_and_impllogical_andZnp_logical_or_implZnp_complex_logical_or_impl
logical_orZnp_logical_xor_implZnp_complex_logical_xor_impllogical_xorZnp_logical_not_implZnp_complex_logical_not_implZlogical_notZnp_int_smax_implZnp_int_umax_implZnp_real_maximum_implZnp_complex_maximum_implmaximumZnp_int_smin_implZnp_int_umin_implZnp_real_minimum_implZnp_complex_minimum_implminimumZnp_real_fmax_implZnp_complex_fmax_implZfmaxZnp_real_fmin_implZnp_complex_fmin_implZfminZint_and_implZbitwise_andZint_or_implZ
bitwise_orZint_xor_implZbitwise_xorZint_invert_implinvertZint_shl_implZ
left_shiftZint_shr_implZright_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   Znumba.cuda.mathimplr   r   r
   r   r   r   r   r	   <module>   s   