U
    hâËdÛk  ã                   @   sÊ  d dl Zd dlmZmZmZmZmZ d dlm	Z	 d dl
mZmZmZmZmZmZmZ d dl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#d'd(„ Z$d)d*„ Z%d+d,„ Z&d-d.„ Z'd/d0„ Z(d1d2„ Z)d3d4„ Z*d5d6„ Z+d7d8„ Z,d9d:„ Z-d;d<„ Z.d=d>„ Z/d?d@„ Z0dAdB„ Z1dCdD„ Z2dEdF„ Z3dGdH„ Z4dIdJ„ Z5dKdL„ Z6dMdN„ Z7dOdP„ Z8dQdR„ Z9dSdT„ Z:dUdV„ Z;G dWdX„ dXeƒZ<e=dYk�rÆe >¡  dS )Zé    N)Úskip_unless_cc_53Úskip_unless_cuda_pythonÚunittestÚCUDATestCaseÚskip_on_cudasim)Únumpy_support)ÚcudaÚfloat32Úfloat64Úint32Ú	vectorizeÚvoidÚint64c                 C   s    t  d¡}t | | ¡||< d S ©Né   )r   ÚgridÚmathÚacos©ÚAÚBÚi© r   úZ/home/sam/Atlas/atlas_env/lib/python3.8/site-packages/numba/cuda/tests/cudapy/test_math.pyÚ	math_acos   s    
r   c                 C   s    t  d¡}t | | ¡||< d S r   )r   r   r   Úasinr   r   r   r   Ú	math_asin   s    
r   c                 C   s    t  d¡}t | | ¡||< d S r   )r   r   r   Úatanr   r   r   r   Ú	math_atan   s    
r   c                 C   s    t  d¡}t | | ¡||< d S r   )r   r   r   Úacoshr   r   r   r   Ú
math_acosh   s    
r    c                 C   s    t  d¡}t | | ¡||< d S r   )r   r   r   Úasinhr   r   r   r   Ú
math_asinh    s    
r"   c                 C   s    t  d¡}t | | ¡||< d S r   )r   r   r   Úatanhr   r   r   r   Ú
math_atanh%   s    
r$   c                 C   s    t  d¡}t | | ¡||< d S r   )r   r   r   Úcosr   r   r   r   Úmath_cos*   s    
r&   c                 C   s    t  d¡}t | | ¡||< d S r   )r   r   r   Úsinr   r   r   r   Úmath_sin/   s    
r(   c                 C   s    t  d¡}t | | ¡||< d S r   )r   r   r   Útanr   r   r   r   Úmath_tan4   s    
r*   c                 C   s    t  d¡}t | | ¡||< d S r   )r   r   r   Úcoshr   r   r   r   Ú	math_cosh9   s    
r,   c                 C   s    t  d¡}t | | ¡||< d S r   )r   r   r   Úsinhr   r   r   r   Ú	math_sinh>   s    
r.   c                 C   s    t  d¡}t | | ¡||< d S r   )r   r   r   Útanhr   r   r   r   Ú	math_tanhC   s    
r0   c                 C   s&   t  d¡}t | | || ¡||< d S r   )r   r   r   Úatan2©r   r   ÚCr   r   r   r   Ú
math_atan2H   s    
r4   c                 C   s    t  d¡}t | | ¡||< d S r   )r   r   r   Úexpr   r   r   r   Úmath_expM   s    
r6   c                 C   s    t  d¡}t | | ¡||< d S r   )r   r   r   Úerfr   r   r   r   Úmath_erfR   s    
r8   c                 C   s    t  d¡}t | | ¡||< d S r   )r   r   r   Úerfcr   r   r   r   Ú	math_erfcW   s    
r:   c                 C   s    t  d¡}t | | ¡||< d S r   )r   r   r   Úexpm1r   r   r   r   Ú
math_expm1\   s    
r<   c                 C   s    t  d¡}t | | ¡||< d S r   )r   r   r   Úfabsr   r   r   r   Ú	math_fabsa   s    
r>   c                 C   s    t  d¡}t | | ¡||< d S r   )r   r   r   Úgammar   r   r   r   Ú
math_gammaf   s    
r@   c                 C   s    t  d¡}t | | ¡||< d S r   )r   r   r   Úlgammar   r   r   r   Úmath_lgammak   s    
rB   c                 C   s    t  d¡}t | | ¡||< d S r   )r   r   r   Úlogr   r   r   r   Úmath_logp   s    
rD   c                 C   s    t  d¡}t | | ¡||< d S r   )r   r   r   Úlog2r   r   r   r   Ú	math_log2u   s    
rF   c                 C   s    t  d¡}t | | ¡||< d S r   )r   r   r   Úlog10r   r   r   r   Ú
math_log10z   s    
rH   c                 C   s    t  d¡}t | | ¡||< d S r   )r   r   r   Úlog1pr   r   r   r   Ú
math_log1p   s    
rJ   c                 C   s&   t  d¡}t | | || ¡||< d S r   )r   r   r   Ú	remainderr2   r   r   r   Úmath_remainder„   s    
rL   c                 C   s    t  d¡}t | | ¡||< d S r   )r   r   r   Úsqrtr   r   r   r   Ú	math_sqrt‰   s    
rN   c                 C   s&   t  d¡}t | | || ¡||< d S r   )r   r   r   Úhypotr2   r   r   r   Ú
math_hypotŽ   s    
rP   c                 C   s&   t  d¡}t | | || ¡||< d S r   )r   r   r   Úpowr2   r   r   r   Úmath_pow“   s    
rR   c                 C   s    t  d¡}t | | ¡||< d S r   )r   r   r   Úceilr   r   r   r   Ú	math_ceil˜   s    
rT   c                 C   s    t  d¡}t | | ¡||< d S r   )r   r   r   Úfloorr   r   r   r   Ú
math_floor�   s    
rV   c                 C   s&   t  d¡}t | | || ¡||< d S r   )r   r   r   Úcopysignr2   r   r   r   Úmath_copysign¢   s    
rX   c                 C   s&   t  d¡}t | | || ¡||< d S r   )r   r   r   Úfmodr2   r   r   r   Ú	math_fmod§   s    
rZ   c                 C   s(   t  d¡}t | | ¡\||< ||< d S r   )r   r   r   Úmodfr2   r   r   r   Ú	math_modf¬   s    
r\   c                 C   s    t  d¡}t | | ¡||< d S r   )r   r   r   Úisnanr   r   r   r   Ú
math_isnan±   s    
r^   c                 C   s    t  d¡}t | | ¡||< d S r   )r   r   r   Úisinfr   r   r   r   Ú
math_isinf¶   s    
r`   c                 C   s    t  d¡}t | | ¡||< d S r   )r   r   r   Úisfiniter   r   r   r   Úmath_isfinite»   s    
rb   c                 C   s    t  d¡}t | | ¡||< d S r   )r   r   r   Údegreesr   r   r   r   Úmath_degreesÀ   s    
rd   c                 C   s    t  d¡}t | | ¡||< d S r   )r   r   r   Úradiansr   r   r   r   Úmath_radiansÅ   s    
rf   c                 C   s    t  d¡}t | | ¡||< d S r   )r   r   r   Útruncr   r   r   r   Ú
math_truncÊ   s    
rh   c                 C   s"   t  d¡}| | ||  ||< d S r   ©r   r   r2   r   r   r   Úmath_pow_binopÏ   s    
rj   c                 C   s"   t  d¡}| | ||  ||< d S r   ri   r2   r   r   r   Úmath_mod_binopÔ   s    
rk   c                   @   sB  e Zd Zd‰dd„ZdŠdd„Zd‹dd„ZdŒd
d„Zd�dd„Zdd„ Zdd„ Z	dd„ Z
dd„ ZdŽdd„Zd�dd„Zd�dd„Zd‘dd„Zdd „ Zd’d!d"„Zd“d#d$„Zd”d%d&„Zd•d'd(„Zd)d*„ Zd+d,„ Zd-d.„ Zd/d0„ Zd1d2„ Zd3d4„ Zd5d6„ Zd7d8„ Zeed9ƒ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„ Z+dTdU„ Z,dVdW„ Z-dXdY„ Z.dZd[„ Z/d\d]„ Z0d^d_„ Z1e2d`ƒdadb„ ƒZ3dcdd„ Z4dedf„ Z5dgdh„ Z6didj„ Z7dkdl„ Z8dmdn„ Z9dodp„ Z:dqdr„ Z;e2dsƒdtdu„ ƒZ<dvdw„ Z=dxdy„ Z>dzd{„ Z?d|d}„ Z@d~d„ ZAd€d�„ ZBd‚dƒ„ ZCd„d…„ ZDd†d‡„ ZEdˆS )–ÚTestCudaMathr   r   c                 C   s   |   ||tjtj||¡ d S ©N)Úunary_templateÚnpZfloat16©ÚselfÚfuncÚnpfuncÚstartÚstopr   r   r   Úunary_template_float16Ú   s    z#TestCudaMath.unary_template_float16c                 C   s   |   ||tjtj||¡ d S rm   ©rn   ro   r	   rp   r   r   r   Úunary_template_float32Ý   s    z#TestCudaMath.unary_template_float32c                 C   s   |   ||tjtj||¡ d S rm   ©rn   ro   r
   rp   r   r   r   Úunary_template_float64à   s    z#TestCudaMath.unary_template_float64é2   c                 C   s   |   ||tjtj||¡ d S rm   )rn   ro   r   r
   rp   r   r   r   Úunary_template_int64ã   s    z!TestCudaMath.unary_template_int64c                 C   s   |   ||tjtj||¡ d S rm   )rn   ro   Úuint64r
   rp   r   r   r   Úunary_template_uint64æ   s    z"TestCudaMath.unary_template_uint64c                 C   s²   d}t  |||¡ |¡}t  |¡ |¡}	t |¡d d d… }
t |¡d d d… }t |
|f¡|ƒ}|d|f ||	ƒ |t jkr„d}n|t j	kr”d}nd}t j
j||ƒ|	|d� d S )Nr{   r   g‚vIhÂ%<=ç�íµ ÷Æ°>gü©ñÒMbP?©Úrtol)ro   ÚlinspaceÚastypeÚ
empty_liker   Ú
from_dtyper   Újitr
   r	   ÚtestingÚassert_allclose)rq   rr   rs   ÚnpdtypeÚ	nprestypert   ru   Únelemr   r   ÚarytypeÚrestypeÚcfuncr�   r   r   r   rn   é   s    

zTestCudaMath.unary_templatec           
   	   C   sÄ   t  |¡}|jd }t jd||jdd|jt jt jg|d�}t j|t jd�}t	 
|d d d… td d d… f¡|ƒ}	|	d|jf ||ƒ t j |||ƒ¡ |	d|jf | |ƒ t j ||| ƒ¡ d S )Né   g        g      à?g      ð?©Údtyper   )ro   ZfinfoZtinyÚarrayÚmaxÚinfÚnanr„   r   r   r†   Úsizer‡   Zassert_array_equal)
rq   rr   rs   r‰   ÚnpmtypeÚfiZdenormr   r   rŽ   r   r   r   Úunary_bool_special_valuesþ   s    

ÿ&z&TestCudaMath.unary_bool_special_valuesc                 C   s   |   ||tjt¡ d S rm   )r™   ro   r	   ©rq   rr   rs   r   r   r   Ú!unary_bool_special_values_float32  s    z.TestCudaMath.unary_bool_special_values_float32c                 C   s   |   ||tjt¡ d S rm   )r™   ro   r
   rš   r   r   r   Ú!unary_bool_special_values_float64  s    z.TestCudaMath.unary_bool_special_values_float64c                 C   s   |   ||tjtj||¡ d S rm   rw   rp   r   r   r   Úunary_bool_template_float32  s    z(TestCudaMath.unary_bool_template_float32c                 C   s   |   ||tjtj||¡ d S rm   ry   rp   r   r   r   Úunary_bool_template_float64  s    z(TestCudaMath.unary_bool_template_float64é1   c                 C   s   |   ||tjtj||¡ d S rm   )rn   ro   r   rp   r   r   r   Úunary_bool_template_int32  s    z&TestCudaMath.unary_bool_template_int32c                 C   s   |   ||tjtj||¡ d S rm   )rn   ro   r   rp   r   r   r   Úunary_bool_template_int64  s    z&TestCudaMath.unary_bool_template_int64c                 C   s€   d}t  |||¡ |¡}t j|jt jd�}	|d d d… }
td d d… }t |
|f¡|ƒ}|d|f ||	ƒ t j 	||ƒ|	¡ d S )Nr{   r�   r   )
ro   r‚   rƒ   ÚemptyÚshaper   r   r†   r‡   rˆ   )rq   rr   rs   r‰   r—   rt   ru   r‹   r   r   ZiarytypeZoarytyperŽ   r   r   r   Úunary_bool_template  s    z TestCudaMath.unary_bool_templatec                 C   s   |   ||tjtj||¡ d S rm   )Úbinary_templatero   r	   rp   r   r   r   Úbinary_template_float32(  s    z$TestCudaMath.binary_template_float32c                 C   s   |   ||tjtj||¡ d S rm   )r¥   ro   r
   rp   r   r   r   Úbinary_template_float64+  s    z$TestCudaMath.binary_template_float64c                 C   s   |   ||tjtj||¡ d S rm   )r¥   ro   r   r
   rp   r   r   r   Úbinary_template_int64.  s    z"TestCudaMath.binary_template_int64c                 C   s   |   ||tjtj||¡ d S rm   )r¥   ro   r}   r
   rp   r   r   r   Úbinary_template_uint641  s    z#TestCudaMath.binary_template_uint64c                 C   s�   d}t  |||¡ |¡}t  |¡ |¡}	t |¡d d d… }
t |¡d d d… }t |
|
|f¡|ƒ}|d|f |||	ƒ t j 	|||ƒ|	¡ d S )Nr{   r   )
ro   r‚   rƒ   r„   r   r…   r   r†   r‡   rˆ   )rq   rr   rs   r‰   rŠ   rt   ru   r‹   r   r   rŒ   r�   rŽ   r   r   r   r¥   4  s    zTestCudaMath.binary_templatec                 C   sH   |   ttj¡ |  ttj¡ | jttjddd� | jttjddd� d S ©Nr   ©rt   ru   )rx   r   ro   Zarccosrz   r|   r~   ©rq   r   r   r   Útest_math_acosA  s    zTestCudaMath.test_math_acosc                 C   sH   |   ttj¡ |  ttj¡ | jttjddd� | jttjddd� d S rª   )rx   r   ro   Zarcsinrz   r|   r~   r¬   r   r   r   Útest_math_asinL  s    zTestCudaMath.test_math_asinc                 C   s<   |   ttj¡ |  ttj¡ |  ttj¡ |  ttj¡ d S rm   )rx   r   ro   Zarctanrz   r|   r~   r¬   r   r   r   Útest_math_atanW  s    zTestCudaMath.test_math_atanc                 C   sT   | j ttjddd� | jttjddd� | jttjddd� | jttjddd� d S )Nr   é   r«   )rx   r    ro   Zarccoshrz   r|   r~   r¬   r   r   r   Útest_math_acosh`  s    zTestCudaMath.test_math_acoshc                 C   s<   |   ttj¡ |  ttj¡ |  ttj¡ |  ttj¡ d S rm   )rx   r"   ro   Zarcsinhrz   r|   r~   r¬   r   r   r   Útest_math_asinhi  s    zTestCudaMath.test_math_asinhc                 C   sT   | j ttjddd� | jttjddd� | jttjddd� | jttjddd� d S )Nr   gÍÌÌÌÌÌì?r«   )rx   r$   ro   Zarctanhrz   r|   r~   r¬   r   r   r   Útest_math_atanhr  s    zTestCudaMath.test_math_atanhc                 C   s<   |   ttj¡ |  ttj¡ |  ttj¡ |  ttj¡ d S rm   )rx   r&   ro   r%   rz   r|   r~   r¬   r   r   r   Útest_math_cos{  s    zTestCudaMath.test_math_coszNVIDIA Binding needed for NVRTCc                 C   s®   |   ttj¡ |   ttj¡ |   ttj¡ | j ttj	dd� | j t
tjdd� | j ttjdd� | j ttjdd� |   ttj¡ |   ttj¡ |   ttj¡ |   ttj¡ d S )Nr   ©rt   éÿÿÿÿ)rv   r(   ro   r'   r&   r%   r6   r5   rD   rC   rF   rE   rH   rG   r>   r=   rN   rM   rT   rS   rV   rU   rh   rg   r¬   r   r   r   Útest_math_fp16�  s    zTestCudaMath.test_math_fp16c                 C   s<   |   ttj¡ |  ttj¡ |  ttj¡ |  ttj¡ d S rm   )rx   r(   ro   r'   rz   r|   r~   r¬   r   r   r   Útest_math_sin“  s    zTestCudaMath.test_math_sinc                 C   s<   |   ttj¡ |  ttj¡ |  ttj¡ |  ttj¡ d S rm   )rx   r*   ro   r)   rz   r|   r~   r¬   r   r   r   Útest_math_tanœ  s    zTestCudaMath.test_math_tanc                 C   s<   |   ttj¡ |  ttj¡ |  ttj¡ |  ttj¡ d S rm   )rx   r,   ro   r+   rz   r|   r~   r¬   r   r   r   Útest_math_cosh¥  s    zTestCudaMath.test_math_coshc                 C   s<   |   ttj¡ |  ttj¡ |  ttj¡ |  ttj¡ d S rm   )rx   r.   ro   r-   rz   r|   r~   r¬   r   r   r   Útest_math_sinh®  s    zTestCudaMath.test_math_sinhc                 C   s<   |   ttj¡ |  ttj¡ |  ttj¡ |  ttj¡ d S rm   )rx   r0   ro   r/   rz   r|   r~   r¬   r   r   r   Útest_math_tanh·  s    zTestCudaMath.test_math_tanhc                 C   s<   |   ttj¡ |  ttj¡ |  ttj¡ |  ttj¡ d S rm   )r¦   r4   ro   Zarctan2r§   r¨   r©   r¬   r   r   r   Útest_math_atan2À  s    zTestCudaMath.test_math_atan2c                 C   s@   t dd„ ƒ}|  t|¡ |  t|¡ |  t|¡ |  t|¡ d S )Nc                 S   s
   t  | ¡S rm   )r   r7   ©Úxr   r   r   ÚufuncÊ  s    z)TestCudaMath.test_math_erf.<locals>.ufunc)r   rx   r8   rz   r|   r~   ©rq   rÀ   r   r   r   Útest_math_erfÉ  s    
zTestCudaMath.test_math_erfc                 C   s@   t dd„ ƒ}|  t|¡ |  t|¡ |  t|¡ |  t|¡ d S )Nc                 S   s
   t  | ¡S rm   )r   r9   r¾   r   r   r   rÀ   Ö  s    z*TestCudaMath.test_math_erfc.<locals>.ufunc)r   rx   r:   rz   r|   r~   rÁ   r   r   r   Útest_math_erfcÕ  s    
zTestCudaMath.test_math_erfcc                 C   s<   |   ttj¡ |  ttj¡ |  ttj¡ |  ttj¡ d S rm   )rx   r6   ro   r5   rz   r|   r~   r¬   r   r   r   Útest_math_expá  s    zTestCudaMath.test_math_expc                 C   s<   |   ttj¡ |  ttj¡ |  ttj¡ |  ttj¡ d S rm   )rx   r<   ro   r;   rz   r|   r~   r¬   r   r   r   Útest_math_expm1ê  s    zTestCudaMath.test_math_expm1c                 C   sL   | j ttjdd� | jttjdd� | jttjdd� | jttjdd� d S ©Nr¶   rµ   )rx   r>   ro   r=   rz   r|   r~   r¬   r   r   r   Útest_math_fabsó  s    zTestCudaMath.test_math_fabsc                 C   sP   t dd„ ƒ}| jt|dd� | jt|dd� | jt|dd� | jt|dd� d S )Nc                 S   s
   t  | ¡S rm   )r   r?   r¾   r   r   r   rÀ   ý  s    z+TestCudaMath.test_math_gamma.<locals>.ufuncçš™™™™™¹?rµ   r   )r   rx   r@   rz   r|   r~   rÁ   r   r   r   Útest_math_gammaü  s    
zTestCudaMath.test_math_gammac                 C   sP   t dd„ ƒ}| jt|dd� | jt|dd� | jt|dd� | jt|dd� d S )Nc                 S   s
   t  | ¡S rm   )r   rA   r¾   r   r   r   rÀ   	  s    z,TestCudaMath.test_math_lgamma.<locals>.ufuncrÈ   rµ   r   )r   rx   rB   rz   r|   r~   rÁ   r   r   r   Útest_math_lgamma  s    
zTestCudaMath.test_math_lgammac                 C   sL   | j ttjdd� | jttjdd� | jttjdd� | jttjdd� d S ©Nr   rµ   )rx   rD   ro   rC   rz   r|   r~   r¬   r   r   r   Útest_math_log  s    zTestCudaMath.test_math_logc                 C   sL   | j ttjdd� | jttjdd� | jttjdd� | jttjdd� d S rË   )rx   rF   ro   rE   rz   r|   r~   r¬   r   r   r   Útest_math_log2  s    zTestCudaMath.test_math_log2c                 C   sL   | j ttjdd� | jttjdd� | jttjdd� | jttjdd� d S rË   )rx   rH   ro   rG   rz   r|   r~   r¬   r   r   r   Útest_math_log10&  s    zTestCudaMath.test_math_log10c                 C   s<   |   ttj¡ |  ttj¡ |  ttj¡ |  ttj¡ d S rm   )rx   rJ   ro   rI   rz   r|   r~   r¬   r   r   r   Útest_math_log1p/  s    zTestCudaMath.test_math_log1pc                 C   sL   | j ttjdd� | jttjdd� | jttjdd� | jttjdd� d S )Ng•dyáý¥=rµ   r   )r¦   rL   ro   rK   r§   r¨   r©   r¬   r   r   r   Útest_math_remainder8  s    z TestCudaMath.test_math_remainderz3math.remainder(0, 0) raises a ValueError on CUDASimc                 C   sZ   t  ttd d d… ttƒ¡dd„ ƒ}t dtj¡}|d |ddƒ |  t |d ¡¡ d S )Nr   c                 S   s   t  ||¡| d< d S )Nr   )r   rK   )Úrr¿   Úyr   r   r   Útest_0_0@  s    z6TestCudaMath.test_math_remainder_0_0.<locals>.test_0_0)r   r   r   )	r   r†   r   r
   r   ro   ZzerosÚ
assertTruer]   )rq   rÓ   rÑ   r   r   r   Útest_math_remainder_0_0>  s
    
z$TestCudaMath.test_math_remainder_0_0c                 C   s<   |   ttj¡ |  ttj¡ |  ttj¡ |  ttj¡ d S rm   )rx   rN   ro   rM   rz   r|   r~   r¬   r   r   r   Útest_math_sqrtJ  s    zTestCudaMath.test_math_sqrtc                 C   s<   |   ttj¡ |  ttj¡ |  ttj¡ |  ttj¡ d S rm   )r¦   rP   ro   rO   r§   r¨   r©   r¬   r   r   r   Útest_math_hypotS  s    zTestCudaMath.test_math_hypotc           
      C   sÐ   d}t  dd|¡ |¡}t j|t jd�}t  |¡}t |¡d d d… }t 	|td d d… |f¡t
ƒ}|d|f |||ƒ t  |¡}tt|ƒƒD ]}	t ||	 ||	 ¡||	< qŽt jjt  ||¡ |¡|dd� d S )Nr{   r   é   r�   r   r   r€   )ro   r‚   rƒ   Zaranger   r„   r   r…   r   r†   rR   ÚrangeÚlenr   rQ   r‡   rˆ   Úpower)
rq   r‰   r‹   r   r   r3   rŒ   rŽ   ZCrefr   r   r   r   Úpow_template_int32\  s    

zTestCudaMath.pow_template_int32c                 C   s8   |   ttj¡ |  ttj¡ |  tj¡ |  tj¡ d S rm   )r¦   rR   ro   rÛ   r§   rÜ   r	   r
   r¬   r   r   r   Útest_math_powm  s    zTestCudaMath.test_math_powc                 C   s    |   ttj¡ |  ttj¡ d S rm   )r¦   rj   ro   rÛ   r§   r¬   r   r   r   Útest_math_pow_binopv  s    z TestCudaMath.test_math_pow_binopc                 C   s<   |   ttj¡ |  ttj¡ |  ttj¡ |  ttj¡ d S rm   )rx   rT   ro   rS   rz   r|   r~   r¬   r   r   r   Útest_math_ceil}  s    zTestCudaMath.test_math_ceilc                 C   s<   |   ttj¡ |  ttj¡ |  ttj¡ |  ttj¡ d S rm   )rx   rV   ro   rU   rz   r|   r~   r¬   r   r   r   Útest_math_floor†  s    zTestCudaMath.test_math_floorc                 C   s   |   ttj¡ d S rm   )rz   rh   ro   rg   r¬   r   r   r   Útest_math_trunc•  s    zTestCudaMath.test_math_truncz%trunc only supported on NumPy float64c                 C   s.   |   ttj¡ |  ttj¡ |  ttj¡ d S rm   )rx   rh   ro   rg   r|   r~   r¬   r   r   r   Útest_math_trunc_non_float64˜  s    z(TestCudaMath.test_math_trunc_non_float64c                 C   s(   | j ttjdd� | jttjdd� d S rÆ   )r¦   rX   ro   rW   r§   r¬   r   r   r   Útest_math_copysign¡  s    zTestCudaMath.test_math_copysignc              	      sd  ‡ fdd„}‡ fdd„}d}ˆ   d¡�( |t dd|¡tjtd d … d	� W 5 Q R X ˆ   d
¡�. |t tjtj g¡tjtd d … d	� W 5 Q R X ˆ   d¡� |tjtd d … d	� W 5 Q R X ˆ   d¡�( |t dd|¡tjtd d … d	� W 5 Q R X ˆ   d¡�. |t tjtj g¡tjtd d … d	� W 5 Q R X ˆ   d¡� |tjtd d … d	� W 5 Q R X d S )Nc                    sv   t jt jg| d�}t  |¡}t  |¡}t |||f¡tƒ}|dt|ƒf |||ƒ ˆ  t  	|¡¡ ˆ  t  	|¡¡ d S )Nr�   r   )
ro   r’   r•   Ú
zeros_liker   r†   r\   rÚ   rÔ   r]   )r‘   rŒ   r   r   r3   rŽ   r¬   r   r   Úmodf_template_nan©  s    

z6TestCudaMath.test_math_modf.<locals>.modf_template_nanc                    s€   |   |¡} t | ¡}t | ¡}t |||f¡tƒ}|dt| ƒf | ||ƒ t | ¡\}}ˆ  t 	||¡¡ ˆ  t 	||¡¡ d S r   )
rƒ   ro   rä   r   r†   r\   rÚ   r[   rÔ   Zarray_equal)r   r‘   rŒ   r   r3   rŽ   ÚDÚEr¬   r   r   Úmodf_template_compare²  s    


z:TestCudaMath.test_math_modf.<locals>.modf_template_comparer{   zfloat32 modf on simple floatr   é
   )r‘   rŒ   zfloat32 modf on +- infinityzfloat32 modf on nanzfloat64 modf on simple floatzfloat64 modf on +- infinityzfloat64 modf on nan)ZsubTestro   r‚   r	   r’   r”   r
   )rq   rå   rè   r‹   r   r¬   r   Útest_math_modf¨  s.    	

ÿ
ÿ 
ÿ
ÿzTestCudaMath.test_math_modfc                 C   s(   | j ttjdd� | jttjdd� d S rË   )r¦   rZ   ro   rY   r§   r¬   r   r   r   Útest_math_fmodÔ  s    zTestCudaMath.test_math_fmodc                 C   s(   | j ttjdd� | jttjdd� d S rË   )r¦   rk   ro   rY   r§   r¬   r   r   r   Útest_math_mod_binopÛ  s    z TestCudaMath.test_math_mod_binopc                 C   sX   |   ttj¡ |  ttj¡ |  ttj¡ |  ttj¡ |  ttj¡ |  ttj¡ d S rm   )	r�   r^   ro   r]   rž   r    r¡   r›   rœ   r¬   r   r   r   Útest_math_isnanâ  s    zTestCudaMath.test_math_isnanc                 C   sX   |   ttj¡ |  ttj¡ |  ttj¡ |  ttj¡ |  ttj¡ |  ttj¡ d S rm   )	r�   r`   ro   r_   rž   r    r¡   r›   rœ   r¬   r   r   r   Útest_math_isinfí  s    zTestCudaMath.test_math_isinfc                 C   sX   |   ttj¡ |  ttj¡ |  ttj¡ |  ttj¡ |  ttj¡ |  ttj¡ d S rm   )	r�   rb   ro   ra   rž   r    r¡   r›   rœ   r¬   r   r   r   Útest_math_isfiniteø  s    zTestCudaMath.test_math_isfinitec                 C   s    |   ttj¡ |  ttj¡ d S rm   )r�   rd   ro   rc   rž   r¬   r   r   r   Útest_math_degrees  s    zTestCudaMath.test_math_degreesc                 C   s    |   ttj¡ |  ttj¡ d S rm   )r�   rf   ro   re   rž   r¬   r   r   r   Útest_math_radians
  s    zTestCudaMath.test_math_radiansN)r   r   )r   r   )r   r   )r   r{   )r   r{   )r   r   )r   r   )r   rŸ   )r   rŸ   )r   r   )r   r   )r   r{   )r   r{   )FÚ__name__Ú
__module__Ú__qualname__rv   rx   rz   r|   r~   rn   r™   r›   rœ   r�   rž   r    r¡   r¤   r¦   r§   r¨   r©   r¥   r­   r®   r¯   r±   r²   r³   r´   r   r   r·   r¸   r¹   rº   r»   r¼   r½   rÂ   rÃ   rÄ   rÅ   rÇ   rÉ   rÊ   rÌ   rÍ   rÎ   rÏ   rÐ   r   rÕ   rÖ   r×   rÜ   rÝ   rÞ   rß   rà   rá   râ   rã   rê   rë   rì   rí   rî   rï   rð   rñ   r   r   r   r   rl   Ù   sˆ   













																	
				
,rl   Ú__main__)?Únumpyro   Znumba.cuda.testingr   r   r   r   r   Znumba.npr   Znumbar   r	   r
   r   r   r   r   r   r   r   r   r    r"   r$   r&   r(   r*   r,   r.   r0   r4   r6   r8   r:   r<   r>   r@   rB   rD   rF   rH   rJ   rL   rN   rP   rR   rT   rV   rX   rZ   r\   r^   r`   rb   rd   rf   rh   rj   rk   rl   rò   Úmainr   r   r   r   Ú<module>   sh   $    :
