U
    ,d%                     @   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 ]8\ZEZFZGeHeeFZIeHeeEZJe@eGeeI e@eGeeJ qeD ]P\ZEZFZGeHeeFZIeHeeEZJeAeGeeI eAeGeeJ eBeGeeJ eBeGeeJ qe3D ]P\ZEZFZGeHeeFZIeHeeEZJeCeGeeI eCeGeeJ eDeGeeJ eDeGeeJ qJdedf 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)	libdeviceZisnandZisnanfZisinfdZisinffZ	isfinitedZfinitefceilZceilffloorZfloorffabsZfabsfexpZexpfexpm1Zexpm1ferfZerfferfcZerfcfZtgammaZtgammaflgammaZlgammafsqrtZsqrtflogZlogflog2Zlog2flog10Zlog10flog1pZlog1pfacoshZacoshfacosZacosfcosZcosfcoshZcoshfasinhZasinhfasinZasinfsinZsinfsinhZsinhfatanZatanfatanhZatanhftanZtanftanhZtanhfZ	fast_cosfZ	fast_sinfZ	fast_tanfZ	fast_expfZ
fast_log2fZfast_log10fZ	fast_logfcopysignZ	copysignfatan2Zatan2fpowZpowffmodZfmodfhypotZhypotf	remainderZ
remainderfZ	fast_powfc                 C   s   |  tjdS )Nr   Zget_constantr   booleancontextbuildersigargs r2   7/tmp/pip-unpacked-wheel-eu7e0c37/numba/cuda/mathimpl.pymath_isinf_isnan_intC   s    r4   c              	   C   sh   | j r,tttt}| tj|}|||S t||d  | j	
|d W 5 Q R X |j| }|S d S )N   )zdivision by zero)fastmathr   	signaturer   get_functionr   Zfast_fdividefr   Zif_zeroZerror_modelZfp_zero_divisionZfdiv)r.   r/   r0   r1   implresr2   r2   r3   maybe_fast_truedivI   s    

r;   c                 C   s   |  tjdS )Nr5   r+   r-   r2   r2   r3   math_isfinite_intV   s    r<   c                    s     fdd}t | | d S )Nc                    s4   |   ttj}|||}| ||tjtjS N)r8   r   r7   r   int32castr,   )r.   r/   r0   r1   libfunc_implresultlibfunctyr2   r3   lower_boolean_impl\   s
    
z(impl_boolean.<locals>.lower_boolean_impllower)keyrD   rC   rE   r2   rB   r3   impl_boolean[   s    rI   c                    s     fdd}t | | d S )Nc                    sR    }d }t kr"| jr"t j}|d k	r4tt|}| |t	}|||S r=   )
r   r6   unarys_fastmathget__name__getattrr   r8   r   r7   r.   r/   r0   r1   Zactual_libfuncZfast_replacementr@   rB   r2   r3   lower_unary_implf   s    

z$impl_unary.<locals>.lower_unary_implrF   )rH   rD   rC   rO   r2   rB   r3   
impl_unarye   s    rP   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)r1   r	   sitofpr
   uitofp	TypeErrorr   
DoubleTyper   r7   r   r8   )r.   r/   r0   r1   convertmargr@   rC   r2   r3   lower_unary_int_implw   s    z,impl_unary_int.<locals>.lower_unary_int_implrF   )rH   rD   rC   rY   r2   rX   r3   impl_unary_intv   s    rZ   c                    s"    fdd}t | | d S )Nc                    sT    }d }t kr"| jr"t j}|d k	r4tt|}| |t	}|||S r=   )
r   r6   binarys_fastmathrK   rL   rM   r   r8   r   r7   rN   rB   r2   r3   lower_binary_impl   s    
z&impl_binary.<locals>.lower_binary_implrF   )rH   rD   rC   r\   r2   rB   r3   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 r2   )r   rT   ).0rW   rU   r2   r3   
<listcomp>   s     zBimpl_binary_int.<locals>.lower_binary_int_impl.<locals>.<listcomp>)
r1   r	   rQ   r
   rR   rS   r   r7   r   r8   )r.   r/   r0   r1   rV   r@   rX   r_   r3   lower_binary_int_impl   s    z.impl_binary_int.<locals>.lower_binary_int_implrF   )rH   rD   rC   ra   r2   rX   r3   impl_binary_int   s    rb   c                    s&    fdd}t tjtj| d S )Nc                    s&   t tj}|  |}|||S r=   r   r7   r   r>   r8   )r.   r/   r0   r1   Zpowi_sigr@   rB   r2   r3   lower_pow_impl_int   s    z(impl_pow_int.<locals>.lower_pow_impl_int)rG   mathr'   r   r>   )rD   rC   rd   r2   rB   r3   impl_pow_int   s    rf   c                    s0   t d fdd}ttj| d S )N   c                    s"   t }|  |}|||S r=   r   r7   r8   )r.   r/   r0   r1   Zmodf_sigr@   rC   ZrettyrD   r2   r3   lower_modf_impl   s    z"impl_modf.<locals>.lower_modf_impl)r   ZUniTuplerG   re   modf)rD   rC   rj   r2   ri   r3   	impl_modf   s    rl   c                    s4   t t jf fdd}ttj| d S )Nc                    s"   t }|  |}|||S r=   rh   )r.   r/   r0   r1   Z	frexp_sigr@   ri   r2   r3   lower_frexp_impl   s    z$impl_frexp.<locals>.lower_frexp_impl)r   Tupler>   rG   re   frexp)rD   rC   rm   r2   ri   r3   
impl_frexp   s    rp   c                    s&    fdd}t tjtj| d S )Nc                    s&   t tj}|  |}|||S r=   rc   )r.   r/   r0   r1   Z	ldexp_sigr@   rB   r2   r3   lower_ldexp_impl   s    z$impl_ldexp.<locals>.lower_ldexp_impl)rG   re   ldexpr   r>   )rD   rC   rq   r2   rB   r3   
impl_ldexp   s    rs   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rX|j dkrX d d S t| j | j}t||j }t| j| j }||j  }|jdkr|t||j  }||jt| 7 }| t| t	| d   S )Ng        g      ?y                y              ?)
realimagre   r)   r'   r&   r   r   r   r   )abZvabslenatphasectyftyr2   r3   cpow_internal  s    
z3cpow_implement.<locals>.core.<locals>.cpow_internal)Zcompile_internal)r.   r/   r0   r1   r~   r{   r2   r3   core  s    zcpow_implement.<locals>.core)rG   operatorr'   ipow)r}   r|   r   r2   r{   r3   cpow_implement  s    r   )Zre   r   Zllvmliter   Z
numba.corer   r   r   Znumba.core.imputilsr   Znumba.typesr   r   r	   r
   Z
numba.cudar   registryrG   ZbooleansisnanisinfisfiniteZunarysr   r   r   r   r   r   r   gammar   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   rJ   Zbinarysr%   r&   r'   r(   r)   r*   r[   ZIntegerr4   truedivr;   r<   rI   rP   rZ   r]   rb   Zfname64Zfname32rH   rM   Zimpl32Zimpl64rf   ZpowifZpowirl   Zmodffrk   rp   Zfrexpfro   rs   Zldexpfrr   r   Z	complex64Z
complex128r2   r2   r2   r3   <module>   s   








		
