o
    8ήc'                     @   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	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dd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+d-d. Z,d/d0 Z-d1d2 Z.d3d4 Z/d5d6 Z0d7d8 Z1d9d: Z2d;d< Z3d=d> Z4d?d@ Z5dAdB Z6dCdD Z7dEdF Z8dGdH Z9dIdJ Z:dKdL Z;dMdN Z<dOdP Z=dQdR Z>dSdT Z?dUdV Z@dWdX ZAdYdZ ZBd[d\ ZCd]d^ ZDd_d` ZEdadb ZFdcdd ZGdedf ZHdgdh ZIdidj ZJdkdl ZKdmdn ZLdodp ZMdqdr ZNdsdt ZOdudv ZPdwdx ZQdydz ZRd{d| ZSd}d~ ZTdd ZUdd 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 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)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   8/tmp/pip-target-vg8gfxp4/lib/python/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   argtybuildercontextr   r   r   
<listcomp>8   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   modltyfntyfn	cast_argsresultr   r)   r   _call_func_by_name_with_cast/   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   alloca_once_valuer   )r*   r   r   r,   X   s    z/_dispatch_func_by_name_type.<locals>.<listcomp>c                    s   g | ]	}  | qS r   )get_value_type
as_pointer)r   r   r+   r   r   r,   `   s    c                    s   g | ]}  |qS r   )r.   )r   atyrA   r   r   r,   h       r%   )r   KeyErrorr   strr   LoweringErrorr-   r   complex_domainmake_complex_getpointerlistr/   r0   r1   VoidTyper   get_or_insert_functionr4   loadr.   r   r2   call_external_function)r+   r*   r    r   table	user_namer   r6   er#   r7   outptrargs	call_argscall_argtyscall_argltysr9   r:   retvalargtypesrestyper   )r*   r+   r   _dispatch_func_by_name_type?   s<   
	



rZ   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likely>!=)r$   r   get_constanttypewidthicmp_unsignedand_or_if_elsebasic_blocksdivsremicmp_signedxorselectaddphiadd_incoming)r+   r*   r    r   numdenr   ZERO	MINUS_ONEMIN_INTden_is_zeroden_is_minus_onenum_is_min_intcould_cause_sigfpe
force_zerothen	otherwisebb_thenbb_otherwisedivr7   num_gt_zeroden_gt_zeronot_same_signmod_not_zeroneeds_fixing	fix_valueresult_otherwiser<   r   r   r   np_int_sdiv_impl}   sB   
r   c                 C   s   t ||d |\}}|jd }| |d}|d||}|j}	t||? |j}
|||}|d||}|d||}|	||}|d||}|
||}||||}|||}W d    n1 sgw   Y  ||j}|||	 |||
 |S )Nr[   r   rb   ra   )r$   r   rc   rf   rj   r   if_unlikelyrl   rm   rn   rg   ro   rp   rq   rd   rr   )r+   r*   r    r   rs   rt   r   ru   den_not_zerobb_no_ifbb_ifr7   r   r   r   r   r   r   	final_modr<   r   r   r   np_int_srem_impl   s*   
r   c                 C   H   t | ||jd |j |}t| ||jd |j |}| ||j||gS Nr   r]   )r   r   r   r   
make_tupler+   r*   r    r   r   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 )Nr[   r   r^   Fr_   )
r$   r   rc   rf   ri   rj   udivrq   rd   rr   )r+   r*   r    r   rs   rt   r   ru   div_by_zeror}   r~   r   r   r   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 )Nr[   r   rb   )r$   r   rc   rf   rj   r   r   uremrq   rd   rr   )r+   r*   r    r   rs   rt   r   ru   r   r   r   r7   r<   r   r   r   np_int_urem_impl   s   
r   c                 C   r   r   )r   r   r   r   r   r   r   r   r   np_int_udivrem_impl   r   r   c                 C      t ||d |j| S Nr[   )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 )Nr[   r           rb   <)	r$   r   rc   fremfcmp_orderedrg   rn   ro   fadd)r+   r*   r    r   in1in2r   ru   resres_ne_zeroden_lt_zerores_lt_zeror   r   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   )r/   r0   Constantrd   fsubr   ro   )r+   r*   r   ru   arg_negated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rH   r   r   r*   r+   r    r   r   r,   )      z'np_complex_div_impl.<locals>.<listcomp>c                       g | ]}|j  kqS r   rd   r   iftyper   r   r,   1  rC   mismatched typesr         ?>=r^   )realimagrd   r   make_helperr   r/   r0   r   r   r   ri   rg   r   fmulr   r   	_getvalue)r+   r*   r    r   r   r   in1rin1iin2rin2irR   ru   ONEin2r_absin2i_absin2r_abs_ge_in2i_absr}   r~   in2r_is_zeroin2i_is_zeroin2_is_zeroinn_theninn_otherwiserattmp1tmp2scltmp3tmp4tmp5tmp6r   r*   r+   r   r    r   np_complex_div_impl!  sx   
& 
-
--r   c                 C   .   t ||d tjdtjdi}t| ||||dS )Nr[   npy_logaddexpfnpy_logaddexp	logaddexpr$   r   float32r5   rZ   r+   r*   r    r   dispatch_tabler   r   r   np_real_logaddexp_impln     
r   c                 C   r   )Nr[   npy_logaddexp2fnpy_logaddexp2
logaddexp2r   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   lltyper   r   r     s    z&np_int_truediv_impl.<locals>.<genexpr>zmust have homogeneous types)rd   r   r   r'   r   r5   r   )r+   r*   r    r   rs   rt   numty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   r   r   )r   r   r   r   r   r   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,     rC   r   r   r   )r   underlying_floatr   r   r   r   rd   r   r/   r0   r   r   r   r   r   ri   r   r   r   r   r   )r+   r*   r    r   
float_kind	floor_sigr   r   r   r   r   r   ru   rR   r   r   r   r}   r~   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   complex_power_implr   r   r   r   np_complex_power_impl     r   c                 C   r   r   )r$   r   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   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   )absnpgcd)abr   r   r   lcm  s   $znp_lcm_impl.<locals>.lcm)r   r   compile_internalr   )
r+   r*   r    r   xtyytyxyr  r   r   r   r   np_lcm_impl  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 )Nr]   r   r   r         nanr[   )r$   r   r   rc   floatrH   r   r   r   r   r   booleanr   np_complex_ge_implnp_complex_eq_implnp_complex_lt_implro   )r+   r*   r    r   opr   float_tyru   r   rv   NANr<   cmp_sigcmp_argsarg1_ge_arg2arg1_eq_arg2arg1_lt_arg2real_when_gereal_when_nger   r   r   np_complex_sign_impl  s(   
r$  c                 C      t ||d t|d|S )Nr]   z	llvm.rintr$   r   call_fp_intrinsicr   r   r   r   np_real_rint_impl2     r(  c           	      C   s|   t ||d |jd }|j}| j|||d d}| ||}tj|gd  }t| |||jg|_t| |||jg|_|	 S )Nr]   r   r   r[   )
r$   r   r   rH   r   r   r(  r   r   r   )	r+   r*   r    r   r   r  r   rR   	inner_sigr   r   r   np_complex_rint_impl8  s   
r+  c                 C   r   Nr]   )r$   r   exp_implr   r   r   r   np_real_exp_implK  r  r.  c                 C   r   r,  )r$   r
   r-  r   r   r   r   np_complex_exp_implP  r  r/  c                 C   r   )Nr]   	npy_exp2fnpy_exp2exp2r   r   r   r   r   np_real_exp2_implW  r   r3  c           	      C   s|   t ||d |jd }|j}| j|||d d}| ||}| |t}|||j|_|||j|_t	| |||
 gS Nr]   r   r   )r$   r   r   rH   rc   
_NPY_LOGE2r   r   r   r/  r   )	r+   r*   r    r   r   r  r   tmploge2r   r   r   np_complex_exp2_implc  s   
r8  c                 C   r   r,  )r$   r   log_implr   r   r   r   np_real_log_implr  r  r:  c                 C   r   r,  )r$   r
   r9  r   r   r   r   np_complex_log_implw  r  r;  c                 C   r   )Nr]   	npy_log2fnpy_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 r4  )r$   r   r   r;  rH   rc   
_NPY_LOG2Er   r   r   r   )r+   r*   r    r   r   r  r6  log2er   r   r   np_complex_log2_impl     
rC  c                 C   r   r,  )r$   r   
log10_implr   r   r   r   np_real_log10_impl  r  rF  c                 C   r@  r4  )r$   r   r   r;  rH   rc   _NPY_LOG10Er   r   r   r   )r+   r*   r    r   r   r  r6  log10er   r   r   np_complex_log10_impl  rD  rI  c                 C   r   r,  )r$   r   
expm1_implr   r   r   r   np_real_expm1_impl  r  rK  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 )Nr]   r   r[   r  r   )r$   r   r   r   r   rc   rH   r.  r   np_real_cos_implr   np_real_sin_implr   r   r   )r+   r*   r    r   r   r  float_unary_sigrv   r   r
  rR   cos_imagsin_imagr6  r   r   r   np_complex_expm1_impl  s   
rQ  c                 C   r   r,  )r$   r   
log1p_implr   r   r   r   np_real_log1p_impl  r  rS  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 )Nr]   r   r[      r   r   )r$   r   r   r   r   rc   rH   r   r   np_real_hypot_implr   np_real_atan2_implr:  r   )r+   r*   r    r   r   r  rN  float_binary_sigr   r   rR   real_plus_onelr   r   r   np_complex_log1p_impl  s"   
rZ  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 Nr]   r   )r$   mulr   r   r   r   np_int_square_impl     ra  c                 C   r^  r_  )r$   r   r   r   r   r   np_real_square_impl  rb  rc  c                 C   s:   t ||d tj|jgd  }t| |||d |d gS Nr]   rT  r   )r$   r   r   r   r   complex_mul_impl)r+   r*   r    r   
binary_sigr   r   r   np_complex_square_impl  s
   
rg  c                    s:   t ||d tdddd   fdd}| ||||S )Nr]   T)fastmathc                 S   s$   | dk rt |  d S t | dS )Nr   gUUUUUU?)r  powerr  r   r   r   cbrt  s   znp_real_cbrt_impl.<locals>.cbrtc                    s   t | rt jS  | S r   )r  isnanr  rj  rk  r   r   _cbrt  s   
z np_real_cbrt_impl.<locals>._cbrt)r$   r   r  )r+   r*   r    r   rn  r   rm  r   np_real_cbrt_impl  s
   
ro  c           	      C   sd   t ||d |j}tj|gd  }| ||d |tj}| tjd}|||}| ||tj|S rd  )	r$   r   r   r   r'   r   r5   rc   r   )	r+   r*   r    r   r   rf  in_as_floatr   result_as_floatr   r   r   np_int_reciprocal_impl  s   rr  c                 C   s*   t ||d | |jd}|||d S )Nr]   r   r   )r$   rc   r   r   )r+   r*   r    r   r   r   r   r   np_real_reciprocal_impl,  s   rs  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 )Nr]   r   r   r   r   <=)r$   r   r   rc   rH   r   r   r   r   ri   r   r   r   r   r   )r+   r*   r    r   r   r  ru   r   r   rR   r   r   in1r_absin1i_absin1i_abs_le_in1r_absr}   r~   rtmp0dinv_dminus_rr   r   r   np_complex_reciprocal_impl2  sJ   


r}  c                 C   r   r,  )r$   r   sin_implr   r   r   r   rM  \  r  rM  c                 C   r   r,  )r$   r
   r~  r   r   r   r   np_complex_sin_impla  r  r  c                 C   r   r,  )r$   r   cos_implr   r   r   r   rL  i  r  rL  c                 C   r   r,  )r$   r
   r  r   r   r   r   np_complex_cos_impln  r  r  c                 C   r   r,  )r$   r   tan_implr   r   r   r   np_real_tan_implv  r  r  c                 C   r   r,  )r$   r   	asin_implr   r   r   r   np_real_asin_impl~  r  r  c                 C   r   r,  )r$   r   	acos_implr   r   r   r   np_real_acos_impl  r  r  c                 C   r   r,  )r$   r   	atan_implr   r   r   r   np_real_atan_impl  r  r  c                 C   r   r   )r$   r   atan2_float_implr   r   r   r   rV    r  rV  c                 C   r   r   )r$   r   hypot_float_implr   r   r   r   rU    r  rU  c                 C   r   r,  )r$   r   	sinh_implr   r   r   r   np_real_sinh_impl  r  r  c                 C   s   t ||d |jd }|j}tj|gd  }| |||d }| ||}|j}	|j}
t| |||
g}t	| |||	g}t
| |||
g}t| |||	g}||||_||||_| S Nr]   r   r[   )r$   r   r   r   r   rH   r   r   rM  r  rL  np_real_cosh_implr   r   )r+   r*   r    r   r   ftyfsig1r  rR   xrxisxishxrcxichxrr   r   r   np_complex_sinh_impl  s   
r  c                 C   r   r,  )r$   r   	cosh_implr   r   r   r   r    r  r  c                 C   s   t ||d |jd }|j}tj|gd  }| |||d }| ||}|j}	|j}
t| |||
g}t	| |||	g}t
| |||
g}t| |||	g}||||_||||_| S r  )r$   r   r   r   r   rH   r   r   rL  r  rM  r  r   r   )r+   r*   r    r   r   r  r  r  rR   r  r  r  r  r  r  r   r   r   np_complex_cosh_impl  s   
r  c                 C   r   r,  )r$   r   	tanh_implr   r   r   r   np_real_tanh_impl  r  r  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 )Nr]   r   r[   r   )r$   r   r   r   r   rc   rH   r   r   rM  rL  r  r  r   r   r   r   r   )r+   r*   r    r   r   r  r  r   r  rR   r  r  sicishrchr_rsis_rcicsqr_rcsqr_icrz  r{  rs_rcis_icis_rcrs_icnumrnumir   r   r   np_complex_tanh_impl  s<   
r  c                 C   r   r,  )r$   r   
asinh_implr   r   r   r   np_real_asinh_impl  r  r  c                 C   r   r,  )r$   r   
acosh_implr   r   r   r   np_real_acosh_impl  r  r  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 )Nr]   r   rT  y      ?        )r$   r   r   r   get_constant_genericr   complex_add_implcomplex_sub_implr]  re  r;  )r+   r*   r    r   r   csig2r   r  
x_plus_onex_minus_onesqrt_x_plus_onesqrt_x_minus_one	prod_sqrtlog_argr   r   r   np_complex_acosh_impl"  s,   

r  c                 C   r   r,  )r$   r   
atanh_implr   r   r   r   np_real_atanh_impl@  r  r  c                 C   r%  )Nr]   z
llvm.floorr&  r   r   r   r   r   H  r)  r   c                 C   r%  )Nr]   z	llvm.ceilr&  r   r   r   r   np_real_ceil_implQ  r)  r  c                 C   r%  )Nr]   z
llvm.truncr&  r   r   r   r   np_real_trunc_implZ  r)  r  c                 C   r%  )Nr]   z	llvm.fabsr&  r   r   r   r   np_real_fabs_implc  r)  r  c                       t ||dtjd |jd  fdd|D \}}|j}|j}|j}|j}	 d||}
 d||	} d||} d	||	} |
|} ||} ||S )
Nr[   r   r   c                       g | ]
}j  |d qS r   rH   r   r)   r   r   r,   t      z&np_complex_ge_impl.<locals>.<listcomp>ra   ordr^   r   	r$   r   r  r   r   r   r   rg   rh   )r+   r*   r    r   r   r   r  r  yryixr_gt_yrno_nan_xi_yixr_eq_yrxi_ge_yi
first_termsecond_termr   r)   r   r  n     
r  c                    r  )
Nr[   r  r   c                    r  r  r  r   r)   r   r   r,     r  z&np_complex_le_impl.<locals>.<listcomp>r   r  r^   rt  r  )r+   r*   r    r   r   r   r  r  r  r  xr_lt_yrr  r  xi_le_yir  r  r   r)   r   np_complex_le_impl  r  r  c                       t ||dtjd |jd  fdd|D \}}|j}|j}|j}|j}	 d||}
 d||	} d||} d||	} |
|} ||} ||S )	Nr[   r  r   c                    r  r  r  r   r)   r   r   r,     r  z&np_complex_gt_impl.<locals>.<listcomp>ra   r  r^   r  )r+   r*   r    r   r   r   r  r  r  r  r  r  r  xi_gt_yir  r  r   r)   r   np_complex_gt_impl  r  r  c                    r  )	Nr[   r  r   c                    r  r  r  r   r)   r   r   r,     r  z&np_complex_lt_impl.<locals>.<listcomp>r   r  r^   r  )r+   r*   r    r   r   r   r  r  r  r  r  r  r  xi_lt_yir  r  r   r)   r   r    r  r  c                    v   t ||dtjd |jd  fdd|D \}}|j}|j}|j}|j}	 d||}
 d||	} |
|S )Nr[   r  r   c                    r  r  r  r   r)   r   r   r,     r  z&np_complex_eq_impl.<locals>.<listcomp>r^   )r$   r   r  r   r   r   r   rg   )r+   r*   r    r   r   r   r  r  r  r  r  xi_eq_yir   r)   r   r       
r  c                    r  )Nr[   r  r   c                    r  r  r  r   r)   r   r   r,     r  z&np_complex_ne_impl.<locals>.<listcomp>rb   )r$   r   r  r   r   r   fcmp_unorderedrh   )r+   r*   r    r   r   r   r  r  r  r  xr_ne_yrxi_ne_yir   r)   r   np_complex_ne_impl  r  r  c                 C   s8   | j |||d}t||j}t||j}|||S )Nr   )rH   r   is_truer   r   rh   )r+   r*   r   valcomplex_valre_trueim_truer   r   r   _complex_is_true  s   r  c                 C   >   t ||dtjd t||d }t||d }|||S Nr[   r  r   r]   )r$   r   r  r   r  rg   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   rg   r  r   r   r   np_complex_logical_and_impl     r  c                 C   r  r  )r$   r   r  r   r  rh   r  r   r   r   np_logical_or_impl  r  r  c                 C   r  r  )r$   r   r  r  r   rh   r  r   r   r   np_complex_logical_or_impl  r  r  c                 C   r  r  )r$   r   r  r   r  rn   r  r   r   r   np_logical_xor_impl  r  r  c                 C   r  r  )r$   r   r  r  r   rn   r  r   r   r   np_complex_logical_xor_impl  r  r  c                 C   "   t ||dtjd t||d S Nr]   r  r   )r$   r   r  r   is_falser   r   r   r   np_logical_not_impl     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_impl   s   
r  c                 C   0   t ||d |\}}|d||}||||S Nr[   r   r$   rm   ro   )r+   r*   r    r   arg1arg2arg1_sge_arg2r   r   r   np_int_smax_impl/     r   c                 C   r  r  r$   rf   ro   )r+   r*   r    r   r  r  arg1_uge_arg2r   r   r   np_int_umax_impl6  r  r  c                 C   h   t ||d |\}}|d||}|d||}||||}|d||}	||	||}
||||
S Nr[   unor   r$   r  ro   r   )r+   r*   r    r   r  r  arg1_nanany_nan
nan_resultr  non_nan_resultr   r   r   np_real_maximum_impl=     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_implL  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 Nr[   r   
r$   r   r   r   r   r  np_complex_isnan_implrh   ro   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_implq     
r  c                 C   r  Nr[   rt  r  )r+   r*   r    r   r  r  arg1_sle_arg2r   r   r   np_int_smin_impl  r  r  c                 C   r  r  r  )r+   r*   r    r   r  r  arg1_ule_arg2r   r   r   np_int_umin_impl  r  r!  c                 C   r  Nr[   r  rt  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  rh   ro   r  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 Nr]   r  r$   r   r  r   	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  r2  c                 C   <   t ||dtjd |\}|j\}| j|||d}t||S Nr]   r  r   )r$   r   r  r   rH   r
   r1  r+   r*   r    r   r  r   r  r   r   r   r    s
   r  c                 C   r+  r,  )r$   r   r  r   true_bitr   r   r   r   np_int_isfinite_impl  r0  r7  c                 C   &   t ||dtjd |d|d tjS )Nr]   r  rb   r   )r$   r   r  rf   r	   NATr   r   r   r   np_datetime_isfinite_impl     r:  c                 C   r8  )Nr]   r  r^   r   )r$   r   r  rm   r	   r9  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_impl  r  r>  c                 C   r3  r4  )r$   r   r  r   rH   r
   r=  r5  r   r   r   np_complex_isfinite_impl  
   r?  c                 C   r+  r,  r-  r   r   r   r   np_int_isinf_impl  r0  rA  c                 C   r  r  )r$   r   r  r   is_infr   r   r   r   np_real_isinf_impl  r  rC  c                 C   r3  r4  )r$   r   r  r   rH   r
   rB  r5  r   r   r   np_complex_isinf_impl  r@  rD  c                 C   sb   t ||dtjd tjdtjdi}tjtjg|jR  }t	| ||||d}|
d||d}|S )Nr]   r  numba_signbitfnumba_signbitsignbitrb   r   )r$   r   r  r   r5   r   r   intcr   rZ   rf   rd   )r+   r*   r    r   r   r*  int_resbool_resr   r   r   np_real_signbit_impl!  s   
rK  c                 C   r   r   )r$   r   copysign_float_implr   r   r   r   np_real_copysign_impl0  r   rM  c                 C   r   )Nr[   npy_nextafterfnpy_nextafter	nextafterr   r   r   r   r   np_real_nextafter_impl5  r   rQ  c                 C   r   )Nr]   npy_spacingfnpy_spacingspacingr   r   r   r   r   np_real_spacing_impl@  r   rU  c           	      C   sH   |\}}|j \}}| |||tj}t||tj}t| ||||fS r   )r   r'   r   rH  r   r   r   
ldexp_impl)	r+   r*   r    r   x1x2ty1ty2f_fi_sigr   r   r   np_real_ldexp_implL  s
   
r\  r   )__doc__mathllvmlite.irr/   numpyr  numba.core.imputilsr   
numba.corer   r   r   r   r   numba.core.extendingr   numba.npr	   numba.cpythonr
   r   r   rA  rG  r5  r$   r5   r=   rZ   r   r   r   r   r   r   np_int_fmod_implr   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r$  r(  r+  r.  r/  r3  r8  r:  r;  r?  rC  rF  rI  rK  rQ  rS  rZ  r\  r]  ra  rc  rg  ro  rr  rs  r}  rM  r  rL  r  r  r  r  r  rV  rU  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/  r2  r  r7  r:  r<  r>  r?  rA  rC  rD  rK  rM  rQ  rU  r\  r   r   r   r   <module>   s   

>%M6		 
*)				