o
    i	                     @   s  d Z ddl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mZmZmZ ddlmZ ddlmZ ddlmZmZmZ d	Zd
ZdZdddZejfddZdd Zdd Zdd Zdd Z dd Z!dd Z"dd Z#e"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*e+e*eej,ej- d-d. Z.d/d0 Z/d1d2 Z0ee0d3d4d5d6 Z1e+e/d7e0ej2 d8d9 Z3d:d; Z4d<d= Z5d>d? Z6d@dA Z7dBdC Z8dDdE Z9dFdG Z:dHdI Z;dJdK Z<dLdM Z=dNdO Z>dPdQ Z?dRdS Z@dTdU ZAdVdW ZBdXdY ZCdZd[ ZDd\d] ZEd^d_ ZFd`da ZGdbdc ZHddde ZIdfdg ZJdhdi ZKdjdk ZLdldm ZMdndo ZNdpdq ZOdrds ZPdtdu ZQdvdw ZRdxdy ZSdzd{ ZTd|d} ZUd~d ZVdd ZWdd ZXdd ZYdd ZZdd Z[dd Z\dd Z]dd Z^dd Z_dd Z`dd Zadd Zbdd Zcdd Zddd Zedd Zfdd Zgdd Zhdd Zidd Zjdd Zkdd Zldd Zmdd Zndd Zodd Zpdd Zqdd Zrdd Zsdd Ztdd Zudd Zvdd ZwddÄ Zxddń ZyddǄ ZzddɄ Z{dd˄ Z|dd̈́ Z}ddτ Z~ddф Zddӄ ZddՄ Zddׄ Zddل Zddۄ Zdd݄ Zdd߄ Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zd d Zdd Zdd ZdS (  zCodegen for functions used as kernels in NumPy functions

Typically, the kernels of several ufuncs that can't map directly to
Python builtins
    Noverload)impl_ret_untracked)typingtypeserrorsloweringcgutils)register_jitable)
npdatetime)	cmathimplmathimplnumbersg+eG?g&{?g9B.?c                    s   t ||ksJ t | j|ksJ | jd  |du r }t fdd| jD r-| j|ksBddl}| jjj}d	|| }J |dS )zchecks that the following are true:
    - args and sig.args have arg_count elements
    - all input types are homogeneous
    - return type is 'return_type' if provided, otherwise it must be
      homogeneous with the input types.
    r   Nc                 3   s    | ]}| kV  qd S N .0argtyr   `/var/www/html/eduruby.in/lip-sync/lip-sync-env/lib/python3.10/site-packages/numba/np/npyfuncs.py	<genexpr>)   s    z/_check_arity_and_homogeneity.<locals>.<genexpr>z"{0} called with invalid types: {1})
lenargsallreturn_typeinspectcurrentframef_backf_codeco_nameformat)sigr   arityr   r   fnamemsgr   r   r   _check_arity_and_homogeneity   s   
"r&   c                    sx    j }}tj||gt|j }tj|||d}	 fddt	||jD }
 
|	|
} |tj|jS )Nnamec                    s    g | ]\}}  ||qS r   )cast)r   r   Zargtybuildercontextr   r   r   
<listcomp>9   s    z0_call_func_by_name_with_cast.<locals>.<listcomp>)moduleget_argument_typellvmliteirFunctionTyper   r   r	   insert_pure_functionzipcallr)   r   float64r   )r,   r+   r"   r   	func_namer   modZltyfntyfnZ	cast_argsresultr   r*   r   _call_func_by_name_with_cast0   s   

r<   c              
      s<  |j d }z|| }W n ty$ } zd|t|}	t|	d }~ww  j}
|tjv rt	 |} fdd|D }|
 g| }|gt|j  }fdd|D }tjtj |}t|
||} ||  |d }|S fdd|j D }|j}tj||}tj|
||d} ||j |}|S )Nr   z!No {0} function for real type {1}c                    s   g | ]}t  |qS r   )r	   Zalloca_once_valuer   )r+   r   r   r-   Y   s    z/_dispatch_func_by_name_type.<locals>.<listcomp>c                    s   g | ]	}  | qS r   )get_value_typeZ
as_pointer)r   r   r,   r   r   r-   a   s    c                    s   g | ]}  |qS r   )r/   )r   Zatyr>   r   r   r-   i       r'   )r   KeyErrorr!   strr   ZLoweringErrorr.   r   Zcomplex_domainmake_complexZ_getpointerlistr0   r1   r2   ZVoidTyper	   Zget_or_insert_functionr5   loadr/   r   r3   Zcall_external_function)r,   r+   r"   r   tableZ	user_namer   r7   er%   r8   outZptrargsZ	call_argsZcall_argtysZcall_argltysr9   r:   retvalargtypesrestyper   )r+   r,   r   _dispatch_func_by_name_type@   s<   
	



rK   c              	   C   s  t ||d |\}}|jd }| |d}| |d}| |d|jjd > }	|d||}
|d||}|d|	|}|||}||
|}|j|ddn\}}| |j	}W d    n1 sbw   Y  |E |j	}|
||}|||}|d||}|d||}|||}|d	||}|||}||||}|||}W d    n1 sw   Y  W d    n1 sw   Y  ||j}||| ||| |S )
N   r      ==FZlikely>!=)r&   r   get_constanttypewidthicmp_unsignedand_or_if_elsebasic_blockZsdivsremicmp_signedxorselectaddphiadd_incoming)r,   r+   r"   r   numdenr   ZERO	MINUS_ONEZMIN_INTZden_is_zeroZden_is_minus_oneZnum_is_min_intZcould_cause_sigfpeZ
force_zerothen	otherwisebb_thenbb_otherwisedivr8   num_gt_zeroden_gt_zeronot_same_signmod_not_zeroneeds_fixing	fix_valueZresult_otherwiser;   r   r   r   np_int_sdiv_impl~   sB   
rq   c                 C   s   t ||d |\}}|jd }| |d}|d||}|j}	t||? |j}
|||}|d||}|d||}|	||}|d||}|
||}||||}|||}W d    n1 sgw   Y  ||j}|||	 |||
 |S )NrL   r   rR   rQ   )r&   r   rS   rV   rZ   r	   if_unlikelyr[   r\   r]   rW   r^   r_   r`   rT   ra   )r,   r+   r"   r   rb   rc   r   rd   den_not_zerobb_no_ifbb_ifr8   rk   rl   rm   rn   ro   rp   Z	final_modr;   r   r   r   np_int_srem_impl   s*   
rv   c                 C   H   t | ||jd |j |}t| ||jd |j |}| ||j||gS Nr   rN   )rq   r   r   rv   
make_tupler,   r+   r"   r   rj   remr   r   r   np_int_sdivrem_impl      r|   c              	   C   s   t ||d |\}}|jd }| |d}|d||}|j|dd:\}	}
|	 |j}W d    n1 s6w   Y  |
 |||}|j}W d    n1 sQw   Y  W d    n1 s`w   Y  ||j}|	|| |	|| |S )NrL   r   rO   FrP   )
r&   r   rS   rV   rY   rZ   Zudivr`   rT   ra   )r,   r+   r"   r   rb   rc   r   rd   Zdiv_by_zerorf   rg   rh   rj   ri   r;   r   r   r   np_int_udiv_impl   s&   
	r~   c                 C   s   t ||d |\}}|jd }| |d}|d||}|j}	t|| |j}
|||}W d    n1 s9w   Y  ||j	}|
||	 |
||
 |S )NrL   r   rR   )r&   r   rS   rV   rZ   r	   rr   Zuremr`   rT   ra   )r,   r+   r"   r   rb   rc   r   rd   rs   rt   ru   r8   r;   r   r   r   np_int_urem_impl   s   
r   c                 C   rw   rx   )r~   r   r   r   ry   rz   r   r   r   np_int_udivrem_impl   r}   r   c                 C      t ||d |j| S NrL   )r&   fdivr,   r+   r"   r   r   r   r   np_real_div_impl   s   
r   c                 C   s   t ||d |\}}|jd }| |d}|||}|d||}	|d||}
|d||}||	||
|}||||}|||S )NrL   r           rR   <)	r&   r   rS   fremfcmp_orderedrW   r]   r^   fadd)r,   r+   r"   r   in1in2r   rd   resZres_ne_zeroZden_lt_zeroZres_lt_zeroro   rp   r   r   r   np_real_mod_impl  s   

r   c                 C   r   r   )r&   r   r   r   r   r   np_real_fmod_impl  s   
r   c                 C   s8   t j|jd}|||}|d||}||||S )Nr   r   )r0   r1   ConstantrT   fsubr   r^   )r,   r+   r   rd   Zarg_negatedZarg_is_negativer   r   r   _fabs  s   r   c                    s    fdd|D \}}|j }|j}|j }|j}	|jtfdd||||	fD s/J d j}
tjd}tjd}t	 |}t	 |	} 
d||} |\}}|  
d||} 
d||} ||} |z\}}|  |||
_  |||
_W d    n1 sw   Y  |F  |	|} |	|} ||} ||} ||} ||} ||} ||} |||
_  |||
_W d    n1 sw   Y  W d    n1 sw   Y  W d    n	1 s	w   Y  |F  ||	} ||} |	|} ||} ||} ||} ||} ||} |||
_  |||
_W d    n1 sZw   Y  W d    |
 S W d    |
 S 1 sww   Y  |
 S )	Nc                    "   g | ]}j  jd  |dqS r   valuerB   r   r   r+   r,   r"   r   r   r-   *      z'np_complex_div_impl.<locals>.<listcomp>c                       g | ]}|j  kqS r   rT   r   iftyper   r   r-   2  r?   mismatched typesr         ?>=rO   )realimagrT   r   make_helperr   r0   r1   r   r   r   rY   rW   r   fmulr   r   	_getvalue)r,   r+   r"   r   r   r   in1rin1iin2rin2irG   rd   ONEin2r_absin2i_absin2r_abs_ge_in2i_absrf   rg   Zin2r_is_zeroZin2i_is_zeroZin2_is_zeroZinn_thenZinn_otherwiserattmp1tmp2Zscltmp3tmp4tmp5Ztmp6r   r+   r,   r   r"   r   np_complex_div_impl"  sx   
& 
-
--r   c                 C      d S r   r   x1x2r   r   r   _npy_logaddexpo     r   c                    s    t | dd fdd}d S )Ngenerictargetc                    s(   | |krd S |   fdd}|S )Nc                    sX   | |}}||kr| S || }|dkr| |  S |dkr*| | S |S )Nr   r   )r   r   xytmp)expfnlog1pfnshiftr   r   impl{  s   
z;_generate_logaddexp.<locals>.ol_npy_logaddexp.<locals>.implr   )r   r   r   constr   r   )r   r   ol_npy_logaddexpv  s
   z-_generate_logaddexp.<locals>.ol_npy_logaddexpr   )Z
fnoverloadr   r   r   r   r   r   r   _generate_logaddexpr  s   
r   c                 C   r   r   r   r   r   r   r   r     r   c                 C   F   t ||d | jt}|| jg |jR i }| ||}|||S r   )r&   typing_contextresolve_value_typer   get_call_typer   get_functionr,   r+   r"   r   r9   r   r   r   r   np_real_logaddexp_impl  
   
r   c                 C   r   r   r   r   r   r   r   _npy_logaddexp2  r   r   c                 C   r   r   r   r   r   r   r   npy_log2_1p  r   r   r   r   c                    s   | t   fdd}|S )Nc                    s    t |  S r   )nplog1pr   ZLOG2Er   r   r     s   zol_npy_log2_1p.<locals>.impl)
_NPY_LOG2E)r   r   r   r   r   ol_npy_log2_1p  s   r   r   c                 C   r   r   )r&   r   r   r   r   r   r   r   r   r   r   np_real_logaddexp2_impl  r   r   c                    sf   |\}}|j  t fdd|D sJ d|j\}}| |||tj}| |||tj}|||S )Nc                 3   s    | ]}|j  kV  qd S r   r   r   Zlltyper   r   r     s    z&np_int_truediv_impl.<locals>.<genexpr>zmust have homogeneous types)rT   r   r   r)   r   r6   r   )r,   r+   r"   r   rb   rc   ZnumtyZdentyr   r   r   np_int_truediv_impl  s   
r   c                 C   s.   t | |||}t|j|j}t| |||fS r   )r   r   	signaturer   np_real_floor_impl)r,   r+   r"   r   r   sr   r   r   np_real_floor_div_impl  s   r   c                 C   rw   rx   )r   r   r   r   ry   rz   r   r   r   np_real_divmod_impl  r}   r   c              	      s
  j d j}t||} fdd|D \}}|j}|j}	|j}
|j}|jtfdd||	|
|fD s;J dtj	
d} j}||_t |
}t |} d||} |\}}|5  ||
} |	|} ||} ||} |
|} ||}t ||f|_W d    n1 sw   Y  |5  |
|} ||} |
|} |	|} ||} ||}t ||f|_W d    n1 sw   Y  W d    | S W d    | S 1 sw   Y  | S )Nr   c                    r   r   r   r   r   r   r   r-     r   z-np_complex_floor_div_impl.<locals>.<listcomp>c                    r   r   r   r   r   r   r   r-     r?   r   r   r   )r   underlying_floatr   r   r   r   rT   r   r0   r1   r   r   r   r   r   rY   r   r   r   r   r   )r,   r+   r"   r   Z
float_kindZ	floor_sigr   r   r   r   r   r   rd   rG   r   r   r   rf   rg   r   r   r   r   r   r   r   r   r   np_complex_floor_div_impl  sV   
&	

r   c                 C      t ||d t| |||S r   r&   r   Zcomplex_power_implr   r   r   r   np_complex_power_impl     r   c                 C   r   r   )r&   r   Zreal_power_implr   r   r   r   real_float_power_impl  r   r   c                 C   r   r   r   r   r   r   r   np_complex_float_power_impl  r   r   c                 C   r   r   )r&   r   Zgcd_implr   r   r   r   np_gcd_impl(     r   c           
      C   sX   |j \}}||  kr|jksJ  J |\}}dd }| ||||}	t| ||j|	S )Nc                 S   s$   | dkrdS t | |t||   S )z7
        Like gcd, heavily cribbed from Julia.
        r   )absr   gcd)abr   r   r   lcm6  s   $znp_lcm_impl.<locals>.lcm)r   r   compile_internalr   )
r,   r+   r"   r   ZxtyZytyr   r   r   r   r   r   r   np_lcm_impl0  s   
r   c                 C   s   t ||d |d }|jd }|j}| |d}| |d}| |d}	| |td}
| ||}||_||_tj	t
jg|gd R  }|| g}t| |||}t| |||}t| |||}||||}|||	|
}|||||_| S )NrN   r   r   r         nanrL   )r&   r   r   rS   floatrB   r   r   r   r   r   booleanr   np_complex_ge_implnp_complex_eq_implnp_complex_lt_implr^   )r,   r+   r"   r   opr   float_tyrd   r   re   ZNANr;   Zcmp_sigZcmp_argsarg1_ge_arg2Zarg1_eq_arg2Zarg1_lt_arg2Zreal_when_geZreal_when_nger   r   r   np_complex_sign_implC  s(   
r   c                 C      t ||d t|d|S )NrN   z	llvm.rintr&   r   Zcall_fp_intrinsicr   r   r   r   np_real_rint_implc     r  c           	      C   s|   t ||d |jd }|j}| j|||d d}| ||}tj|gd  }t| |||jg|_t| |||jg|_|	 S )NrN   r   r   rL   )
r&   r   r   rB   r   r   r  r   r   r   )	r,   r+   r"   r   r   r   r   rG   	inner_sigr   r   r   np_complex_rint_impli  s   
r  c                 C   r   NrN   )r&   r   exp_implr   r   r   r   np_real_exp_impl|  r   r  c                 C   r   r  )r&   r   r  r   r   r   r   np_complex_exp_impl  r   r	  c                 C   .   t ||d tjdtjdi}t| ||||dS )NrN   Znumba_exp2fZ
numba_exp2exp2r&   r   float32r6   rK   r,   r+   r"   r   dispatch_tabler   r   r   np_real_exp2_impl     
r  c           	      C   s|   t ||d |jd }|j}| j|||d d}| ||}| |t}|||j|_|||j|_t	| |||
 gS NrN   r   r   )r&   r   r   rB   rS   
_NPY_LOGE2r   r   r   r	  r   )	r,   r+   r"   r   r   r   r   r   Zloge2r   r   r   np_complex_exp2_impl  s   
r  c                 C   r   r  )r&   r   log_implr   r   r   r   np_real_log_impl  r   r  c                 C   r   r  )r&   r   r  r   r   r   r   np_complex_log_impl  r   r  c                 C   r
  )NrN   Znumba_log2fZ
numba_log2log2r  r  r   r   r   np_real_log2_impl  r  r  c                 C   n   t ||d |jd }|j}t| |||}| j|||d}| |t}|||j|_|||j	|_	|
 S r  )r&   r   r   r  rB   rS   r   r   r   r   r   )r,   r+   r"   r   r   r   r   Zlog2er   r   r   np_complex_log2_impl     
r  c                 C   r   r  )r&   r   Z
log10_implr   r   r   r   np_real_log10_impl  r   r  c                 C   r  r  )r&   r   r   r  rB   rS   _NPY_LOG10Er   r   r   r   )r,   r+   r"   r   r   r   r   Zlog10er   r   r   np_complex_log10_impl  r  r  c                 C   r   r  )r&   r   Z
expm1_implr   r   r   r   np_real_expm1_impl  r   r   c                 C   s   t ||d |jd }|j}tj|gd  }| |d}| j|||d d}t| |||jg}	| ||}
t	| |||j
g}t| |||j
g}||	|}||	||
_
||||
_|
 S )NrN   r   rL   r   r   )r&   r   r   r   r   rS   rB   r  r   np_real_cos_implr   np_real_sin_implr   r   r   )r,   r+   r"   r   r   r   float_unary_sigre   r   r   rG   Zcos_imagZsin_imagr   r   r   r   np_complex_expm1_impl  s   
r$  c                 C   r   r  )r&   r   Z
log1p_implr   r   r   r   np_real_log1p_impl  r   r%  c                 C   s   t ||d |jd }|j}tj|gd  }tj|gd  }| |d}| j|||d d}	| ||}
||	j|}t	| ||||	j
g}t| |||	j
|g|
_
t| |||g|
_|
 S )NrN   r   rL      r   r   )r&   r   r   r   r   rS   rB   r   r   np_real_hypot_implr   np_real_atan2_implr  r   )r,   r+   r"   r   r   r   r#  Zfloat_binary_sigr   r   rG   Zreal_plus_onelr   r   r   np_complex_log1p_impl  s"   
r*  c                 C   r   r  )r&   r   	sqrt_implr   r   r   r   np_real_sqrt_impl  r   r,  c                 C   r   r  )r&   r   r+  r   r   r   r   np_complex_sqrt_impl  r   r-  c                 C       t ||d ||d |d S NrN   r   )r&   mulr   r   r   r   np_int_square_impl%     r1  c                 C   r.  r/  )r&   r   r   r   r   r   np_real_square_impl*  r2  r3  c                 C   s:   t ||d tj|jgd  }t| |||d |d gS NrN   r&  r   )r&   r   r   r   r   complex_mul_impl)r,   r+   r"   r   
binary_sigr   r   r   np_complex_square_impl.  s
   
r7  c                    s:   t ||d tdddd   fdd}| ||||S )NrN   T)Zfastmathc                 S   s$   | dk rt |  d S t | dS )Nr   gUUUUUU?)r   powerr   r   r   r   cbrt=  s   znp_real_cbrt_impl.<locals>.cbrtc                    s   t | rt jS  | S r   )r   isnanr   r   r9  r   r   _cbrtD  s   
z np_real_cbrt_impl.<locals>._cbrt)r&   r
   r   )r,   r+   r"   r   r<  r   r;  r   np_real_cbrt_impl8  s
   
r=  c           	      C   sd   t ||d |j}tj|gd  }| ||d |tj}| tjd}|||}| ||tj|S r4  )	r&   r   r   r   r)   r   r6   rS   r   )	r,   r+   r"   r   r   r6  Zin_as_floatr   Zresult_as_floatr   r   r   np_int_reciprocal_implO  s   r>  c                 C   s*   t ||d | |jd}|||d S )NrN   r   r   )r&   rS   r   r   )r,   r+   r"   r   r   r   r   r   np_real_reciprocal_impl]  s   r?  c              	   C   s  t ||d |jd }|j}| |d}| |d}| j|||d d}| ||}	|j}
|j}t| ||
}t| ||}|d||}|	|\}}|0 |
||
}|||}||
|}|
||}|||}||	_||||	_W d    n1 sw   Y  |. |
|
|}||
|}|||}|
||}||||	_||||	_W d    n1 sw   Y  W d    |	 S W d    |	 S 1 sw   Y  |	 S )NrN   r   r   r   r   <=)r&   r   r   rS   rB   r   r   r   r   rY   r   r   r   r   r   )r,   r+   r"   r   r   r   rd   r   r   rG   r   r   Zin1r_absZin1i_absZin1i_abs_le_in1r_absrf   rg   rZtmp0dinv_dZminus_rr   r   r   np_complex_reciprocal_implc  sJ   


rD  c                 C   r   r  )r&   r   sin_implr   r   r   r   r"    r   r"  c                 C   r   r  )r&   r   rE  r   r   r   r   np_complex_sin_impl  r   rF  c                 C   r   r  )r&   r   cos_implr   r   r   r   r!    r   r!  c                 C   r   r  )r&   r   rG  r   r   r   r   np_complex_cos_impl  r   rH  c                 C   r   r  )r&   r   Ztan_implr   r   r   r   np_real_tan_impl  r   rI  c                 C   r   r  )r&   r   Z	asin_implr   r   r   r   np_real_asin_impl  r   rJ  c                 C   r   r  )r&   r   Z	acos_implr   r   r   r   np_real_acos_impl  r   rK  c                 C   r   r  )r&   r   Z	atan_implr   r   r   r   np_real_atan_impl  r   rL  c                 C   r   r   )r&   r   Zatan2_float_implr   r   r   r   r(    r   r(  c                 C   r   r   )r&   r   Zhypot_float_implr   r   r   r   r'    r   r'  c                 C   r   r  )r&   r   Z	sinh_implr   r   r   r   np_real_sinh_impl  r   rM  c                 C   s   t ||d |jd }|j}tj|gd  }| |||d }| ||}|j}	|j}
t| |||
g}t	| |||	g}t
| |||
g}t| |||	g}||||_||||_| S NrN   r   rL   )r&   r   r   r   r   rB   r   r   r"  rM  r!  np_real_cosh_implr   r   )r,   r+   r"   r   r   ftyfsig1r   rG   xrxisxishxrcxichxrr   r   r   np_complex_sinh_impl  s   
rX  c                 C   r   r  )r&   r   Z	cosh_implr   r   r   r   rO    r   rO  c                 C   s   t ||d |jd }|j}tj|gd  }| |||d }| ||}|j}	|j}
t| |||
g}t	| |||	g}t
| |||
g}t| |||	g}||||_||||_| S rN  )r&   r   r   r   r   rB   r   r   r!  rO  r"  rM  r   r   )r,   r+   r"   r   r   rP  rQ  r   rG   rR  rS  rV  rW  rT  rU  r   r   r   np_complex_cosh_impl  s   
rY  c                 C   r   r  )r&   r   Z	tanh_implr   r   r   r   np_real_tanh_impl  r   rZ  c                 C   sn  t ||d |jd }|j}tj|gd  }| |d}| |||d }| ||}	|j}
|j}t	| |||g}t
| |||g}t| |||
g}t| |||
g}|||}|||}|||}|||}|||}|||}|||}|||}|||}|||}|||}|||}|||}|||}||||	_||||	_|	 S )NrN   r   rL   r   )r&   r   r   r   r   rS   rB   r   r   r"  r!  rM  rO  r   r   r   r   r   )r,   r+   r"   r   r   rP  rQ  r   r   rG   rR  rS  siciZshrZchr_rsis_rcZicZsqr_rcZsqr_icrB  rC  Zrs_rcZis_icZis_rcZrs_icZnumrZnumir   r   r   np_complex_tanh_impl  s<   
r`  c                 C   r   r  )r&   r   Z
asinh_implr   r   r   r   np_real_asinh_implF  r   ra  c                 C   r   r  )r&   r   Z
acosh_implr   r   r   r   np_real_acosh_implN  r   rb  c                 C   s   t ||d |jd }tj|gd  }| ||d}|d }t| ||||g}t| ||||g}	t| |||g}
t| |||	g}t	| |||
|g}t| ||||g}t
| |||gS )NrN   r   r&  y      ?        )r&   r   r   r   Zget_constant_genericr   Zcomplex_add_implZcomplex_sub_implr-  r5  r  )r,   r+   r"   r   r   Zcsig2r   r   Z
x_plus_oneZx_minus_oneZsqrt_x_plus_oneZsqrt_x_minus_oneZ	prod_sqrtZlog_argr   r   r   np_complex_acosh_implS  s,   

rc  c                 C   r   r  )r&   r   Z
atanh_implr   r   r   r   np_real_atanh_implq  r   rd  c                 C   r   )NrN   z
llvm.floorr  r   r   r   r   r   y  r  r   c                 C   r   )NrN   z	llvm.ceilr  r   r   r   r   np_real_ceil_impl  r  re  c                 C   r   )NrN   z
llvm.truncr  r   r   r   r   np_real_trunc_impl  r  rf  c                 C   r   )NrN   z	llvm.fabsr  r   r   r   r   np_real_fabs_impl  r  rg  c                       t ||dtjd |jd  fdd|D \}}|j}|j}|j}|j}	 d||}
 d||	} d||} d	||	} |
|} ||} ||S )
NrL   r   r   c                       g | ]
}j  |d qS r   rB   r   r*   r   r   r-         z&np_complex_ge_impl.<locals>.<listcomp>rQ   ordrO   r   	r&   r   r   r   r   r   r   rW   rX   )r,   r+   r"   r   r   r   rR  rS  yryixr_gt_yrno_nan_xi_yixr_eq_yrZxi_ge_yi
first_termsecond_termr   r*   r   r        
r   c                    rh  )
NrL   ri  r   c                    rj  rk  rl  r   r*   r   r   r-     rm  z&np_complex_le_impl.<locals>.<listcomp>r   rn  rO   r@  ro  )r,   r+   r"   r   r   r   rR  rS  rp  rq  xr_lt_yrrs  rt  Zxi_le_yiru  rv  r   r*   r   np_complex_le_impl  rw  ry  c                       t ||dtjd |jd  fdd|D \}}|j}|j}|j}|j}	 d||}
 d||	} d||} d||	} |
|} ||} ||S )	NrL   ri  r   c                    rj  rk  rl  r   r*   r   r   r-     rm  z&np_complex_gt_impl.<locals>.<listcomp>rQ   rn  rO   ro  )r,   r+   r"   r   r   r   rR  rS  rp  rq  rr  rs  rt  Zxi_gt_yiru  rv  r   r*   r   np_complex_gt_impl  rw  r{  c                    rz  )	NrL   ri  r   c                    rj  rk  rl  r   r*   r   r   r-     rm  z&np_complex_lt_impl.<locals>.<listcomp>r   rn  rO   ro  )r,   r+   r"   r   r   r   rR  rS  rp  rq  rx  rs  rt  Zxi_lt_yiru  rv  r   r*   r   r     rw  r   c                    v   t ||dtjd |jd  fdd|D \}}|j}|j}|j}|j}	 d||}
 d||	} |
|S )NrL   ri  r   c                    rj  rk  rl  r   r*   r   r   r-     rm  z&np_complex_eq_impl.<locals>.<listcomp>rO   )r&   r   r   r   r   r   r   rW   )r,   r+   r"   r   r   r   rR  rS  rp  rq  rt  Zxi_eq_yir   r*   r   r        
r   c                    r|  )NrL   ri  r   c                    rj  rk  rl  r   r*   r   r   r-   
  rm  z&np_complex_ne_impl.<locals>.<listcomp>rR   )r&   r   r   r   r   r   fcmp_unorderedrX   )r,   r+   r"   r   r   r   rR  rS  rp  rq  Zxr_ne_yrZxi_ne_yir   r*   r   np_complex_ne_impl  r}  r  c                 C   s8   | j |||d}t||j}t||j}|||S )Nr   )rB   r	   is_truer   r   rX   )r,   r+   r   valcomplex_valZre_trueZim_truer   r   r   _complex_is_true  s   r  c                 C   >   t ||dtjd t||d }t||d }|||S NrL   ri  r   rN   )r&   r   r   r	   r  rW   r,   r+   r"   r   r   r   r   r   r   np_logical_and_impl"     r  c                 C   N   t ||dtjd t| ||jd |d }t| ||jd |d }|||S r  )r&   r   r   r  r   rW   r  r   r   r   np_complex_logical_and_impl)     r  c                 C   r  r  )r&   r   r   r	   r  rX   r  r   r   r   np_logical_or_impl0  r  r  c                 C   r  r  )r&   r   r   r  r   rX   r  r   r   r   np_complex_logical_or_impl7  r  r  c                 C   r  r  )r&   r   r   r	   r  r]   r  r   r   r   np_logical_xor_impl>  r  r  c                 C   r  r  )r&   r   r   r  r   r]   r  r   r   r   np_complex_logical_xor_implE  r  r  c                 C   "   t ||dtjd t||d S NrN   ri  r   )r&   r   r   r	   Zis_falser   r   r   r   np_logical_not_implL     r  c                 C   s4   t ||dtjd t| ||jd |d }||S r  )r&   r   r   r  r   not_)r,   r+   r"   r   r   r   r   r   np_complex_logical_not_implQ  s   
r  c                 C   0   t ||d |\}}|d||}||||S NrL   r   r&   r\   r^   )r,   r+   r"   r   arg1arg2Zarg1_sge_arg2r   r   r   np_int_smax_impl`     r  c                 C   r  r  r&   rV   r^   )r,   r+   r"   r   r  r  Zarg1_uge_arg2r   r   r   np_int_umax_implg  r  r  c                 C   h   t ||d |\}}|d||}|d||}||||}|d||}	||	||}
||||
S NrL   unor   r&   r~  r^   r   )r,   r+   r"   r   r  r  arg1_nanany_nan
nan_resultr   non_nan_resultr   r   r   np_real_maximum_impln     r  c                 C   sh   t ||d |\}}|d||}|d||}||||}|d||}	||	||}
||||
S r  r  )r,   r+   r"   r   r  r  arg2_nanr  r  r   r  r   r   r   np_real_fmax_impl}  r  r  c                 C      t ||d |jd }ttj|}tjtjg|gd R  }|\}}t| |||g}	t| |||g}
||	|
}||	||}t	| |||}||||}||||S NrL   r   
r&   r   r   r   r   r   np_complex_isnan_implrX   r^   r   r,   r+   r"   r   r   bc_sigbcc_sigr  r  r  r  r  r  r   r  r   r   r   np_complex_maximum_impl     
r  c                 C      t ||d |jd }ttj|}tjtjg|gd R  }|\}}t| |||g}	t| |||g}
||	|
}||
||}t	| |||}||||}||||S r  r  r  r   r   r   np_complex_fmax_impl     
r  c                 C   r  NrL   r@  r  )r,   r+   r"   r   r  r  Zarg1_sle_arg2r   r   r   np_int_smin_impl  r  r  c                 C   r  r  r  )r,   r+   r"   r   r  r  Zarg1_ule_arg2r   r   r   np_int_umin_impl  r  r  c                 C   r  NrL   r  r@  r  r,   r+   r"   r   r  r  r  r  r  arg1_le_arg2r  r   r   r   np_real_minimum_impl  r  r  c                 C   sh   t ||d |\}}|d||}|d||}||||}|d||}	||	||}
||||
S r  r  r  r   r   r   np_real_fmin_impl  r  r  c                 C   r  r  
r&   r   r   r   r   r   r  rX   r^   ry  r,   r+   r"   r   r   r  r  r  r  r  r  r  r  r  r  r   r   r   np_complex_minimum_impl  r  r  c                 C   r  r  r  r  r   r   r   np_complex_fmin_impl  r  r  c                 C      t ||dtjd tjS NrN   ri  r&   r   r   r	   Z	false_bitr   r   r   r   np_int_isnan_impl     r  c                 C   r  r  )r&   r   r   r   is_nanr   r   r   r   np_real_isnan_impl  r  r  c                 C   <   t ||dtjd |\}|j\}| j|||d}t||S NrN   ri  r   )r&   r   r   r   rB   r   r  r,   r+   r"   r   r   r   r  r   r   r   r    s
   r  c                 C   r  r  )r&   r   r   r	   Ztrue_bitr   r   r   r   np_int_isfinite_impl$  r  r  c                 C   &   t ||dtjd |d|d tjS )NrN   ri  rR   r   )r&   r   r   rV   r   NATr   r   r   r   np_datetime_isfinite_impl)     r  c                 C   r  )NrN   ri  rO   r   )r&   r   r   r\   r   r  r   r   r   r   np_datetime_isnat_impl.  r  r  c                 C   r  r  )r&   r   r   r   	is_finiter   r   r   r   np_real_isfinite_impl3  r  r  c                 C   r  r  )r&   r   r   r   rB   r   r  r  r   r   r   np_complex_isfinite_impl8  
   r  c                 C   r  r  r  r   r   r   r   np_int_isinf_impl@  r  r  c                 C   r  r  )r&   r   r   r   is_infr   r   r   r   np_real_isinf_implE  r  r  c                 C   r  r  )r&   r   r   r   rB   r   r  r  r   r   r   np_complex_isinf_implJ  r  r  c           
   	   C   s   t ||dtjd tj| tjdtj| tjdtj| tj	di}|j
d }ttd|j }| |}|||d ||| }|d||d}	|	S )	NrN   ri  i   l        l            r   ZuintrR   )r&   r   r   Zfloat16rS   Zuint16r  Zuint32r6   Zuint64r   getattrZbitwidthr=   rW   ZbitcastrV   rT   )
r,   r+   r"   r   masksZarg_tyZ
arg_int_tyZarg_ll_int_tyZint_resZbool_resr   r   r   np_real_signbit_implR  s   

r  c                 C   r   r   )r&   r   Zcopysign_float_implr   r   r   r   np_real_copysign_impld  r   r  c                 C   r
  )NrL   numba_nextafterfnumba_nextafter	nextafterr  r  r   r   r   np_real_nextafter_impli  r  r  c                 C   s   t ||d tjdtjdi}|j\}t|j||}|d j}|t	j
}tj|||g}	tj|j|	dd}
||
||d g}||g }t| ||||d}|||d S )NrN   r  r  r   zllvm.copysignr'   r  )r&   r   r  r6   r   r   r   r   rT   r   infr0   r1   r2   r	   r3   r.   r5   rK   r   )r,   r+   r"   r   r  r   r  Zll_tyZll_infr9   r:   Zll_sinfZ
inner_argsr  r   r   r   np_real_spacing_implt  s&   



r  c           	      C   sH   |\}}|j \}}| |||tj}t||tj}t| ||||fS r   )r   r)   r   Zintcr   r   r   Z
ldexp_impl)	r,   r+   r"   r   r   r   Zty1Zty2Zf_fi_sigr   r   r   np_real_ldexp_impl  s
   
r  r   )__doc__mathZllvmlite.irr0   numpyr   Znumba.core.extendingr   Znumba.core.imputilsr   Z
numba.corer   r   r   r   r	   r
   Znumba.npr   Znumba.cpythonr   r   r   r   r  r  r&   r6   r<   rK   rq   rv   r|   r~   r   r   Znp_int_fmod_implr   r   r   r   r   r   r   r   expr   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  r3  r7  r=  r>  r?  rD  r"  rF  r!  rH  rI  rJ  rK  rL  r(  r'  rM  rX  rO  rY  rZ  r`  ra  rb  rc  rd  r   re  rf  rg  r   ry  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   <module>   s   
>%M


6		 
*)				