o
    8ήcd                     @   s	  d dl 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mZmZ d dlmZmZmZmZmZmZ d dlmZmZ d dlm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j%ej%dd Z&e
ej'ej%ej%e
ej(ej%ej%dd Z)e
ej*ej%ej%e
ej+ej%ej%dd Z,e
ej-ej%ej%e
ej.ej%ej%dd Z/dd Z0d d! Z1e
ej2ej%ej3e
ej4ej%ej3e
ej2ej5ej3e
ej4ej5ej3d"d# Z6d$d% Z7d&d' Z8d(d) Z9d*d+ Z:d,d- Z;d.d/ Z<d0d1 Z=d2d3 Z>d4d5 Z?d6d7 Z@d8d9 ZAd:d; ZBd<d= ZCd>d? ZDd@dA ZEdBdC ZFdDdE ZGdFdG ZHdHdI ZIdJdK ZJdLdM ZKdNdO ZLdPdQ ZMe
ejNejOejOe? e
ejPejOejOe@ e
ejQejOejOe; e
ejRejOejOe< e
ejSejOejOe= e
ejTejOejOe> e
ejUejOeL e
ejVejOeM dRdS ZWdTdU ZXeW  eX  dVdW ZYdXdY ZZdZd[ Z[d\d] Z\d^d_ Z]d`da Z^e
e$ej5ej5ddbdcZ_ddddeZ`ddfdgZadhdi Zbdjdk Zcdldm Zddndo Zedpdq Zfdrds Zgdtdu Zhdvdw Zidxdy Zjdzd{ Zkd|d} Zlej5Zme
ejnememeY e
ejoememeY e
ejpememeZ e
ejqememeZ e
ejrememe[ e
ejsememe[ e
ej'ememea e
ej(ememea e
ej*ememe\ e
ej+ememe\ e
ej-ememe` e
ej.ememe` e
ej2ememeb e
ej4ememeb e
e2ememeb e
ejNememeg e
ejPememeh e
ejQememec e
ejRememed e
ejSememee e
ejTememef e
etemei e
ejUemej e
ejVemek [meejud~dd Zveejuddd Zwe
dejudd Zxdd Zydd Zzdd Z{ej5ej%fD ]Z|ee|d~ey ee|dez e
de|e{ qe
ej2ejuejue
ej4ejuejue
e2ejuejudd Z}dd Z~dd Zdd ZedZdd Zdd Zdd Zdd Zdd Zdd ZejuZme
ejnememe~ e
ejoememe~ e
ejpememe e
ejqememe e
ejrememe e
ejsememe e
ej*ememe e
ej+ememe e
ejUeme e
ejVeme e
ejNememe e
ejPememe e
eteme [me
deje
dejdd Zdd Ze
eejdd Ze
eej%dd Ze
eej5dd Ze
eejudd Zej%ej5ejufD ]Zme
ejeme qe
ejejOe eej3ej%eej3ej5eej3ejudd Zeej%ej%dd Zeej%ejdd Zeej5ej5dd Zeej%ej5dd Zeej5ej%dd Zeej5ejueej%ejudd Zeejuejudd Zeejejdd Zeejejdd Zeej3ejeejejddĄ ZeejuddƄ Zeej%eej5eejddȄ Zddʄ Zeej5d˃e eej%d˃e dS )    N)ir)Constant)lower_builtinlower_getattrlower_getattr_generic
lower_castlower_constantimpl_ret_borrowedimpl_ret_untracked)typingtypesutilserrorscgutilsoptional)	intrinsicoverload_methodviewerc                 C   s   | j rdgS g S )z;
    Return the modifier flags for integer arithmetic.
    nsw)signed)rettype r   </tmp/pip-target-vg8gfxp4/lib/python/numba/cpython/numbers.py_int_arith_flags   s   r   c                 C   \   |\}}|j \}}| ||||j}| ||||j}	|j||	t|jd}
t| ||j|
S N)flags)argscastreturn_typeaddr   r
   contextbuildersigr   vavbtatbabresr   r   r   int_add_impl#      
r-   c                 C   r   r   )r   r   r    subr   r
   r"   r   r   r   int_sub_impl,   r.   r0   c                 C   r   r   )r   r   r    mulr   r
   r"   r   r   r   int_mul_impl5   r.   r2   c              
   C   s  |j |j ksJ | d}| d}t||}t||}||d|| |j|d|| d}	|j||	dd |||}
|	||}|d|
|||}|d||}|||}||N\}}| ||
| ||| W d	   n1 sw   Y  | |||
|| ||||| W d	   n1 sw   Y  W d	   n1 sw   Y  W d	   n1 sw   Y  ||||fS )
a@  
    Reference Objects/intobject.c
    xdivy = x / y;
    xmody = (long)(x - (unsigned long)xdivy * y);
    /* If the signs of x and y differ, and the remainder is non-0,
     * C89 doesn't define whether xdivy is now the floor or the
     * ceiling of the infinitely precise quotient.  We want the floor,
     * and we have it iff the remainder's sign matches y's.
     */
    if (xmody && ((y ^ xmody) < 0) /* i.e. and signs differ */) {
        xmody += y;
        --xdivy;
        assert(xmody && ((y ^ xmody) >= 0));
    }
    *p_xdivy = xdivy;
    *p_xmody = xmody;
    r      ==Tlikely<!=N)typer   alloca_once_valueand_icmp_signedminvalif_thennot_sdivsremxorif_elsestorer/   r!   load)r#   r$   tyxyZEROONEresdivresmodis_overflowxdivyxmodyy_xor_xmody_ltzxmody_istruecondif_different_signsif_same_signsr   r   r   int_divmod_signed>   s:   

rV   c                 C   s.   |j rt| ||||S ||||||fS )zD
    Integer divmod(x, y).  The caller must ensure that y != 0.
    )r   rV   udivurem)r#   r$   rG   rH   rI   r   r   r   
int_divmodw   s   rY   c              	   C   sf  |\}}|j \}}|j}	t|	tjr|	j}	| ||||	}
| ||||	}tj||
j	dd}tj||
j	dd}|j
t||dde\}}| | j||fs\||| ||| W d    n1 sfw   Y  | t| ||	|
|\}}||| ||| W d    n1 sw   Y  W d    ||fS W d    ||fS 1 sw   Y  ||fS )NquotnameremFr6   )r   r    
isinstancer   UniTupledtyper   r   alloca_oncer:   rD   is_scalar_zeroerror_modelfp_zero_divisionrE   rY   )r#   r$   r%   r   zerodiv_messager&   r'   r(   r)   rG   r*   r+   rZ   r]   if_zeroif_non_zeroqrr   r   r   _int_divmod_impl   s>   


rj   c                 C   s0   t | |||d\}}t|||||fS )Nzinteger divmod by zero)rj   r   
pack_arrayrF   r#   r$   r%   r   rZ   r]   r   r   r   int_divmod_impl   s   
rm   c                 C   s   t | |||d\}}||S )Nzinteger division by zerorj   rF   rl   r   r   r   int_floordiv_impl      

ro   c                 C   s   |\}}|j \}}| ||||j}| ||||j}	t||	 | j|d W d    n1 s3w   Y  |||	}
t| ||j|
S )Nzdivision by zero)	r   r   r    r   rf   rc   rd   fdivr
   r"   r   r   r   int_truediv_impl   s   
rs   c                 C   s   t | |||d\}}||S )Nzinteger modulo by zerorn   rl   r   r   r   int_rem_impl   rp   rt   c                 C   s&   t |tjr| jjsd|jd > S dS )Nr5   r3   F)r^   r   Integerrc   raise_on_fp_zero_divisionbitwidth)r#   r    r   r   r   _get_power_zerodiv_return   s
   rx   c                    sR   t |jd tj |jt|  fdd}| ||||}t| ||j|S )z@
    a ^ b, where a is an integer or real, and b an integer
    r   c                    s   d}| } |dk r0d}| }|dk rt  r/| dkr%r!S td| dkr/| dkr/dS nd}|}|dkr@t| t|S |dkrX|d@ rL|| 9 }|dL }| | 9 } |dksD|r^d| S |S )	Nr3   r   T&0 cannot be raised to a negative powerr5   F         ?)OverflowErrorZeroDivisionErrormathpowfloat)r*   r+   ri   invertexp
is_integertpzerodiv_returnr   r   	int_power   s4   z!int_power_impl.<locals>.int_power)r^   r   r   ru   r    rx   compile_internalr
   )r#   r$   r%   r   r   r,   r   r   r   int_power_impl   s   
r   c                    s  |j d j}t|tjstt|dkrt|dk }t|}|j}t|tj	t
| ||  |d |j d |}|j} fdd}	|d}
|}|dkrc|d@ rV|	|
|}
|dL }|	||}|dksM|rrnfdd}ndd }|  |t|||
f}
|
S )	zH
    a ^ b, where a is an integer or real, and b a constant integer
    r3   rz   r   c                    s   r  | |S  | |S N)r1   fmul)r*   r+   )r$   r   r   r   r1     s   zstatic_power_impl.<locals>.mulc                    s0   | dkr r S t d| dkr| dkrdS | S )Nr   ry   r3   r5   )r}   r*   )r   r   r   invert_impl$  s   z&static_power_impl.<locals>.invert_implc                 S   s   d|  S )Nr{   r   r   r   r   r   r   1  s   )r   valuer^   numbersIntegralNotImplementedErrorabsr    r   ru   rx   r   r:   r   r   	signature)r#   r$   r%   r   r   r   r   valltyr1   r,   r*   r   r   )r$   r   r   r   static_power_impl   s:   


r   c                 C   "   |j dg|R  }t| ||j|S Nr8   r=   r
   r    r#   r$   r%   r   r,   r   r   r   int_slt_impl:     r   c                 C   r   Nz<=r   r   r   r   r   int_sle_impl?  r   r   c                 C   r   N>r   r   r   r   r   int_sgt_implD  r   r   c                 C   r   Nz>=r   r   r   r   r   int_sge_implI  r   r   c                 C   r   r   icmp_unsignedr
   r    r   r   r   r   int_ult_implN  r   r   c                 C   r   r   r   r   r   r   r   int_ule_implS  r   r   c                 C   r   r   r   r   r   r   r   int_ugt_implX  r   r   c                 C   r   r   r   r   r   r   r   int_uge_impl]  r   r   c                 C   r   Nr4   r   r   r   r   r   int_eq_implb  r   r   c                 C   r   Nr9   r   r   r   r   r   int_ne_implg  r   r   c           	      C   sH   |\}t |jd }|d||}||}||||}t| ||j|S r   )r   r:   r=   negselectr
   r    )	r#   r$   r%   r   rH   rJ   ltznegatedr,   r   r   r   int_abs_impll  s   
r   c                 C      |\}t | ||j|S r   r
   r    )r#   r$   r%   r   rH   r   r   r   uint_abs_implu     r   c           	      C   sR   |j \}}|\}}| ||||j}| ||||j}|||}t| ||j|S r   )r   r   r    shlr
   	r#   r$   r%   r   valtyamttyr   amtr,   r   r   r   int_shl_implz     
r   c           	      C   sh   |j \}}|\}}| ||||j}| ||||j}|jjr&|||}n|||}t| ||j|S r   )r   r   r    r   ashrlshrr
   r   r   r   r   int_shr_impl  s   
r   c                 C   R   |j \}}|\}}| ||||j}| ||||j}	|||	}
t| ||j|
S r   )r   r   r    r<   r
   r#   r$   r%   r   atbtavbvcavcbcr,   r   r   r   int_and_impl  r   r   c                 C   r   r   )r   r   r    or_r
   r   r   r   r   int_or_impl  r   r   c                 C   r   r   )r   r   r    rC   r
   r   r   r   r   int_xor_impl  r   r   c                 C   s:   |j \}|\}||}| ||||j}t| ||j|S r   )r   r   r   r    r
   r#   r$   r%   r   typr   r,   r   r   r   int_negate_impl  s
   
r   c                 C   0   |j \}|\}| ||||j}t| ||j|S r   r   r   r    r
   r   r   r   r   int_positive_impl     r   c                 C   sR   |j \}|\}||t|jtd|jj d}| ||||j}t| ||j|S )N1   )	r   rC   r   r:   intwidthr   r    r
   r   r   r   r   int_invert_impl  s
   "r   c                 C   s  |\}t |jd}t |jd}t |jd}|d||}|d||}	t||j}
|d}|d}|d}|d	}|d
}|||| || |	||
 |
| W d   n1 sew   Y  || ||	|| W d   n1 sw   Y  || |	||
 |
| W d   n1 sw   Y  || |	||
 |
| W d   n1 sw   Y  || ||
}t| ||j|S )z
    np.sign(int)
    r3   r5   r   r4   r   z.zeroz.postestz.posz.negz.exitN)r   r:   r   r=   r   ra   append_basic_blockcbranch
goto_blockrE   branchposition_at_endrF   r
   r    )r#   r$   r%   r   rH   POSNEGrJ   cmp_zerocmp_pospresultbb_zero
bb_postestbb_posbb_negbb_exitr,   r   r   r   int_sign_impl  s>   






r   c                 C   s:   |j \}|\}| ||||j}||}t| ||j|S r   )r   r   r    r   r
   r   r   r   r   bool_negate_impl  
   
r   c                 C   r   r   r   r   r   r   r   bool_unary_positive_impl  r   r   c                  C   s  t j} ttj| | t ttj| | t ttj| | t ttj	| | t ttj
| | t ttj| | t ttj| | t ttj| | t ttj| | t ttj| | t ttj| | t ttj| | t ttj| t ttj| t ttj| | t ttj| | t tt| | t t jD ]J} ttj| | t  ttj!| | t" ttj#| | t$ ttj%| | t& ttjt j'| t ttjt j'| t ttt j'| t tt(| t) qttjt j*t j*t+ ttj#t j*t j*t+ ttj!t j*t j*t+ ttj%t j*t j*t+ t j,D ]K} ttj| | t+ ttj!| | t- ttj#| | t. ttj%| | t/ ttjt j'| t ttjt j'| t ttt j'| t tt(| t0 qd S r   )1r   ru   r   operatorr!   r-   iaddr/   r0   isubr1   r2   imuleqr   ner   lshiftr   ilshiftrshiftr   irshiftr   r   posr   r   r   ipowunsigned_domainltr   ler   gtr   ger   Floatr   r   IntegerLiteralr   signed_domainr   r   r   r   rG   r   r   r   _implement_integer_operators  sR   

r  c                  C   s   t jt jfD ]@} ttj| | t ttj| | t ttj| | t	 ttj
| | t	 ttj| | t ttj| | t ttj| t qd S r   )r   Booleanru   r   r   r<   r   iandr   r   iorrC   r   ixorr   r   r   r   r   r   _implement_bitwise_operators6  s   r  c                 C      |j | }t| ||j|S r   )faddr
   r    r   r   r   r   real_add_implF     
r	  c                 C   r  r   )fsubr
   r    r   r   r   r   real_sub_implK  r
  r  c                 C   r  r   )r   r
   r    r   r   r   r   real_mul_implP  r
  r  c                 C   sX   t ||d  | j|d W d    n1 sw   Y  |j| }t| ||j|S )Nr3   rq   )r   rf   rc   rd   rr   r
   r    r   r   r   r   real_div_implU  s
   
r  c                 C   s   |j |j ksJ |j }|j}| d|j g}t|||t|f}t|||}|jrQd|_	t
|d}	|j\}
}}t| |	|
|\}}|	|| |	| t||}|||||f}|||fS )Nz.numba.python.remlinkonce_odrentry)r:   modulemanglerr   FunctionTypePointerTyper   get_or_insert_functionis_declarationlinkage	IRBuilderr   r   real_divmod_func_bodyrE   retra   callrF   )r#   r$   rH   rI   floattyr  fnamefntyfn	fnbuilderfxfypmoddivmodquotientr   r   r   real_divmod\  s    
r'  c              
   C   s  t ||j}t ||j}t ||j}|||}|||||}||| ||| |d}	|d}
|d}|d||	}|d||	}|d||	}|j	|ddk\}}|8 |
d||}|| ||||| ||||| W d    n1 sw   Y  W d    n1 sw   Y  | |||
|	}||| W d    n1 sw   Y  W d    n1 sw   Y  ~~||}|d||	}||M tjtjd}|t|j }| tjt||}|||g}|||}|||}t|jd	}|d
||}||||}||| W d    n	1 s3w   Y  t ||$ |||}||| |||||}||| W d    n	1 sfw   Y  ||||fS )N        g       r{   r9   r8   Tr6   )r   doubleg      ?r   )r   ra   r:   fremrr   r  rE   fcmp_unorderedfcmp_orderedrD   r   r?   r  r   rF   r   float32float64strget_functionr~   floorr   r   r   ifnotr   )r#   r$   vxwxr#  pdiv	pfloordivr%  r$  rJ   NZEROrK   
mod_istruewx_ltzmod_ltzif_nonzero_modif_zero_modwx_ltz_ne_mod_ltz
div_istruerealtypemaprealtypefloorfnfloordivfloordivdifffloordivincrHALFpredr   r   r   r  r  sl   .


	

r  c              	   C   s4  |\}}t j||jdd}t j||jdd}|jt ||ddc\}	}
|	( | j|d|sG|||}|||}|	|| |	|| W d    n1 sQw   Y  |
 t
| |||\}}|	|| |	|| W d    n1 sxw   Y  W d    n1 sw   Y  t |||||fS )NrZ   r[   r]   Fr6   zmodulo by zero)r   ra   r:   rD   rb   rc   rd   rr   r*  rE   r'  rk   rF   )r#   r$   r%   r   locrH   rI   rZ   r]   rf   rg   rh   ri   r   r   r   real_divmod_impl  s2   	rI  c              	   C   s   |\}}t ||j}|jt ||ddQ\}}	| | j|d|s0|||}
||
| W d    n1 s:w   Y  |	 t	| |||\}}
||
| W d    n1 s[w   Y  W d    n1 sjw   Y  t
| ||j||S )NFr6   rG  )r   ra   r:   rD   rb   rc   rd   r*  rE   r'  r
   r    rF   )r#   r$   r%   r   rH  rH   rI   r,   rf   rg   r]   _r   r   r   real_mod_impl  *   
rK  c              	   C   s   |\}}t ||j}|jt ||ddQ\}}	| | j|d|s0|||}
||
| W d    n1 s:w   Y  |	 t	| |||\}
}||
| W d    n1 s[w   Y  W d    n1 sjw   Y  t
| ||j||S )NFr6   rq   )r   ra   r:   rD   rb   rc   rd   rr   rE   r'  r
   r    rF   )r#   r$   r%   r   rH  rH   rI   r,   rf   rg   rZ   rJ  r   r   r   real_floordiv_impl  rL  rM  c           
      C   s^   |\}}|j }| jr| tj|}|||}n|d|jg}	||	||f}t| ||j	|S )Nzllvm.pow)
r  implement_powi_as_math_callr0  r~   r   declare_intrinsicr:   r  r
   r    )
r#   r$   r%   r   rH   rI   r  impr,   r  r   r   r   real_power_impl  s   rQ  c                 C   r   r   r,  r
   r    r   r   r   r   real_lt_impl*  r   rS  c                 C   r   r   rR  r   r   r   r   real_le_impl/  r   rT  c                 C   r   r   rR  r   r   r   r   real_gt_impl4  r   rU  c                 C   r   r   rR  r   r   r   r   real_ge_impl9  r   rV  c                 C   r   r   rR  r   r   r   r   real_eq_impl>  r   rW  c                 C   r   r   )r+  r
   r    r   r   r   r   real_ne_implC  r   rX  c                 C   s,   |j \}t||}| tj|}|||S r   )r   r   r   r0  r~   fabs)r#   r$   r%   r   rG   implr   r   r   real_abs_implH  s   
r[  c                 C   s,   ddl m} |||d }t| ||j|S Nr   mathimpl)numba.cpythonr^  negate_realr
   r    )r#   r$   r%   r   r^  r,   r   r   r   real_negate_implO  s   ra  c                 C   r   r   r   r   r   r   r   real_positive_implU  r   rb  c                 C   s~  |\}t |jd}t |jd}t |jd}t||j}|d||}	|d||}
||	{\}}| ||| W d   n1 sEw   Y  |O ||
:\}}| ||| W d   n1 shw   Y  | ||| W d   n1 sw   Y  W d   n1 sw   Y  W d   n1 sw   Y  W d   n1 sw   Y  ||}t| ||j	|S )z
    np.sign(float)
    r3   r5   r   r   r8   N)
r   r:   r   ra   r,  rD   rE   rF   r
   r    )r#   r$   r%   r   rH   r   r   rJ   r   is_posis_neggt_zeronot_gt_zerolt_zeronot_lt_zeror,   r   r   r   real_sign_impl\  s6   
ri  realc                 C   $   | j |||d}|j}t| |||S Nr   )make_complexrj  r
   r#   r$   r   r   cplxr,   r   r   r   complex_real_impl     rq  imagc                 C   rk  rl  )rn  rs  r
   ro  r   r   r   complex_imag_impl  rr  rt  zcomplex.conjugatec                 C   sL   ddl m} | ||jd |d }|||j|_| }t| ||j|S r\  )	r_  r^  rn  r   r`  rs  	_getvaluer
   r    )r#   r$   r%   r   r^  zr,   r   r   r   complex_conjugate_impl  s
   rw  c                 C   s   t | |||S r   )r
   )r#   r$   r   r   r   r   r   real_real_impl  s   rx  c                 C   s   t |j}t| |||S r   )r   get_null_valuer:   r
   )r#   r$   r   r   r,   r   r   r   real_imag_impl  s   rz  c                 C   s   t | ||j|d S Nr   r   r#   r$   r%   r   r   r   r   real_conjugate_impl  s   r}  c              	   C   s  |\}}|j d }|j}| j|||d}| j|||d}	| ||}
|j}| }|	 }|
 }| |d}| |d}|d|	j|}|d|	j|}|	||}|
|m\}}|! t| ||||f}| j|||d}|j|
_|j|
_W d    n1 sw   Y  |. tjdtjdi| }tt |jgd }t|||}|||||f W d    n1 sw   Y  W d    n1 sw   Y  ||}t| ||j|S )Nr   rm  r   r4   numba_cpowf
numba_cpow   )r   underlying_floatmake_helperr  _getpointerget_constantr,  rj  rs  r<   rD   complex_mul_implr   	complex64
complex128r   r  VoidTyper:   r   r  r  rF   r
   r    )r#   r$   r%   r   cacbrG   ftyr*   r+   cr  papbpcTWOrJ   b_real_is_twob_imag_is_zerob_is_twothen	otherwiser,   cres	func_namer  cpowr   r   r   complex_power_impl  sH   


r  c                 C      |\}}|j d }| j|||d}| j|||d}| ||}	|j}
|j}|j}|j}||
||	_||||	_|	 }t| ||j|S Nr   rm  )r   rn  rj  rs  r  ru  r
   r    r#   r$   r%   r   cxcyrG   rH   rI   rv  r*   r+   r  dr,   r   r   r   complex_add_impl     
r  c                 C   r  r  )r   rn  rj  rs  r  ru  r
   r    r  r   r   r   complex_sub_impl  r  r  c                 C   s   |\}}|j d }| j|||d}| j|||d}| ||}	|j}
|j}|j}|j}||
|}|||}||
|}|||}||||	_||||	_|	 }t| ||j	|S )z'
    (a+bi)(c+di)=(ac-bd)+i(ad+bc)
    r   rm  )
r   rn  rj  rs  r   r  r  ru  r
   r    )r#   r$   r%   r   r  r  rG   rH   rI   rv  r*   r+   r  r  acbdadbcr,   r   r   r   r    s"   
r  nanc                 C   (   dd }|  ||||}t| ||j|S )Nc                 S   s   | j }| j}|j }|j}|s|stdt|t|kr>|s#tttS || }|||  }t|||  | |||  | S |sEtttS || }|| | }t| j | | j | | j| | j  | S )Nzcomplex division by zero)rj  rs  r}   r   complexNAN)r*   r+   arealaimagbrealbimagratiodenomr   r   r   complex_div%  s.   

z%complex_div_impl.<locals>.complex_divr   r
   r    )r#   r$   r%   r   r  r,   r   r   r   complex_div_impl$  s   r  c           	      C   sn   ddl m} |j\}|\}| j|||d}| ||}|||j|_|||j|_| }t| ||j	|S )Nr   r]  rm  )
r_  r^  r   rn  r`  rj  rs  ru  r
   r    )	r#   r$   r%   r   r^  r   r   cmplxr,   r   r   r   complex_negate_implD  s   r  c                 C   r   r   r   r#   r$   r%   r   r   r   r   r   complex_positive_implP  r   r  c                 C   r   |\}}|j d }| j|||d}| j|||d}|d|j|j}	|d|j|j}
||	|
}t| ||j|S )Nr   rm  r4   )r   rn  r,  rj  rs  r<   r
   r    )r#   r$   r%   r   r  r  r   rH   rI   reals_are_eqimags_are_eqr,   r   r   r   complex_eq_implU     
r  c                 C   r  )Nr   rm  r9   )r   rn  r+  rj  rs  r   r
   r    )r#   r$   r%   r   r  r  r   rH   rI   reals_are_neimags_are_ner,   r   r   r   complex_ne_impla  r  r  c                 C   r  )z)
    abs(z) := hypot(z.real, z.imag)
    c                 S   s   t | j| jS r   )r~   hypotrj  rs  )rv  r   r   r   complex_absq  s   z%complex_abs_impl.<locals>.complex_absr  )r#   r$   r%   r   r  r,   r   r   r   complex_abs_implm  s   r  znumber.itemc                 C   s   |d S )z;
    The no-op .item() method on booleans and numbers.
    r   r   r|  r   r   r   number_item_impl  s   r  c                 C   s:   |j \}|\}| ||||j}||}t| ||j|S r   )r   r   r    r@   r
   )r#   r$   r%   r   r   r   istruer,   r   r   r   number_not_impl  r   r  c                 C   s
   |\}|S r   r   r  r   r   r   bool_as_bool  s   r  c                 C      |\}| d|t|jdS )Nr9   r   )r   r   r:   r  r   r   r   int_as_bool     r  c                 C   r  )Nr9   r(  )r+  r   r:   r  r   r   r   float_as_bool  r  r  c                 C   s^   |j \}|\}| |||}|j|j}}t|jd}	|d||	}
|d||	}||
|S )Nr(  r9   )r   rn  rj  rs  r   r:   r+  r   )r#   r$   r%   r   r   r   r  rj  rs  zeroreal_istrueimag_istruer   r   r   complex_as_bool  s   r  c                 C   s$   |  ||j|j}| |||j|S r   )get_constant_genericliteral_typeliteral_valuer   r#   r$   fromtytotyr   litr   r   r   literal_int_to_number  s   r  c                 C   sX   |j |j kr|S |j |j k r||| |S |jr#||| |S ||| |S r   )rw   truncget_value_typer   sextzextr#   r$   r  r  r   r   r   r   integer_to_integer  s   r  c                 C   s   | || |S r   )inttoptrr  r  r   r   r   integer_to_voidptr  s   r  c                 C   s.   |  |}|j|jk r|||S |||S r   )r  rw   fpextfptruncr#   r$   r  r  r   r   r   r   r   float_to_float  s   
r  c                 C   s(   |  |}|jr|||S |||S r   )r  r   sitofpuitofpr  r   r   r   integer_to_float     
r  c                 C   s(   |  |}|jr|||S |||S r   )r  r   fptosifptouir  r   r   r   float_to_integer  r  r  c                 C   s@   |  ||||j}| |jd}| ||}||_||_| S r{  )r   r  r  rn  rj  rs  ru  )r#   r$   r  r  r   rj  rs  r  r   r   r   non_complex_to_complex  s   r  c           	      C   sX   |j }|j }| j|||d}| ||}| ||j|||_| ||j|||_| S rl  )r  rn  r   rj  rs  ru  )	r#   r$   r  r  r   srctydsttysrcdstr   r   r   complex_to_complex
  s   r  c                 C   s   |  |||S r   )is_truer  r   r   r   any_to_boolean  s   r  c                 C   s$   | |td}| ||tj|S )N    )r  r   IntTyper   r   int32)r#   r$   r  r  r   asintr   r   r   boolean_to_any  s   r  c                 C   s"   |  ||j|j}| ||j|S r   )r  r  r  r  r  r   r   r   literal_int_to_boolean  s   r  c                 C   s4   |j }| |||j}| |||j}t||fS r   )r  r  rj  rs  r   literal_struct)r#   r$   rG   pyvalr  rj  rs  r   r   r   constant_complex,  s   r  c                 C   s&   t |tjr
t|}| |}||S r   )r^   npbool_boolr  )r#   r$   rG   r  r   r   r   r   constant_integer3  s   
r  c                 C   sL   t | tjtjfr"t |tjjr$| j|jjkrt	ddd }|S dS dS )z) Typing for the np scalar 'view' method. zOChanging the dtype of a 0d array is only supported if the itemsize is unchangedc                 S   s
   t | |S r   r   )scalarviewtyr   r   r   rZ  M  s   
zscalar_view.<locals>.implN)
r^   r   r   ru   abstract	DTypeSpecrw   r`   r   TypingError)r  r   rZ  r   r   r   scalar_viewD  s   r  viewr   )r~   r   numpyr  r   llvmliter   llvmlite.irr   numba.core.imputilsr   r   r   r   r   r	   r
   
numba.corer   r   r   r   r   r   numba.core.extendingr   r   numba.cpython.unsafe.numbersr   r   r-   r0   r2   rV   rY   rj   divmodru   rm   rB  	ifloordivro   truedivitruedivrs   r%  imodrt   rx   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   booleanr   r   r   r   r   r   r   r  r  r	  r  r  r  r'  r  rI  rK  rM  rQ  rS  rT  rU  rV  rW  rX  r[  ra  rb  ri  rG   r!   r   r/   r   r1   r   r   Complexrq  rt  rw  rx  rz  r}  clsr  r  r  r  r   r  r  r  r  r  r  r  r  Numberr  r  r  r  r  r  r  r@   r  r  voidptrr  r  r  r  r  r  Anyr  r  BooleanLiteralr  r  r  r  r   r   r   r   <module>   s   $ 			9

	+=							*0l







) 










		




	




