o
    ºiÉÃ  ã                   @   sø	  d dl Z 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 d dlmZmZmZmZ d dl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„ Z,d d!„ Z-eej.ej!ej/ƒeej0ej!ej/ƒeej.ej1ej/ƒeej0ej1ej/ƒd"d#„ ƒƒƒƒZ2d$d%„ Z3d&d'„ Z4d(d)„ Z5d*d+„ Z6d,d-„ Z7d.d/„ Z8d0d1„ Z9d2d3„ Z:d4d5„ Z;d6d7„ Z<d8d9„ Z=d:d;„ Z>d<d=„ Z?d>d?„ Z@d@dA„ ZAdBdC„ ZBdDdE„ ZCdFdG„ ZDdHdI„ ZEdJdK„ ZFdLdM„ ZGdNdO„ ZHdPdQ„ ZIdRdS„ ZJdTdU„ ZKeejLejMejMƒe;ƒ eejNejMejMƒe<ƒ eejOejMejMƒe7ƒ eejPejMejMƒe8ƒ eejQejMejMƒe9ƒ eejRejMejMƒe:ƒ eejSejMƒeJƒ eejTejMƒeKƒ dVdW„ ZUdXdY„ ZVeUƒ  eVƒ  dZd[„ ZWd\d]„ ZXd^d_„ ZYd`da„ ZZdbdc„ Z[ddde„ Z\ee ej1ej1ƒdÐdfdg„ƒZ]dÐdhdi„Z^dÐdjdk„Z_dldm„ Z`dndo„ Zadpdq„ Zbdrds„ Zcdtdu„ Zddvdw„ Zedxdy„ Zfdzd{„ Zgd|d}„ Zhd~d„ Zid€d„ Zjej1ZkeejlekekƒeWƒ eejmekekƒeWƒ eejnekekƒeXƒ eejoekekƒeXƒ eejpekekƒeYƒ eejqekekƒeYƒ eej#ekekƒe_ƒ eej$ekekƒe_ƒ eej&ekekƒeZƒ eej'ekekƒeZƒ eej)ekekƒe^ƒ eej*ekekƒe^ƒ eej.ekekƒe`ƒ eej0ekekƒe`ƒ ee.ekekƒe`ƒ eejLekekƒeeƒ eejNekekƒefƒ eejOekekƒeaƒ eejPekekƒebƒ eejQekekƒecƒ eejRekekƒedƒ eerekƒegƒ eejSekƒehƒ eejTekƒeiƒ [keejsd‚ƒdƒd„„ ƒZteejsd…ƒd†d‡„ ƒZuedˆejsƒd‰dŠ„ ƒZvd‹dŒ„ ZwddŽ„ Zxdd„ Zyej1ej!fD ]Zzeezd‚ƒewƒ eezd…ƒexƒ edˆezƒeyƒ qeej.ejsejsƒeej0ejsejsƒee.ejsejsƒd‘d’„ ƒƒƒZ{d“d”„ Z|d•d–„ Z}d—d˜„ Z~ed™ƒZ€dšd›„ Zdœd„ Z‚dždŸ„ Zƒd d¡„ Z„d¢d£„ Z…d¤d¥„ Z†ejsZkeejlekekƒe|ƒ eejmekekƒe|ƒ eejnekekƒe}ƒ eejoekekƒe}ƒ eejpekekƒe~ƒ eejqekekƒe~ƒ eej&ekekƒeƒ eej'ekekƒeƒ eejSekƒe‚ƒ eejTekƒeƒƒ eejLekekƒe„ƒ eejNekekƒe…ƒ eerekƒe†ƒ [ked¦ej‡ƒed¦ejˆƒd§d¨„ ƒƒZ‰d©dª„ ZŠee‹ej‡ƒd«d¬„ ƒZŒee‹ej!ƒd­d®„ ƒZee‹ej1ƒd¯d°„ ƒZŽee‹ejsƒd±d²„ ƒZej!ej1ejsfD ]ZkeejekƒeŠƒ q eejejMƒeŠƒ eej/ej!ƒeej/ej1ƒeej/ejsƒd³d´„ ƒƒƒZ‘eej!ej!ƒdµd¶„ ƒZ’eej!ej“ƒd·d¸„ ƒZ”eej1ej1ƒd¹dº„ ƒZ•eej!ej1ƒd»d¼„ ƒZ–eej1ej!ƒd½d¾„ ƒZ—eej1ejsƒeej!ejsƒd¿dÀ„ ƒƒZ˜eejsejsƒdÁdÂ„ ƒZ™eejšej‡ƒdÃdÄ„ ƒZ›eej‡ejˆƒdÅdÆ„ ƒZœeej/ej‡ƒeejej‡ƒdÇdÈ„ ƒƒZžeejsƒdÉdÊ„ ƒZŸeej!ƒeej1ƒeej‡ƒdËdÌ„ ƒƒƒZ dÍdÎ„ Z¡eej1dÏƒe¡ƒ eej!dÏƒe¡ƒ dS )Ñé    N)Úir)ÚConstant)Úlower_builtinÚlower_getattrÚ
lower_castÚlower_constantÚimpl_ret_untracked)ÚtypingÚtypesÚerrorsÚcgutils)Úoverload_method©Úviewerc                 C   s   | j rdgS g S )z;
    Return the modifier flags for integer arithmetic.
    Únsw)Úsigned)Úrettype© r   úV/home/ubuntu/veenaModal/venv/lib/python3.10/site-packages/numba/cpython/new_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)   r+   c                 C   r   r   )r   r   r   Úmulr   r   r   r   r   r   Úint_mul_impl5   r)   r-   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 s…w   Y  | | | |
|¡|¡ | | ||¡|¡ W d	  ƒ n1 s«w   Y  W d	  ƒ n1 sºw   Y  W d	  ƒ n1 sÉw   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:   

þþþ€û€örQ   c                 C   s.   |j rt| ||||ƒS | ||¡| ||¡fS )zD
    Integer divmod(x, y).  The caller must ensure that y != 0.
    )r   rQ   ÚudivÚurem)r   r   rB   rC   rD   r   r   r   Ú
int_divmodw   s   rT   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 sŽw   Y  W d   ƒ ||fS W d   ƒ ||fS 1 sªw   Y  ||fS )NÚquot©ÚnameÚremFr1   )r   r   Ú
isinstancer
   ÚUniTupleÚdtyper   r   Úalloca_oncer5   r?   Úis_scalar_zeroÚerror_modelÚfp_zero_divisionr@   rT   )r   r   r    r   Úzerodiv_messager!   r"   r#   r$   rB   r%   r&   rU   rX   Úif_zeroÚif_non_zeroÚqÚrr   r   r   Ú_int_divmod_impl   s>   
ÿ€ùý
öû
öñre   c                 C   s0   t | |||dƒ\}}t || |¡| |¡f¡S )Nzinteger divmod by zero)re   r   Ú
pack_arrayrA   ©r   r   r    r   rU   rX   r   r   r   Úint_divmod_implŸ   s   
ÿÿrh   c                 C   s   t | |||dƒ\}}| |¡S )Nzinteger division by zero©re   rA   rg   r   r   r   Úint_floordiv_impl¨   ó   
ÿ
rj   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   ra   r^   r_   Úfdivr   r   r   r   r   Úint_truediv_impl°   s   
ÿrn   c                 C   s   t | |||dƒ\}}| |¡S )Nzinteger modulo by zerori   rg   r   r   r   Úint_rem_impl½   rk   ro   c                 C   s&   t |tjƒr| jjsd|jd > S dS )Nr0   r.   F)rY   r
   ÚIntegerr^   Úraise_on_fp_zero_divisionÚbitwidth)r   r   r   r   r   Ú_get_power_zerodiv_returnÅ   s
   ÿrs   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 )	Nr.   r   Tú&0 cannot be raised to a negative powerr0   Fé   ç      ð?)ÚOverflowErrorÚZeroDivisionErrorÚmathÚpowÚfloat)r%   r&   rd   ÚinvertÚexp©Ú
is_integerÚtpÚzerodiv_returnr   r   Ú	int_powerÖ   s4   €üz!int_power_impl.<locals>.int_power)rY   r   r
   rp   r   rs   Ú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
    r.   ru   r   c                    s   ˆrˆ   | |¡S ˆ  | |¡S ©N)r,   Úfmul)r%   r&   )r   r   r   r   r,     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   rt   r.   r0   )rx   ©r%   )r   r   r   Úinvert_impl$  s   z&static_power_impl.<locals>.invert_implc                 S   s   d|  S )Nrv   r   r‡   r   r   r   rˆ   1  s   )r   ÚvaluerY   ÚnumbersÚIntegralÚNotImplementedErrorÚabsr   r
   rp   rs   r   r5   rƒ   r	   Ú	signature)r   r   r    r   r}   r|   r€   ÚvalÚltyr,   r'   r%   rˆ   r   )r   r   r   r   Ústatic_power_implù   s:   


üÿr‘   c                 C   ó"   |j dg|¢R Ž }t| ||j|ƒS ©Nr3   ©r8   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’   ©Nr/   rŸ   r•   r   r   r   Úint_eq_implb  r—   r¦   c                 C   r’   ©Nr4   rŸ   r•   r   r   r   Úint_ne_implg  r—   r¨   c                    ó   ‡ fdd„}|S )Nc           
         s`   |\}}|  d|t|jdƒ¡}|  ˆ |t|jdƒ¡}| ˆ ||¡}| |||¡}	t| ||j|	ƒS ©Nr3   r   ©r8   r   r5   r    Úselectr   r   ©
r   r   r    r   ÚleftÚrightÚcmp_zeroÚlt_zeroÚge_zeror'   ©Úopr   r   Úimplm  s   
z%int_signed_unsigned_cmp.<locals>.implr   ©r´   rµ   r   r³   r   Úint_signed_unsigned_cmpl  s   r·   c                    r©   )Nc           
         s`   |\}}|  d|t|jdƒ¡}|  ˆ t|jdƒ|¡}| ˆ ||¡}| |||¡}	t| ||j|	ƒS rª   r«   r­   r³   r   r   rµ     s   z%int_unsigned_signed_cmp.<locals>.implr   r¶   r   r³   r   Úint_unsigned_signed_cmp€  s   r¸   c           	      C   sH   |\}t |jd ƒ}| d||¡}| |¡}| |||¡}t| ||j|ƒS r“   )r   r5   r8   Únegr¬   r   r   )	r   r   r    r   rC   rE   ÚltzÚnegatedr'   r   r   r   Úint_abs_implŒ  s   
r¼   c                 C   ó   |\}t | ||j|ƒS r…   ©r   r   )r   r   r    r   rC   r   r   r   Úuint_abs_impl•  ó   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_implš  ó   
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   r7   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   r>   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   r>   r   r5   Ú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 s¡w   Y  | |¡ | 	||
¡ | 
|¡ W d  ƒ n1 sÁw   Y  | |¡ | |
¡}t| ||j|ƒS )z
    np.sign(int)
    r.   r0   r   r/   r›   z.zeroz.postestz.posz.negz.exitN)r   r5   r    r8   r   r\   Úappend_basic_blockÚcbranchÚ
goto_blockr@   ÚbranchÚposition_at_endrA   r   r   )r   r   r    r   rC   ÚPOSÚNEGrE   r°   Ú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)ƒ qœ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tj%t j*t j*ƒt+ƒ t, -t j.t j/¡D ]K} ttj| | ƒt+ƒ ttj!| | ƒt0ƒ ttj#| | ƒt1ƒ ttj%| | ƒt2ƒ ttjt j'| ƒtƒ ttjt j'| ƒtƒ ttt j'| ƒtƒ tt(| ƒt3ƒ qd S r…   )4r
   rp   r   Úoperatorr   r(   Úiaddr*   r+   Úisubr,   r-   ÚimulÚeqr¦   Úner¨   ÚlshiftrÆ   ÚilshiftÚrshiftrÊ   Úirshiftr¹   rÙ   ÚposrÜ   rz   r„   ÚipowÚnp_unsigned_domainÚltr¡   Úler¢   Úgtr£   Úger¤   ÚFloatr   r¿   ÚIntegerLiteralr–   Ú	itertoolsÚchainÚpy_signed_domainÚnp_signed_domainr™   rœ   rž   r¼   ©rB   r   r   r   Ú_implement_integer_operators&  sV   
ÿ÷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
   ÚBooleanrp   r   rõ   r7   rÓ   ÚiandrÔ   rÕ   Úiorr>   rÖ   Úixorr|   râ   r  r   r   r   Ú_implement_bitwise_operatorsW  s   ør  c                 C   ó   |j |Ž }t| ||j|ƒS r…   )Úfaddr   r   r•   r   r   r   Úreal_add_implg  ó   
r  c                 C   r  r…   )Úfsubr   r   r•   r   r   r   Úreal_sub_impll  r  r  c                 C   r  r…   )r†   r   r   r•   r   r   r   Úreal_mul_implq  r  r  c                 C   sX   t  ||d ¡ | j |d¡ W d   ƒ n1 sw   Y  |j|Ž }t| ||j|ƒS )Nr.   rl   )r   ra   r^   r_   rm   r   r   r•   r   r   r   Úreal_div_implv  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)r5   ÚmoduleÚmanglerr   ÚFunctionTypeÚPointerTyper   Úget_or_insert_functionÚis_declarationÚlinkageÚ	IRBuilderrã   r   Úreal_divmod_func_bodyr@   Úretr\   ÚcallrA   )r   r   rC   rD   Úfloattyr  ÚfnameÚfntyÚfnÚ	fnbuilderÚfxÚfyÚpmodÚdivÚmodÚquotientr   r   r   Úreal_divmod}  s    
r3  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 sœw   Y  | | ||
|	¡}| ||¡ W d   ƒ n1 s»w   Y  W d   ƒ n1 sÊw   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       €rv   r4   r3   Tr1   )r{   Údoubleg      à?r›   )r   r\   r5   Úfremrm   r  r@   Úfcmp_unorderedÚfcmp_orderedr?   r    r:   r  r¬   rA   r
   Úfloat32Úfloat64ÚstrÚget_functionry   Úfloorr	   rŽ   r   Úifnotr†   )r   r   ÚvxÚwxr/  ÚpdivÚ	pfloordivr1  r0  rE   ÚNZEROrF   Ú
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%  “  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 s‡w   Y  t  || |¡| |¡f¡S )NrU   rV   rX   Fr1   ©zmodulo by zero)r   r\   r5   r?   r]   r^   r_   rm   r6  r@   r3  rf   rA   )r   r   r    r   ÚlocrC   rD   rU   rX   ra   rb   rc   rd   r   r   r   Úreal_divmod_implÿ  s2   ÿ€ø	ý€õÿrU  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 )NFr1   rS  )r   r\   r5   r?   r]   r^   r_   r6  r@   r3  r   r   rA   )r   r   r    r   rT  rC   rD   r'   ra   rb   rX   Ú_r   r   r   Úreal_mod_impl  ó*   ÿ€úþ€÷
ÿrW  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 )NFr1   rl   )r   r\   r5   r?   r]   r^   r_   rm   r@   r3  r   r   rA   )r   r   r    r   rT  rC   rD   r'   ra   rb   rU   rV  r   r   r   Úreal_floordiv_impl,  rX  rY  c           
      C   s^   |\}}|j }| jr|  tj|¡}|||ƒ}n| d|jg¡}	| |	||f¡}t| ||j	|ƒS )Nzllvm.pow)
r  Úimplement_powi_as_math_callr<  ry   rz   Údeclare_intrinsicr5   r'  r   r   )
r   r   r    r   rC   rD   r  Úimpr'   r+  r   r   r   Úreal_power_impl?  s   r]  c                 C   r’   r“   ©r8  r   r   r•   r   r   r   Úreal_lt_implK  r—   r_  c                 C   r’   r˜   r^  r•   r   r   r   Úreal_le_implP  r—   r`  c                 C   r’   rš   r^  r•   r   r   r   Úreal_gt_implU  r—   ra  c                 C   r’   r   r^  r•   r   r   r   Úreal_ge_implZ  r—   rb  c                 C   r’   r¥   r^  r•   r   r   r   Úreal_eq_impl_  r—   rc  c                 C   r’   r§   )r7  r   r   r•   r   r   r   Úreal_ne_impld  r—   rd  c                 C   s,   |j \}t ||¡}|  tj|¡}|||ƒS r…   )r   r	   rŽ   r<  ry   Úfabs)r   r   r    r   rB   rµ   r   r   r   Úreal_abs_impli  s   
rf  c                 C   s,   ddl m} | ||d ¡}t| ||j|ƒS ©Nr   ©Úmathimpl)Únumba.cpythonri  Únegate_realr   r   )r   r   r    r   ri  r'   r   r   r   Úreal_negate_implp  s   rl  c                 C   rÚ   r…   rÛ   r×   r   r   r   Úreal_positive_implv  rÝ   rm  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 s€w   Y  W d  ƒ n1 sw   Y  W d  ƒ n1 sžw   Y  W d  ƒ n1 s­w   Y  | |¡}t| ||j	|ƒS )z
    np.sign(float)
    r.   r0   r   r›   r3   N)
r   r5   r   r\   r8  r?   r@   rA   r   r   )r   r   r    r   rC   rè   ré   rE   rë   Úis_posÚis_negÚgt_zeroÚnot_gt_zeror±   Únot_lt_zeror'   r   r   r   Úreal_sign_impl}  s6   ÿÿý€ý€ÿ€ý
rs  Úrealc                 C   ó$   | j |||d}|j}t| |||ƒS ©N©r‰   )Úmake_complexrt  r   ©r   r   rØ   r‰   Úcplxr'   r   r   r   Úcomplex_real_impl¼  ó   r{  Úimagc                 C   ru  rv  )rx  r}  r   ry  r   r   r   Úcomplex_imag_implÂ  r|  r~  zcomplex.conjugatec                 C   sL   ddl m} |  ||jd |d ¡}| ||j¡|_| ¡ }t| ||j|ƒS rg  )	rj  ri  rx  r   rk  r}  Ú	_getvaluer   r   )r   r   r    r   ri  Úzr'   r   r   r   Úcomplex_conjugate_implÈ  s
   r  c                 C   s   t | |||ƒS r…   )r   )r   r   rØ   r‰   r   r   r   Úreal_real_implÐ  s   r‚  c                 C   s   t  |j¡}t| |||ƒS r…   )r   Úget_null_valuer5   r   )r   r   rØ   r‰   r'   r   r   r   Úreal_imag_implÓ  s   r„  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 s¹w   Y  W d   ƒ n1 sÈw   Y  | |¡}t| ||j|ƒS )Nr   rw  rß   r/   Únumba_cpowfÚ
numba_cpowé   )r   Úunderlying_floatÚmake_helperr  Ú_getpointerÚget_constantr8  rt  r}  r7   r?   Úcomplex_mul_implr
   Ú	complex64Ú
complex128r   r  ÚVoidTyper5   r   r!  r'  rA   r   r   )r   r   r    r   ÚcaÚcbrB   Úftyr%   r&   Úcr  ÚpaÚpbÚpcÚTWOrE   Ú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   rw  )r   rx  rt  r}  r  r  r   r   ©r   r   r    r   ÚcxÚcyrB   rC   rD   r€  r%   r&   r–  Údr'   r   r   r   Úcomplex_add_impl  ó   
rª  c                 C   r¤  r¥  )r   rx  rt  r}  r  r  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   rw  )
r   rx  rt  r}  r†   r  r  r  r   r   )r   r   r    r   r§  r¨  rB   rC   rD   r€  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)rt  r}  rx   r   ÚcomplexÚNAN)r%   r&   ÚarealÚaimagÚbrealÚbimagÚratioÚdenomr   r   r   Úcomplex_divF  s.   
þ
þz%complex_div_impl.<locals>.complex_div©rƒ   r   r   )r   r   r    r   r»  r'   r   r   r   Úcomplex_div_implE  s   r½  c           	      C   sn   ddl m} |j\}|\}| j|||d}|  ||¡}| ||j¡|_| ||j¡|_| ¡ }t| ||j	|ƒS )Nr   rh  rw  )
rj  ri  r   rx  rk  rt  r}  r  r   r   )	r   r   r    r   ri  rØ   r   Úcmplxr'   r   r   r   Úcomplex_negate_imple  s   r¿  c                 C   r½   r…   r¾   ©r   r   r    r   r   r   r   r   Úcomplex_positive_implq  rÀ   rÁ  c                 C   ór   |\}}|j d }| j|||d}| j|||d}| d|j|j¡}	| d|j|j¡}
| |	|
¡}t| ||j|ƒS )Nr   rw  r/   )r   rx  r8  rt  r}  r7   r   r   )r   r   r    r   r§  r¨  rØ   rC   rD   Úreals_are_eqÚimags_are_eqr'   r   r   r   Úcomplex_eq_implv  ó   
rÅ  c                 C   rÂ  )Nr   rw  r4   )r   rx  r7  rt  r}  rÔ   r   r   )r   r   r    r   r§  r¨  rØ   rC   rD   Úreals_are_neÚimags_are_ner'   r   r   r   Úcomplex_ne_impl‚  rÆ  rÉ  c                 C   r²  )z)
    abs(z) := hypot(z.real, z.imag)
    c                 S   s   t  | j| j¡S r…   )ry   Úhypotrt  r}  )r€  r   r   r   Úcomplex_abs’  s   z%complex_abs_impl.<locals>.complex_absr¼  )r   r   r    r   rË  r'   r   r   r   Úcomplex_abs_implŽ  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 )Nr4   r   )r    r   r5   rÀ  r   r   r   Úint_as_boolÇ  ó   rÒ  c                 C   rÑ  )Nr4   r4  )r7  r   r5   rÀ  r   r   r   Úfloat_as_boolÌ  rÓ  rÔ  c                 C   s^   |j \}|\}|  |||¡}|j|j}}t|jdƒ}	| d||	¡}
| d||	¡}| |
|¡S )Nr4  r4   )r   rx  rt  r}  r   r5   r7  rÔ   )r   r   r    r   rØ   r   r¾  rt  r}  Ú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…   )rr   Ú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â  rr   Ú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Ž  rx  rt  r}  r  )r   r   rÝ  rÞ  r   rt  r}  r¾  r   r   r   Únon_complex_to_complex!  s   rô  c           	      C   sX   |j }|j }| j|||d}|  ||¡}|  ||j||¡|_|  ||j||¡|_| ¡ S rv  )r‹  rx  r   rt  r}  r  )	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_boolean7  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_booleanA  s   ýr  c                 C   s4   |j }|  |||j¡}|  |||j¡}t ||f¡S r…   )r‹  rÙ  rt  r}  r   Úliteral_struct)r   r   rB   Úpyvalr•  rt  r}  r   r   r   Úconstant_complexN  s   r  c                 C   s&   t |tjƒr
t|ƒ}|  |¡}||ƒS r…   )rY   ÚnpÚbool_Úboolrâ  )r   r   rB   r  r   r   r   r   Úconstant_integerU  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   rµ   o  s   
zscalar_view.<locals>.implN)
rY   r
   r  rp   ÚabstractÚ	DTypeSpecrr   r[   r   ÚTypingError)r	  r
  rµ   r   r   r   Úscalar_viewf  s   ÿÿ÷r  Úviewr…   )¢ry   rŠ   r  Únumpyr  rõ   Úllvmliter   Úllvmlite.irr   Únumba.core.imputilsr   r   r   r   r   Ú
numba.corer	   r
   r   r   Únumba.core.extendingr   Únumba.cpython.unsafe.numbersr   r   r(   r+   r-   rQ   rT   re   Údivmodrp   rh   rN  Ú	ifloordivrj   ÚtruedivÚitruedivrn   r1  Úimodro   rs   r„   rz   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ù   Úpy_boolrú   r  r  r  r  r¹   rÿ   r  r  r  r  r  r  r3  r%  rU  rW  rY  r]  r_  r`  ra  rb  rc  rd  rf  rl  rm  rs  rB   r   rö   r*   r÷   r,   rø   r   ÚComplexr{  r~  r  r‚  r„  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

	+=							*1l







) 



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

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