o
    8ήc%                     @   sT  d dl Z d dlZd dlmZ d dlmZmZmZ d dlm	Z	 d dl
mZmZmZmZ d dlmZ e	 ZejZg Zedde jfg7 Zed	d
e jfg7 Zedde jfg7 Zg Zedde jfg7 Zedde jfg7 Zedde jfg7 Zedde jfg7 Zedde jfg7 Zedde jfg7 Zedde jfg7 Zedde jfg7 Zedde j fg7 Zedd e j!fg7 Zed!d"e j"fg7 Zed#d$e j#fg7 Zed%d&e j$fg7 Zed'd(e j%fg7 Zed)d*e j&fg7 Zed+d,e j'fg7 Zed-d.e j(fg7 Zed/d0e j)fg7 Zed1d2e j*fg7 Zed3d4e j+fg7 Zed5d6e j,fg7 Zed7d8e j-fg7 Zed9d:e j.fg7 Zed;d<e j/fg7 Zed=d>e j0fg7 Zed?d@e j1fg7 Zi Z2dAe2d.< dBe2d6< dCe2d>< dDe2d< dEe2d$< dFe2d&< dGe2d"< g Z3e3dHdIe j4fg7 Z3e3dJdKe j5fg7 Z3e3dLdMe j6fg7 Z3e3dNdOe j7fg7 Z3e3dPdQe j8fg7 Z3e3dRdSe j9fg7 Z3i Z:dTe:dM< ee jej;ee jej;dUdV Z<eej=ejejdWdX Z>ee jej;dYdZ Z?d[d\ Z@d]d^ ZAd_d` ZBdadb ZCdcdd ZDeD ]\ZEZFZGeHeeFZIeHeeEZJe@eGeeI e@eGeeJ qeD ](\ZEZFZGeHeeFZIeHeeEZJeAeGeeI eAeGeeJ eBeGeeJ eBeGeeJ qe3D ](\ZEZFZGeHeeFZIeHeeEZJeCeGeeI eCeGeeJ eDeGeeJ eDeGeeJ q%dedf ZKeKejejL eKejejM dgdh ZNeNejejO eNejejP didj ZQeQejejR eQejejS dkdl ZTeTejejU eTejejV dmdn ZWeWejejX eWejejY dS )o    N)ir)typestypingcgutils)Registry)float32float64int64uint64)	libdeviceisnandisnanfisinfdisinff	isfinitedfinitefceilceilffloorfloorffabsfabsfexpexpfexpm1expm1ferferfferfcerfcftgammatgammaflgammalgammafsqrtsqrtfloglogflog2log2flog10log10flog1plog1pfacoshacoshfacosacosfcoscosfcoshcoshfasinhasinhfasinasinfsinsinfsinhsinhfatanatanfatanhatanhftantanftanhtanhf	fast_cosf	fast_sinf	fast_tanf	fast_expf
fast_log2ffast_log10f	fast_logfcopysign	copysignfatan2atan2fpowpowffmodfmodfhypothypotf	remainder
remainderf	fast_powfc                 C      |  tjdS )Nr   get_constantr   booleancontextbuildersigargs rc   :/tmp/pip-target-vg8gfxp4/lib/python/numba/cuda/mathimpl.pymath_isinf_isnan_intC   s   re   c                 C   sx   | j rtttt}| tj|}|||S t||d  | j	
|d W d    n1 s0w   Y  |j| }|S )N   )zdivision by zero)fastmathr   	signaturer   get_functionr   fast_fdividefr   if_zeroerror_modelfp_zero_divisionfdiv)r_   r`   ra   rb   implresrc   rc   rd   maybe_fast_truedivI   s   

rq   c                 C   rZ   )Nrf   r[   r^   rc   rc   rd   math_isfinite_intV   s   rr   c                         fdd}t | | d S )Nc                    s4   |   ttj}|||}| ||tjtjS N)ri   r   rh   r   int32castr]   )r_   r`   ra   rb   libfunc_implresultlibfunctyrc   rd   lower_boolean_impl\   s
   
z(impl_boolean.<locals>.lower_boolean_impllower)keyr{   rz   r|   rc   ry   rd   impl_boolean[   s   r   c                    rs   )Nc                    sR    }d }t kr| jrt j}|d urtt|}| |t	}|||S rt   )
r   rg   unarys_fastmathget__name__getattrr   ri   r   rh   r_   r`   ra   rb   actual_libfuncfast_replacementrw   ry   rc   rd   lower_unary_implf   s   


z$impl_unary.<locals>.lower_unary_implr}   )r   r{   rz   r   rc   ry   rd   
impl_unarye   s   r   c                    s    fdd}t | || d S )Nc                    sn   |j d tkr|j}n|j d tkr|j}nd}t|||d t }t	t
t
}|  |}|||gS )Nr   z<Only 64-bit integers are supported for generic unary int ops)rb   r	   sitofpr
   uitofp	TypeErrorr   
DoubleTyper   rh   r   ri   )r_   r`   ra   rb   convertmargrw   rz   rc   rd   lower_unary_int_implw   s   z,impl_unary_int.<locals>.lower_unary_int_implr}   )r   r{   rz   r   rc   r   rd   impl_unary_intv   s   r   c                    s"    fdd}t | | d S )Nc                    sT    }d }t kr| jrt j}|d urtt|}| |t	}|||S rt   )
r   rg   binarys_fastmathr   r   r   r   ri   r   rh   r   ry   rc   rd   lower_binary_impl   s   

z&impl_binary.<locals>.lower_binary_implr}   )r   r{   rz   r   rc   ry   rd   impl_binary   s   r   c                    s     fdd}t | ||| d S )Nc                    sn   |j d tkr|j n|j d tkr|j nd}t| fdd|D }tttt}| 	|}|||S )Nr   z=Only 64-bit integers are supported for generic binary int opsc                    s   g | ]	} |t  qS rc   )r   r   ).0r   r   rc   rd   
<listcomp>   s    zBimpl_binary_int.<locals>.lower_binary_int_impl.<locals>.<listcomp>)
rb   r	   r   r
   r   r   r   rh   r   ri   )r_   r`   ra   rb   r   rw   r   r   rd   lower_binary_int_impl   s   
z.impl_binary_int.<locals>.lower_binary_int_implr}   )r   r{   rz   r   rc   r   rd   impl_binary_int   s   r   c                    &    fdd}t tjtj| d S )Nc                    &   t tj}|  |}|||S rt   r   rh   r   ru   ri   )r_   r`   ra   rb   powi_sigrw   ry   rc   rd   lower_pow_impl_int      
z(impl_pow_int.<locals>.lower_pow_impl_int)r~   mathrQ   r   ru   )r{   rz   r   rc   ry   rd   impl_pow_int      r   c                    s0   t d fdd}ttj| d S )N   c                    "   t }|  |}|||S rt   r   rh   ri   )r_   r`   ra   rb   modf_sigrw   rz   rettyr{   rc   rd   lower_modf_impl      
z"impl_modf.<locals>.lower_modf_impl)r   UniTupler~   r   modf)r{   rz   r   rc   r   rd   	impl_modf   s   r   c                    s4   t t jf fdd}ttj| d S )Nc                    r   rt   r   )r_   r`   ra   rb   	frexp_sigrw   r   rc   rd   lower_frexp_impl   r   z$impl_frexp.<locals>.lower_frexp_impl)r   Tupleru   r~   r   frexp)r{   rz   r   rc   r   rd   
impl_frexp   s   r   c                    r   )Nc                    r   rt   r   )r_   r`   ra   rb   	ldexp_sigrw   ry   rc   rd   lower_ldexp_impl   r   z$impl_ldexp.<locals>.lower_ldexp_impl)r~   r   ldexpr   ru   )r{   rz   r   rc   ry   rd   
impl_ldexp   r   r   c                    sF    fdd}t tj  | t tj  | t t  | d S )Nc                    s    fdd}|  ||||S )Nc                    s   |j dkr|jdkr d d S | j dkr,|j dkr, d d S t| j | j}t||j }t| j| j }||j  }|jdkrc|t||j  }||jt| 7 }| t| t	| d   S )Ng        g      ?y                y              ?)
realimagr   rU   rQ   rO   r   r&   r2   r:   )abvabslenatphasectyftyrc   rd   cpow_internal  s   
z3cpow_implement.<locals>.core.<locals>.cpow_internal)compile_internal)r_   r`   ra   rb   r   r   rc   rd   core  s   zcpow_implement.<locals>.core)r~   operatorrQ   ipow)r   r   r   rc   r   rd   cpow_implement  s   r   )Zr   r   llvmliter   
numba.corer   r   r   numba.core.imputilsr   numba.typesr   r   r	   r
   
numba.cudar   registryr~   booleansisnanisinfisfiniteunarysr   r   r   r   r   r   r   gammar"   r$   r&   r(   r*   r,   r.   r0   r2   r4   r6   r8   r:   r<   r>   r@   rB   rD   r   binarysrM   rO   rQ   rS   rU   rW   r   Integerre   truedivrq   rr   r   r   r   r   r   fname64fname32r   r   impl32impl64r   powifpowir   modffr   r   frexpfr   r   ldexpfr   r   	complex64
complex128rc   rc   rc   rd   <module>   s    








		
