
    ܙdk                        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 Zd Zd Zd Zd	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Z d Z!d Z"d Z#d Z$d Z%d Z&d Z'd Z(d Z)d Z*d Z+d Z,d Z-d  Z.d! Z/d" Z0d# Z1d$ Z2d% Z3d& Z4d' Z5d( Z6d) Z7d* Z8d+ Z9d, Z:d- Z; G d. d/e          Z<e=d0k    r ej>                     dS dS )1    N)skip_unless_cc_53skip_unless_cuda_pythonunittestCUDATestCaseskip_on_cudasim)numpy_support)cudafloat32float64int32	vectorizevoidint64c                 h    t          j        d          }t          j        | |                   ||<   d S N   )r	   gridmathacosABis      Alib/python3.11/site-packages/numba/cuda/tests/cudapy/test_math.py	math_acosr      (    	!A9QqT??AaDDD    c                 h    t          j        d          }t          j        | |                   ||<   d S r   )r	   r   r   asinr   s      r   	math_asinr       r   r   c                 h    t          j        d          }t          j        | |                   ||<   d S r   )r	   r   r   atanr   s      r   	math_atanr#      r   r   c                 h    t          j        d          }t          j        | |                   ||<   d S r   )r	   r   r   acoshr   s      r   
math_acoshr&      *    	!A:adAaDDDr   c                 h    t          j        d          }t          j        | |                   ||<   d S r   )r	   r   r   asinhr   s      r   
math_asinhr*       r'   r   c                 h    t          j        d          }t          j        | |                   ||<   d S r   )r	   r   r   atanhr   s      r   
math_atanhr-   %   r'   r   c                 h    t          j        d          }t          j        | |                   ||<   d S r   )r	   r   r   cosr   s      r   math_cosr0   *   (    	!A8AaD>>AaDDDr   c                 h    t          j        d          }t          j        | |                   ||<   d S r   )r	   r   r   sinr   s      r   math_sinr4   /   r1   r   c                 h    t          j        d          }t          j        | |                   ||<   d S r   )r	   r   r   tanr   s      r   math_tanr7   4   r1   r   c                 h    t          j        d          }t          j        | |                   ||<   d S r   )r	   r   r   coshr   s      r   	math_coshr:   9   r   r   c                 h    t          j        d          }t          j        | |                   ||<   d S r   )r	   r   r   sinhr   s      r   	math_sinhr=   >   r   r   c                 h    t          j        d          }t          j        | |                   ||<   d S r   )r	   r   r   tanhr   s      r   	math_tanhr@   C   r   r   c                 v    t          j        d          }t          j        | |         ||                   ||<   d S r   )r	   r   r   atan2r   r   Cr   s       r   
math_atan2rE   H   0    	!A:adAaD!!AaDDDr   c                 h    t          j        d          }t          j        | |                   ||<   d S r   )r	   r   r   expr   s      r   math_exprI   M   r1   r   c                 h    t          j        d          }t          j        | |                   ||<   d S r   )r	   r   r   erfr   s      r   math_erfrL   R   r1   r   c                 h    t          j        d          }t          j        | |                   ||<   d S r   )r	   r   r   erfcr   s      r   	math_erfcrO   W   r   r   c                 h    t          j        d          }t          j        | |                   ||<   d S r   )r	   r   r   expm1r   s      r   
math_expm1rR   \   r'   r   c                 h    t          j        d          }t          j        | |                   ||<   d S r   )r	   r   r   fabsr   s      r   	math_fabsrU   a   r   r   c                 h    t          j        d          }t          j        | |                   ||<   d S r   )r	   r   r   gammar   s      r   
math_gammarX   f   r'   r   c                 h    t          j        d          }t          j        | |                   ||<   d S r   )r	   r   r   lgammar   s      r   math_lgammar[   k   s*    	!A;qtAaDDDr   c                 h    t          j        d          }t          j        | |                   ||<   d S r   )r	   r   r   logr   s      r   math_logr^   p   r1   r   c                 h    t          j        d          }t          j        | |                   ||<   d S r   )r	   r   r   log2r   s      r   	math_log2ra   u   r   r   c                 h    t          j        d          }t          j        | |                   ||<   d S r   )r	   r   r   log10r   s      r   
math_log10rd   z   r'   r   c                 h    t          j        d          }t          j        | |                   ||<   d S r   )r	   r   r   log1pr   s      r   
math_log1prg      r'   r   c                 v    t          j        d          }t          j        | |         ||                   ||<   d S r   )r	   r   r   	remainderrC   s       r   math_remainderrj      s0    	!A>!A$!%%AaDDDr   c                 h    t          j        d          }t          j        | |                   ||<   d S r   )r	   r   r   sqrtr   s      r   	math_sqrtrm      r   r   c                 v    t          j        d          }t          j        | |         ||                   ||<   d S r   )r	   r   r   hypotrC   s       r   
math_hypotrp      rF   r   c                 v    t          j        d          }t          j        | |         ||                   ||<   d S r   )r	   r   r   powrC   s       r   math_powrs      s0    	!A8AaD!A$AaDDDr   c                 h    t          j        d          }t          j        | |                   ||<   d S r   )r	   r   r   ceilr   s      r   	math_ceilrv      r   r   c                 h    t          j        d          }t          j        | |                   ||<   d S r   )r	   r   r   floorr   s      r   
math_floorry      r'   r   c                 v    t          j        d          }t          j        | |         ||                   ||<   d S r   )r	   r   r   copysignrC   s       r   math_copysignr|      s0    	!A=1qt$$AaDDDr   c                 v    t          j        d          }t          j        | |         ||                   ||<   d S r   )r	   r   r   fmodrC   s       r   	math_fmodr      s0    	!A9QqT1Q4  AaDDDr   c                 t    t          j        d          }t          j        | |                   \  ||<   ||<   d S r   )r	   r   r   modfrC   s       r   	math_modfr      s0    	!A1Q4JAaD!A$$$r   c                 h    t          j        d          }t          j        | |                   ||<   d S r   )r	   r   r   isnanr   s      r   
math_isnanr      r'   r   c                 h    t          j        d          }t          j        | |                   ||<   d S r   )r	   r   r   isinfr   s      r   
math_isinfr      r'   r   c                 h    t          j        d          }t          j        | |                   ||<   d S r   )r	   r   r   isfiniter   s      r   math_isfiniter      s*    	!A=1AaDDDr   c                 h    t          j        d          }t          j        | |                   ||<   d S r   )r	   r   r   degreesr   s      r   math_degreesr      *    	!A<!AaDDDr   c                 h    t          j        d          }t          j        | |                   ||<   d S r   )r	   r   r   radiansr   s      r   math_radiansr      r   r   c                 h    t          j        d          }t          j        | |                   ||<   d S r   )r	   r   r   truncr   s      r   
math_truncr      r'   r   c                 V    t          j        d          }| |         ||         z  ||<   d S r   r	   r   rC   s       r   math_pow_binopr      s(    	!AQ41Q4<AaDDDr   c                 V    t          j        d          }| |         ||         z  ||<   d S r   r   rC   s       r   math_mod_binopr      s(    	!AQ4!A$;AaDDDr   c                      e Zd ZdIdZdIdZdIdZdJdZdJdZd	 Zd
 Z	d Z
d ZdIdZdIdZdKdZdKdZd ZdIdZdIdZdJdZdJdZd Zd Zd Zd Zd Zd Zd Zd Ze ed          d                          Zd! Z d" Z!d# Z"d$ Z#d% Z$d& Z%d' Z&d( Z'd) Z(d* Z)d+ Z*d, Z+d- Z,d. Z-d/ Z.d0 Z/d1 Z0d2 Z1 e2d3          d4             Z3d5 Z4d6 Z5d7 Z6d8 Z7d9 Z8d: Z9d; Z:d< Z; e2d=          d>             Z<d? Z=d@ Z>dA Z?dB Z@dC ZAdD ZBdE ZCdF ZDdG ZEdHS )LTestCudaMathr   r   c                 b    |                      ||t          j        t          j        ||           d S N)unary_templatenpfloat16selffuncnpfuncstartstops        r   unary_template_float16z#TestCudaMath.unary_template_float16   *    D&"*bj%NNNNNr   c                 b    |                      ||t          j        t          j        ||           d S r   r   r   r
   r   s        r   unary_template_float32z#TestCudaMath.unary_template_float32   r   r   c                 b    |                      ||t          j        t          j        ||           d S r   r   r   r   r   s        r   unary_template_float64z#TestCudaMath.unary_template_float64   r   r   2   c                 b    |                      ||t          j        t          j        ||           d S r   )r   r   r   r   r   s        r   unary_template_int64z!TestCudaMath.unary_template_int64   s*    D&"(BJtLLLLLr   c                 b    |                      ||t          j        t          j        ||           d S r   )r   r   uint64r   r   s        r   unary_template_uint64z"TestCudaMath.unary_template_uint64   s*    D&")RZMMMMMr   c                 *   d}t          j        |||                              |          }t          j        |                              |          }	t	          j        |          d d d         }
t	          j        |          d d d         } t          j        |
|f          |          } |d|f         ||	           |t           j        k    rd}n|t           j	        k    rd}nd}t           j
                             ||          |	|           d S )Nr   r   gvIh%<=ư>gMbP?rtol)r   linspaceastype
empty_liker   
from_dtyper	   jitr   r
   testingassert_allclose)r   r   r   npdtype	nprestyper   r   nelemr   r   arytyperestypecfuncr   s                 r   r   zTestCudaMath.unary_template   s   KtU++227;;M!##I..*733CCaC8*955ccc:,'7+,,T22ah1 bj  DD
""DDD

""66!99ad";;;;;r   c           
      r   t          j        |          }|j        dz  }t          j        d||j        dd|j        t           j        t           j        g|          }t          j        |t           j                  } t          j
        |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   )r   finfotinyarraymaxinfnanr   r   r	   r   sizer   assert_array_equal)
r   r   r   r   npmtypefidenormr   r   r   s
             r   unary_bool_special_valuesz&TestCudaMath.unary_bool_special_values   s   Xg1Hb&"'3BFBFBFK"$ $ $M!28,,,4'##A#,ccc
344T::aiA

%%a333ai!Q

%%a44444r   c                 T    |                      ||t          j        t                     d S r   )r   r   r
   r   r   r   s      r   !unary_bool_special_values_float32z.TestCudaMath.unary_bool_special_values_float32  $    &&tVRZIIIIIr   c                 T    |                      ||t          j        t                     d S r   )r   r   r   r   s      r   !unary_bool_special_values_float64z.TestCudaMath.unary_bool_special_values_float64  r   r   c                 b    |                      ||t          j        t          j        ||           d S r   r   r   s        r   unary_bool_template_float32z(TestCudaMath.unary_bool_template_float32  r   r   c                 b    |                      ||t          j        t          j        ||           d S r   r   r   s        r   unary_bool_template_float64z(TestCudaMath.unary_bool_template_float64  r   r   1   c                 b    |                      ||t          j        t          j        ||           d S r   )r   r   r   r   s        r   unary_bool_template_int32z&TestCudaMath.unary_bool_template_int32  *    D&"(BHeTJJJJJr   c                 b    |                      ||t          j        t          j        ||           d S r   )r   r   r   r   s        r   unary_bool_template_int64z&TestCudaMath.unary_bool_template_int64  r   r   c                    d}t          j        |||                              |          }t          j        |j        t           j                  }	|d d d         }
t
          d d d         } t          j        |
|f          |          } |d|f         ||	           t           j        	                     ||          |	           d S )Nr   r   r   )
r   r   r   emptyshaper   r	   r   r   r   )r   r   r   r   r   r   r   r   r   r   iarytypeoarytyper   s                r   unary_bool_templatez TestCudaMath.unary_bool_template  s    KtU++227;;HQWBH---33Q3<1:.(H-..t44ah1

""66!99a00000r   c                 b    |                      ||t          j        t          j        ||           d S r   )binary_templater   r
   r   s        r   binary_template_float32z$TestCudaMath.binary_template_float32(  *    T62:rz5$OOOOOr   c                 b    |                      ||t          j        t          j        ||           d S r   )r   r   r   r   s        r   binary_template_float64z$TestCudaMath.binary_template_float64+  r   r   c                 b    |                      ||t          j        t          j        ||           d S r   )r   r   r   r   r   s        r   binary_template_int64z"TestCudaMath.binary_template_int64.  s*    T628RZMMMMMr   c                 b    |                      ||t          j        t          j        ||           d S r   )r   r   r   r   r   s        r   binary_template_uint64z#TestCudaMath.binary_template_uint641  s*    T629bj%NNNNNr   c                    d}t          j        |||                              |          }t          j        |                              |          }	t	          j        |          d d d         }
t	          j        |          d d d         } t          j        |
|
|f          |          } |d|f         |||	           t           j        	                     |||          |	           d S )Nr   r   )
r   r   r   r   r   r   r	   r   r   r   )r   r   r   r   r   r   r   r   r   r   r   r   r   s                r   r   zTestCudaMath.binary_template4  s    KtU++227;;M!##I..*733CCaC8*955ccc:5'7G455d;;ah1a   

""66!Q<<33333r   c                 :   |                      t          t          j                   |                     t          t          j                   |                     t          t          j        dd           |                     t          t          j        dd           d S Nr   r   r   )r   r   r   arccosr   r   r   r   s    r   test_math_acoszTestCudaMath.test_math_acosA  x    ##Iry999##Iry999 	!!)RYaa!HHH""9biqq"IIIIIr   c                 :   |                      t          t          j                   |                     t          t          j                   |                     t          t          j        dd           |                     t          t          j        dd           d S r   )r   r    r   arcsinr   r   r   r   s    r   test_math_asinzTestCudaMath.test_math_asinL  r   r   c                 .   |                      t          t          j                   |                     t          t          j                   |                     t          t          j                   |                     t          t          j                   d S r   )r   r#   r   arctanr   r   r   r   s    r   test_math_atanzTestCudaMath.test_math_atanW  sh    ##Iry999##Iry999!!)RY777""9bi88888r   c                 F   |                      t          t          j        dd           |                     t          t          j        dd           |                     t          t          j        dd           |                     t          t          j        dd           d S )Nr      r   )r   r&   r   arccoshr   r   r   r   s    r   test_math_acoshzTestCudaMath.test_math_acosh`  s    ##J
!!#LLL##J
!!#LLL!!*bj!JJJ"":rz"KKKKKr   c                 .   |                      t          t          j                   |                     t          t          j                   |                     t          t          j                   |                     t          t          j                   d S r   )r   r*   r   arcsinhr   r   r   r   s    r   test_math_asinhzTestCudaMath.test_math_asinhi  sh    ##J
;;;##J
;;;!!*bj999"":rz:::::r   c                 F   |                      t          t          j        dd           |                     t          t          j        dd           |                     t          t          j        dd           |                     t          t          j        dd           d S )Nr   g?r   )r   r-   r   arctanhr   r   r   r   s    r   test_math_atanhzTestCudaMath.test_math_atanhr  s    ##J
!"#MMM##J
!"#MMM!!*bj!KKK"":rz"LLLLLr   c                 .   |                      t          t          j                   |                     t          t          j                   |                     t          t          j                   |                     t          t          j                   d S r   )r   r0   r   r/   r   r   r   r   s    r   test_math_coszTestCudaMath.test_math_cos{  h    ##Hbf555##Hbf555!!(BF333""8RV44444r   zNVIDIA Binding needed for NVRTCc                 D   |                      t          t          j                   |                      t          t          j                   |                      t          t          j                   |                      t          t          j	        d           |                      t          t          j        d           |                      t          t          j        d           |                      t          t          j        d           |                      t           t          j                   |                      t$          t          j                   |                      t(          t          j                   |                      t,          t          j                   d S )Nr   r   )r   r4   r   r3   r0   r/   rI   rH   r^   r]   ra   r`   rd   rc   rU   rT   rm   rl   rv   ru   ry   rx   r   r   r   s    r   test_math_fp16zTestCudaMath.test_math_fp16  s&    	##Hbf555##Hbf555##Hbf555##HbfA#>>>##Irwa#@@@##J#BBB##Irwb#AAA##Irw777##Irw777##J999##J99999r   c                 .   |                      t          t          j                   |                     t          t          j                   |                     t          t          j                   |                     t          t          j                   d S r   )r   r4   r   r3   r   r   r   r   s    r   test_math_sinzTestCudaMath.test_math_sin  r  r   c                 .   |                      t          t          j                   |                     t          t          j                   |                     t          t          j                   |                     t          t          j                   d S r   )r   r7   r   r6   r   r   r   r   s    r   test_math_tanzTestCudaMath.test_math_tan  r  r   c                 .   |                      t          t          j                   |                     t          t          j                   |                     t          t          j                   |                     t          t          j                   d S r   )r   r:   r   r9   r   r   r   r   s    r   test_math_coshzTestCudaMath.test_math_cosh  h    ##Irw777##Irw777!!)RW555""9bg66666r   c                 .   |                      t          t          j                   |                     t          t          j                   |                     t          t          j                   |                     t          t          j                   d S r   )r   r=   r   r<   r   r   r   r   s    r   test_math_sinhzTestCudaMath.test_math_sinh  r  r   c                 .   |                      t          t          j                   |                     t          t          j                   |                     t          t          j                   |                     t          t          j                   d S r   )r   r@   r   r?   r   r   r   r   s    r   test_math_tanhzTestCudaMath.test_math_tanh  r  r   c                 .   |                      t          t          j                   |                     t          t          j                   |                     t          t          j                   |                     t          t          j                   d S r   )r   rE   r   arctan2r   r   r   r   s    r   test_math_atan2zTestCudaMath.test_math_atan2  sh    $$Z<<<$$Z<<<"":rz:::##J
;;;;;r   c                     t           d             }|                     t          |           |                     t          |           |                     t          |           |                     t          |           d S )Nc                 *    t          j        |           S r   )r   rK   xs    r   ufuncz)TestCudaMath.test_math_erf.<locals>.ufunc  s    8A;;r   )r   r   rL   r   r   r   r   r(  s     r   test_math_erfzTestCudaMath.test_math_erf  sy    		 	 
	##He444##He444!!(E222""8U33333r   c                     t           d             }|                     t          |           |                     t          |           |                     t          |           |                     t          |           d S )Nc                 *    t          j        |           S r   )r   rN   r&  s    r   r(  z*TestCudaMath.test_math_erfc.<locals>.ufunc  s    9Q<<r   )r   r   rO   r   r   r   r)  s     r   test_math_erfczTestCudaMath.test_math_erfc  sy    		  	  
	 ##Iu555##Iu555!!)U333""9e44444r   c                 .   |                      t          t          j                   |                     t          t          j                   |                     t          t          j                   |                     t          t          j                   d S r   )r   rI   r   rH   r   r   r   r   s    r   test_math_expzTestCudaMath.test_math_exp  r  r   c                 .   |                      t          t          j                   |                     t          t          j                   |                     t          t          j                   |                     t          t          j                   d S r   )r   rR   r   rQ   r   r   r   r   s    r   test_math_expm1zTestCudaMath.test_math_expm1  h    ##J999##J999!!*bh777"":rx88888r   c                 >   |                      t          t          j        d           |                     t          t          j        d           |                     t          t          j        d           |                     t          t          j        d           d S Nr  r  )r   rU   r   rT   r   r   r   r   s    r   test_math_fabszTestCudaMath.test_math_fabs  s|    ##Irwb#AAA##Irwb#AAA!!)RWB!???""9bgR"@@@@@r   c                    t           d             }|                     t          |d           |                     t          |d           |                     t          |d           |                     t          |d           d S )Nc                 *    t          j        |           S r   )r   rW   r&  s    r   r(  z+TestCudaMath.test_math_gamma.<locals>.ufunc  s    :a== r   皙?r  r   )r   r   rX   r   r   r   r)  s     r   test_math_gammazTestCudaMath.test_math_gamma  s    		! 	! 
	!##JS#AAA##JS#AAA!!*e1!==="":uA">>>>>r   c                    t           d             }|                     t          |d           |                     t          |d           |                     t          |d           |                     t          |d           d S )Nc                 *    t          j        |           S r   )r   rZ   r&  s    r   r(  z,TestCudaMath.test_math_lgamma.<locals>.ufunc	  s    ;q>>!r   r8  r  r   )r   r   r[   r   r   r   r)  s     r   test_math_lgammazTestCudaMath.test_math_lgamma  s    		" 	" 
	"##Kc#BBB##Kc#BBB!!+uA!>>>"";Q"?????r   c                 >   |                      t          t          j        d           |                     t          t          j        d           |                     t          t          j        d           |                     t          t          j        d           d S Nr   r  )r   r^   r   r]   r   r   r   r   s    r   test_math_logzTestCudaMath.test_math_log  s|    ##HbfA#>>>##HbfA#>>>!!(BF!!<<<""8RV1"=====r   c                 >   |                      t          t          j        d           |                     t          t          j        d           |                     t          t          j        d           |                     t          t          j        d           d S r>  )r   ra   r   r`   r   r   r   r   s    r   test_math_log2zTestCudaMath.test_math_log2  s|    ##Irwa#@@@##Irwa#@@@!!)RWA!>>>""9bgQ"?????r   c                 >   |                      t          t          j        d           |                     t          t          j        d           |                     t          t          j        d           |                     t          t          j        d           d S r>  )r   rd   r   rc   r   r   r   r   s    r   test_math_log10zTestCudaMath.test_math_log10&  s|    ##J#BBB##J#BBB!!*bha!@@@"":rxq"AAAAAr   c                 .   |                      t          t          j                   |                     t          t          j                   |                     t          t          j                   |                     t          t          j                   d S r   )r   rg   r   rf   r   r   r   r   s    r   test_math_log1pzTestCudaMath.test_math_log1p/  r2  r   c                 >   |                      t          t          j        d           |                     t          t          j        d           |                     t          t          j        d           |                     t          t          j        d           d S )Ngdy=r  r   )r   rj   r   ri   r   r   r   r   s    r   test_math_remainderz TestCudaMath.test_math_remainder8  s|    $$^R\$OOO$$^R\$OOO"">2<q"III##NBL#JJJJJr   z3math.remainder(0, 0) raises a ValueError on CUDASimc                 L   t          j        t          t          d d d         t          t                              d             }t          j        dt
          j                  } |d         |dd           |                     t          j        |d                              d S )Nr   c                 6    t          j        ||          | d<   d S )Nr   )r   ri   )rr'  ys      r   test_0_0z6TestCudaMath.test_math_remainder_0_0.<locals>.test_0_0@  s    >!Q''AaDDDr   )r   r   r   )	r	   r   r   r   r   r   zeros
assertTruer   )r   rL  rJ  s      r   test_math_remainder_0_0z$TestCudaMath.test_math_remainder_0_0>  s    	$wsss|UE22	3	3	( 	( 
4	3	(HQ
##q!Q1'''''r   c                 .   |                      t          t          j                   |                     t          t          j                   |                     t          t          j                   |                     t          t          j                   d S r   )r   rm   r   rl   r   r   r   r   s    r   test_math_sqrtzTestCudaMath.test_math_sqrtJ  r  r   c                 .   |                      t          t          j                   |                     t          t          j                   |                     t          t          j                   |                     t          t          j                   d S r   )r   rp   r   ro   r   r   r   r   s    r   test_math_hypotzTestCudaMath.test_math_hypotS  sh    $$Z:::$$Z:::"":rx888##J99999r   c                    d}t          j        dd|                              |          }t          j        |t           j                  }t          j        |          }t          j        |          d d d         } t          j	        |t          d d d         |f          t                    } |d|f         |||           t          j        |          }t          t          |                    D ]&}	t          j        ||	         ||	                   ||	<   't           j                            t          j        ||                              |          |d           d S )Nr   r      r   r   r   r   )r   r   r   aranger   r   r   r   r	   r   rs   rangelenr   rr   r   r   power)
r   r   r   r   r   rD   r   r   Crefr   s
             r   pow_template_int32zTestCudaMath.pow_template_int32\  s4   K2u%%,,W55Ie28,,,M!*733CCaC88'51:w788BBah1a   
 }Qs1vv 	+ 	+AhqtQqT**DGG

""28Aq>>#8#8#A#A14"PPPPPr   c                    |                      t          t          j                   |                     t          t          j                   |                     t          j                   |                     t          j                   d S r   )r   rs   r   rY  r   r[  r
   r   r   s    r   test_math_powzTestCudaMath.test_math_powm  sd    $$Xrx888$$Xrx888
+++
+++++r   c                     |                      t          t          j                   |                     t          t          j                   d S r   )r   r   r   rY  r   r   s    r   test_math_pow_binopz TestCudaMath.test_math_pow_binopv  s8    $$^RX>>>$$^RX>>>>>r   c                 .   |                      t          t          j                   |                     t          t          j                   |                     t          t          j                   |                     t          t          j                   d S r   )r   rv   r   ru   r   r   r   r   s    r   test_math_ceilzTestCudaMath.test_math_ceil}  r  r   c                 .   |                      t          t          j                   |                     t          t          j                   |                     t          t          j                   |                     t          t          j                   d S r   )r   ry   r   rx   r   r   r   r   s    r   test_math_floorzTestCudaMath.test_math_floor  r2  r   c                 P    |                      t          t          j                   d S r   )r   r   r   r   r   s    r   test_math_trunczTestCudaMath.test_math_trunc  s     ##J99999r   z%trunc only supported on NumPy float64c                     |                      t          t          j                   |                     t          t          j                   |                     t          t          j                   d S r   )r   r   r   r   r   r   r   s    r   test_math_trunc_non_float64z(TestCudaMath.test_math_trunc_non_float64  sP    ##J999!!*bh777"":rx88888r   c                     |                      t          t          j        d           |                     t          t          j        d           d S r4  )r   r|   r   r{   r   r   s    r   test_math_copysignzTestCudaMath.test_math_copysign  sB    $$]BKr$JJJ$$]BKr$JJJJJr   c                      fd} fd}d}                      d          5   |t          j        dd|          t          j        t          d d                     d d d            n# 1 swxY w Y                         d          5   |t          j        t          j        t          j         g          t          j        t          d d                     d d d            n# 1 swxY w Y                         d	          5   |t          j        t          d d                     d d d            n# 1 swxY w Y                         d
          5   |t          j        dd|          t          j        t          d d                     d d d            n# 1 swxY w Y                         d          5   |t          j        t          j        t          j         g          t          j        t          d d                     d d d            n# 1 swxY w Y                         d          5   |t          j        t          d d                     d d d            d S # 1 swxY w Y   d S )Nc                    t          j        t           j        g|           }t          j        |          }t          j        |          } t	          j        |||f          t                    } |dt          |          f         |||                               t          j	        |                                         t          j	        |                     d S )Nr   r   )
r   r   r   
zeros_liker	   r   r   rX  rN  r   )r   r   r   r   rD   r   r   s         r   modf_template_nanz6TestCudaMath.test_math_modf.<locals>.modf_template_nan  s    "&///Aa  Aa  A9DHgw899)DDEE!SVV)Q1%%%OOBHQKK(((OOBHQKK(((((r   c                    |                      |          } t          j        |           }t          j        |           } t          j        |||f          t
                    } |dt          |           f         | ||           t          j        |           \  }}                    t          j	        ||                                         t          j	        ||                     d S r   )
r   r   rl  r	   r   r   rX  r   rN  array_equal)	r   r   r   r   rD   r   DEr   s	           r   modf_template_comparez:TestCudaMath.test_math_modf.<locals>.modf_template_compare  s    Aa  Aa  A9DHgw899)DDEE!SVV)Q1%%%71::DAqOOBN1Q//000OOBN1Q//00000r   r   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)subTestr   r   r
   r   r   r   )r   rm  rr  r   s   `   r   test_math_modfzTestCudaMath.test_math_modf  s   	) 	) 	) 	) 	)	1 	1 	1 	1 	1 \\899 	6 	6!!"+aU";";2:*1!!!*6 6 6 6	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 \\788 	6 	6!!"(BFRVG+<"="=RZ*1!!!*6 6 6 6	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 \\/00 	D 	DBJ
CCCC	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D \\899 	6 	6!!"+aU";";2:*1!!!*6 6 6 6	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 \\788 	6 	6!!"(BFRVG+<"="=RZ*1!!!*6 6 6 6	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 \\/00 	D 	DBJ
CCCC	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	Dsm   :A))A-0A-	AC$$C(+C(%D55D9<D9:FF"F;AHHH6%I((I,/I,c                     |                      t          t          j        d           |                     t          t          j        d           d S r>  )r   r   r   r~   r   r   s    r   test_math_fmodzTestCudaMath.test_math_fmod  sB    $$Yq$AAA$$Yq$AAAAAr   c                     |                      t          t          j        d           |                     t          t          j        d           d S r>  )r   r   r   r~   r   r   s    r   test_math_mod_binopz TestCudaMath.test_math_mod_binop  sB    $$^RWA$FFF$$^RWA$FFFFFr   c                    |                      t          t          j                   |                     t          t          j                   |                     t          t          j                   |                     t          t          j                   |                     t          t          j                   |                     t          t          j                   d S r   )	r   r   r   r   r   r   r   r   r   r   s    r   test_math_isnanzTestCudaMath.test_math_isnan      ((RX>>>((RX>>>&&z28<<<&&z28<<<..z28DDD..z28DDDDDr   c                    |                      t          t          j                   |                     t          t          j                   |                     t          t          j                   |                     t          t          j                   |                     t          t          j                   |                     t          t          j                   d S r   )	r   r   r   r   r   r   r   r   r   r   s    r   test_math_isinfzTestCudaMath.test_math_isinf  r|  r   c                    |                      t          t          j                   |                     t          t          j                   |                     t          t          j                   |                     t          t          j                   |                     t          t          j                   |                     t          t          j                   d S r   )	r   r   r   r   r   r   r   r   r   r   s    r   test_math_isfinitezTestCudaMath.test_math_isfinite  s    ((DDD((DDD&&}bkBBB&&}bkBBB..}bkJJJ..}bkJJJJJr   c                     |                      t          t          j                   |                     t          t          j                   d S r   )r   r   r   r   r   r   s    r   test_math_degreeszTestCudaMath.test_math_degrees  8    ((rzBBB((rzBBBBBr   c                     |                      t          t          j                   |                     t          t          j                   d S r   )r   r   r   r   r   r   s    r   test_math_radianszTestCudaMath.test_math_radians
  r  r   N)r   r   )r   r   )r   r   )F__name__
__module____qualname__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/  r1  r5  r9  r<  r?  rA  rC  rE  rG  r   rO  rQ  rS  r[  r]  r_  ra  rc  re  rg  ri  ru  rw  ry  r{  r~  r  r  r   r   r   r   r      s       O O O OO O O OO O O OM M M MN N N N< < <*5 5 5J J JJ J JO O O OO O O OK K K KK K K K1 1 1P P P PP P P PN N N NO O O O4 4 4J J JJ J J9 9 9L L L; ; ;M M M5 5 5 >??: : @? : 5 5 55 5 57 7 77 7 77 7 7< < <4 4 45 5 55 5 59 9 9A A A? ? ?@ @ @> > >@ @ @B B B9 9 9K K K _JKK( ( LK(7 7 7: : :Q Q Q", , ,? ? ?7 7 79 9 9: : : _<==9 9 >=9K K K'D 'D 'DXB B BG G GE E EE E EK K KC C CC C C C Cr   r   __main__)?numpyr   numba.cuda.testingr   r   r   r   r   numba.npr   numbar	   r
   r   r   r   r   r   r   r   r    r#   r&   r*   r-   r0   r4   r7   r:   r=   r@   rE   rI   rL   rO   rR   rU   rX   r[   r^   ra   rd   rg   rj   rm   rp   rs   rv   ry   r|   r   r   r   r   r   r   r   r   r   r   r   r  mainr  r   r   <module>r     sr      1 1 1 1 1 1 1 1 1 1 1 1 1 1
 # " " " " " G G G G G G G G G G G G G G G G G G   
  
  
  
  
  
  
  
  
  
  
  
" " "
  
  
  
  
  
  
  
  
  
  
  
& & &
  
" " "
     
  
  
% % %
! ! !
! ! !
  
  
  
  
  
  
  
  
sC sC sC sC sC< sC sC sCl zHMOOOOO r   