
    xKg                        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	 d dl
mZmZmZmZ d dlmZ d Zd Zd	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z d Z!d Z"d Z#d Z$d Z%d Z&d Z'd Z(d Z)d  Z*d! Z+d" Z,d# Z-d$ Z.d% Z/d& Z0d' Z1d( Z2d) Z3d* Z4d+ Z5d, Z6d- Z7d. Z8d/ Z9d0 Z:d1 Z;d2 Z<d3 Z=dgd4Z>dgd5Z?dgd6Z@d7 ZAd8 ZBd9 ZCd: ZDd; ZEd< ZFd= ZGd> ZHd? ZId@ ZJdA ZKdB ZLdC ZMdD ZNdE ZOdF ZPdG ZQdH ZRdI ZSdJ ZTdK ZU eVdL      ZWdM ZXdN ZYdO ZZdP Z[dQ Z\dR Z]dS Z^dT Z_dU Z`dV ZadW ZbdX ZcdY ZddZ Zed[ Zfd\ Zgd] Zhd^ Zid_ Zjd` Zkda Zldb Zmdc Zndd Zode Zpdf Zqy)h    N)ir)Constantimpl_ret_untracked)typingtypeserrorscgutilsviewerc                 $    | j                   rdgS g S )z;
    Return the modifier flags for integer arithmetic.
    nsw)signed)rettypes    Y/home/alanp/www/video.onchill/myenv/lib/python3.12/site-packages/numba/np/math/numbers.py_int_arith_flagsr      s     ~~ w	    c                     |\  }}|j                   \  }}| j                  ||||j                        }| j                  ||||j                        }	|j                  ||	t	        |j                              }
t        | ||j                  |
      S N)flags)argscastreturn_typeaddr   r   contextbuildersigr   vavbtatbabress              r   int_add_implr&      {    HRxxHRWb"coo6AWb"coo6A
++a"23??"C+
DCgwEEr   c                     |\  }}|j                   \  }}| j                  ||||j                        }| j                  ||||j                        }	|j                  ||	t	        |j                              }
t        | ||j                  |
      S r   )r   r   r   subr   r   r   s              r   int_sub_implr*   '   r'   r   c                     |\  }}|j                   \  }}| j                  ||||j                        }| j                  ||||j                        }	|j                  ||	t	        |j                              }
t        | ||j                  |
      S r   )r   r   r   mulr   r   r   s              r   int_mul_implr-   0   r'   r   c           
         |j                   |j                   k(  sJ |j                  d      }|j                  d      }t        j                  ||      }t        j                  ||      }|j                  |j	                  d||j                  |j
                              |j	                  d||j                  d                  }	|j                  |j                  |	      d      5  |j                  ||      }
|j                  ||      }|j	                  d|j                  ||      |      }|j	                  d||      }|j                  ||      }|j                  |      5 \  }}|5  |j                  |
|       |j                  ||       d	d	d	       |5  |j                  |j                  |
|      |       |j                  |j                  ||      |       d	d	d	       d	d	d	       d	d	d	       |j                  |      |j                  |      fS # 1 sw Y   xY w# 1 sw Y   GxY w# 1 sw Y   KxY w# 1 sw Y   OxY w)
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_signss                    r   int_divmod_signedrR   9   s   $ 66QVV66!9D
&&)C &&w5F&&w5F,,D!QVVBII%67D!QVVBZ02K 
k24	@ Q"Q"!--c7;;q%3H$O**4=||L/:__T"&I'9=eV,eV,  $gkk%5v>gkk%3V< $ # 
A& <<f!555  $# #" 
A	@sV   (A>H>&H2,%H
H2AH& H2(H>H#H2&H/+H22H;	7H>>Ic                     |j                   rt        | ||||      S |j                  ||      |j                  ||      fS )zD
    Integer divmod(x, y).  The caller must ensure that y != 0.
    )r   rR   udivurem)r   r   rC   rD   rE   s        r   
int_divmodrV   r   s?     
yy '2q!<<||Aq!7<<1#555r   c           	      <   |\  }}|j                   \  }}|j                  }	t        |	t        j                        r|	j
                  }	| j                  ||||	      }
| j                  ||||	      }t        j                  ||
j                  d      }t        j                  ||
j                  d      }|j                  t        j                  ||      d      5 \  }}|5  | j                  j                  ||f      s$|j                  ||       |j                  ||       d d d        |5  t        | ||	|
|      \  }}|j                  ||       |j                  ||       d d d        d d d        ||fS # 1 sw Y   VxY w# 1 sw Y   !xY w# 1 sw Y   ||fS xY w)NquotnameremFr2   )r   r   
isinstancer   UniTupledtyper   r
   alloca_oncer6   r@   is_scalar_zeroerror_modelfp_zero_divisionrA   rV   )r   r   r   r   zerodiv_messager   r    r!   r"   rC   r#   r$   rX   r[   if_zeroif_non_zeroqrs                     r   _int_divmod_implrh   |   sg   FBXXFB	B"enn%XXWb"b)AWb"b)AwV<D


gqvvE
:C	//;E 
4w&&77/+-
 a&a%  gwAq9DAqMM!T"MM!S! 
 9 W [
 9s=   F AE7"
F,7F#F7F 	<FF	FFc                     t        | |||d      \  }}t        j                  ||j                  |      |j                  |      f      S )Nzinteger divmod by zero)rh   r
   
pack_arrayrB   r   r   r   r   rX   r[   s         r   int_divmod_implrl      sN     '3!9;ID# g&||D17<<3DEG Gr   c                 H    t        | |||d      \  }}|j                  |      S )Nzinteger division by zerorh   rB   rk   s         r   int_floordiv_implro      s*     '3!;=ID#<<r   c                    |\  }}|j                   \  }}| j                  ||||j                        }| j                  ||||j                        }	t        j                  ||	      5  | j
                  j                  |d       d d d        |j                  ||	      }
t        | ||j                  |
      S # 1 sw Y   3xY w)Nzdivision by zero)	r   r   r   r
   rd   ra   rb   fdivr   r   s              r   int_truediv_implrs      s    HRxxHRWb"coo6AWb"coo6A	!	$,,W6KL 
%
,,q!
CgwEE 
%	$s   'B66B?c                 H    t        | |||d      \  }}|j                  |      S )Nzinteger modulo by zerorn   rk   s         r   int_rem_implru      s*     '3!9;ID#<<r   c                     t        |t        j                        r(| j                  j                  sd|j
                  dz
  z  S y)Nr1   r/   F)r\   r   Integerra   raise_on_fp_zero_divisionbitwidth)r   r   s     r   _get_power_zerodiv_returnrz      s8    ;.##==k**Q.//r   c                     t        |j                  d   t        j                        |j                  t        |       fd}| j                  ||||      }t        | ||j                  |      S )z@
    a ^ b, where a is an integer or real, and b an integer
    r   c                 0    d      } |       } |dk  r1d}| }|dk  rt         r#| dk(  rrS t        d      | dk7  r
| dk7  ryd}|}|dkD  rt        j                  | t	        |            S |dk7  r|dz  r|| z  }|dz  }| | z  } |dk7  r|rd|z  S |S )	Nr/   r   T&0 cannot be raised to a negative powerr1   F         ?)OverflowErrorZeroDivisionErrormathpowfloat)r#   r$   rg   invertexp
is_integertpzerodiv_returns        r   	int_powerz!int_power_impl.<locals>.int_power   s    qEqEq5F"CQw##6%--/0XYY6a2gFC=88AuQx((QhQwQAICFA	 Qh !sQw'a'r   )r\   r   r   rw   r   rz   compile_internalr   )	r   r   r   r   r   r%   r   r   r   s	         @@@r   int_power_implr      sd     CHHQK7J	B.w;N(> 
"
"7IsD
ACgwEEr   c                 d   |j                   d   j                  }t        |t        j                        st
        t        |      dkD  rt
        |dk  }t        |      }|j                  }t        |t        j                        t        | |      | j                  |d   |j                   d   |      }|j                  }fd}	 |d      }
|}|dk7  r"|dz  r	 |	|
|      }
|dz  } |	||      }|dk7  r"|r4rfd}nd }| j                  |t        j                  ||      |
f      }
|
S )zH
    a ^ b, where a is an integer or real, and b a constant integer
    r/   r~   r   c                 P    rj                  | |      S j                  | |      S N)r,   fmul)r#   r$   r   r   s     r   r,   zstatic_power_impl.<locals>.mul  s(    ;;q!$$<<1%%r   c                 F    | dk(  rrS t        d      | dk7  r| dk7  ry| S )Nr   r}   r/   r1   )r   )r#   r   s    r   invert_implz&static_power_impl.<locals>.invert_impl  s4    6%--/0XYY6a2gHr   c                     d| z  S )Nr    )r#   s    r   r   z&static_power_impl.<locals>.invert_impl,  s    Qwr   )r   valuer\   numbersIntegralNotImplementedErrorabsr   r   rw   rz   r   r6   r   r   	signature)r   r   r   r   r   r   r   valltyr,   r%   r#   r   r   r   s    `           @@r   static_power_implr      s/    ((1+

Cc7++,!!
3x'!!1WF
c(C	BB.J.w;N
,,wQ!b
9C
((C& a&CA
(7c3-C	#sm	 ( 	 &&w'-'7'7B'?#I Jr   c                 X     |j                   dg| }t        | ||j                  |      S Nr4   r9   r   r   r   r   r   r   r%   s        r   int_slt_implr   5  .    
'

c
)D
)CgwEEr   c                 X     |j                   dg| }t        | ||j                  |      S Nz<=r   r   s        r   int_sle_implr   :  .    
'

d
*T
*CgwEEr   c                 X     |j                   dg| }t        | ||j                  |      S N>r   r   s        r   int_sgt_implr   ?  r   r   c                 X     |j                   dg| }t        | ||j                  |      S Nz>=r   r   s        r   int_sge_implr   D  r   r   c                 X     |j                   dg| }t        | ||j                  |      S r   icmp_unsignedr   r   r   s        r   int_ult_implr   I  .    
'


+d
+CgwEEr   c                 X     |j                   dg| }t        | ||j                  |      S r   r   r   s        r   int_ule_implr   N  .    
'


,t
,CgwEEr   c                 X     |j                   dg| }t        | ||j                  |      S r   r   r   s        r   int_ugt_implr   S  r   r   c                 X     |j                   dg| }t        | ||j                  |      S r   r   r   s        r   int_uge_implr   X  r   r   c                 X     |j                   dg| }t        | ||j                  |      S Nr0   r   r   s        r   int_eq_implr   ]  r   r   c                 X     |j                   dg| }t        | ||j                  |      S Nr5   r   r   s        r   int_ne_implr   b  r   r   c                       fd}|S )Nc                 &   |\  }}|j                  d|t        |j                  d            }|j                  
|t        |j                  d            }|j                  
||      }|j	                  |||      }	t        | ||j                  |	      S Nr4   r   r9   r   r6   r   selectr   r   r   r   r   r   leftrightcmp_zerolt_zeroge_zeror%   ops             r   implz%int_signed_unsigned_cmp.<locals>.implh  s    u &&sD(499a2HI%%b$A0FG''D%8nnXw8!'7COOSIIr   r   r   r   s   ` r   int_signed_unsigned_cmpr   g  s    J  Kr   c                       fd}|S )Nc                 &   |\  }}|j                  d|t        |j                  d            }|j                  
t        |j                  d      |      }|j                  
||      }|j	                  |||      }	t        | ||j                  |	      S r   r   r   s             r   r   z%int_unsigned_signed_cmp.<locals>.impl|  s    u&&sE8EJJ3JK%%b(5::q*A5I''D%8nnXw8!'7COOSIIr   r   r   s   ` r   int_unsigned_signed_cmpr   {  s    J Kr   c                     |\  }t        |j                  d       }|j                  d||      }|j                  |      }|j	                  |||      }t        | ||j                  |      S r   )r   r6   r9   negr   r   r   )	r   r   r   r   rD   rF   ltznegatedr%   s	            r   int_abs_implr     sa    
CQAFFD!D


c1d
+Ckk!nG
..gq
)CgwEEr   c                 :    |\  }t        | ||j                  |      S r   r   r   )r   r   r   r   rD   s        r   uint_abs_implr     s    
CQgwCCr   c                     |j                   \  }}|\  }}| j                  ||||j                        }| j                  ||||j                        }|j                  ||      }t	        | ||j                  |      S r   )r   r   r   shlr   	r   r   r   r   valtyamttyr   amtr%   s	            r   int_shl_implr     sm    XXNUEJS#
,,wUCOO
<C
,,wUCOO
<C
++c3
CgwEEr   c                 H   |j                   \  }}|\  }}| j                  ||||j                        }| j                  ||||j                        }|j                  j                  r|j	                  ||      }n|j                  ||      }t        | ||j                  |      S r   )r   r   r   r   ashrlshrr   r   s	            r   int_shr_implr     s    XXNUEJS#
,,wUCOO
<C
,,wUCOO
<C
ll3$ll3$gwEEr   c                     |j                   \  }}|\  }}| j                  ||||j                        }| j                  ||||j                        }	|j                  ||	      }
t	        | ||j                  |
      S r   )r   r   r   r8   r   r   r   r   r   atbtavbvcavcbcr%   s              r   int_and_implr     sm    xxHRHR
,,wB
8C
,,wB
8C
,,sC
 CgwEEr   c                     |j                   \  }}|\  }}| j                  ||||j                        }| j                  ||||j                        }	|j                  ||	      }
t	        | ||j                  |
      S r   )r   r   r   or_r   r   s              r   int_or_implr     m    xxHRHR
,,wB
8C
,,wB
8C
++c3
CgwEEr   c                     |j                   \  }}|\  }}| j                  ||||j                        }| j                  ||||j                        }	|j                  ||	      }
t	        | ||j                  |
      S r   )r   r   r   r?   r   r   s              r   int_xor_implr     r   r   c                     |j                   \  }|\  }|j                  |      }| j                  ||||j                        }t	        | ||j                  |      S r   )r   r   r   r   r   r   r   r   r   typr   r%   s          r   int_negate_implr     sO    HHESES
++c
C
,,wS#//
:CgwEEr   c                     |j                   \  }|\  }| j                  ||||j                        }t        | ||j                  |      S r   r   r   r   r   r   s          r   int_positive_implr     A    HHESES
,,wS#//
:CgwEEr   c           
          |j                   \  }|\  }|j                  |t        |j                  t	        d|j                  j
                  z  d                  }| j                  ||||j                        }t        | ||j                  |      S )N1   )	r   r?   r   r6   intwidthr   r   r   r   s          r   int_invert_implr    sp    HHESES
++c8CHHc#2F.JK
LC
,,wS#//
:CgwEEr   c                    |\  }t        |j                  d      }t        |j                  d      }t        |j                  d      }|j                  d||      }|j                  d||      }	t	        j
                  ||j                        }
|j                  d      }|j                  d      }|j                  d      }|j                  d	      }|j                  d
      }|j                  |||       |j                  |      5  |j                  ||
       |j                  |       ddd       |j                  |      5  |j                  |	||       ddd       |j                  |      5  |j                  ||
       |j                  |       ddd       |j                  |      5  |j                  ||
       |j                  |       ddd       |j                  |       |j                  |
      }t        | ||j                  |      S # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   gxY w)z
    np.sign(int)
    r/   r1   r   r0   r   z.zeroz.postestz.posz.negz.exitN)r   r6   r   r9   r
   r_   append_basic_blockcbranch
goto_blockrA   branchposition_at_endrB   r   r   )r   r   r   r   rD   POSNEGrF   r   cmp_pospresultbb_zero
bb_postestbb_posbb_negbb_exitr%   s                    r   int_sign_implr    s    CQ
1661
C
1662
CAFFAD$$T1d3H!!#q$/G!!'1662G((1G++J7J''/F''/F((1GOOHgz2			G	$dG$w 
% 
		J	'0 
( 
		F	#c7#w 
$ 
		F	#c7#w 
$ G$
,,w
CgwEE# 
%	$ 
(	' 
$	# 
$	#s0   $HH0$H+-$H7HH(+H47I c                     |j                   \  }|\  }| j                  ||||j                        }|j                  |      }t	        | ||j                  |      S r   )r   r   r   r   r   r   s          r   bool_negate_implr    sO    HHESES
,,wS#//
:C
++c
CgwEEr   c                     |j                   \  }|\  }| j                  ||||j                        }t        | ||j                  |      S r   r   r   s          r   bool_unary_positive_implr    r   r   c                 P     |j                   | }t        | ||j                  |      S r   )faddr   r   r   s        r   real_add_implr  a  '    
',,
CgwEEr   c                 P     |j                   | }t        | ||j                  |      S r   )fsubr   r   r   s        r   real_sub_implr  f  r  r   c                 P     |j                   | }t        | ||j                  |      S r   )r   r   r   r   s        r   real_mul_implr  k  r  r   c                     t        j                  ||d         5  | j                  j                  |d       d d d         |j                  | }t        | ||j                  |      S # 1 sw Y   0xY w)Nr/   rq   )r
   rd   ra   rb   rr   r   r   r   s        r   real_div_implr!  p  s^    	$q'	*,,W6KL 
+
',,
CgwEE 
+	*s   A&&A/c                    |j                   |j                   k(  sJ |j                   }|j                  }| j                  d|j                   g      }t        j                  |||t        j
                  |      f      }t        j                  |||      }|j                  rod|_	        t        j                  |j                  d            }	|j                  \  }
}}t        | |	|
|      \  }}|	j                  ||       |	j                  |       t        j                   ||      }|j#                  ||||f      }||j%                  |      fS )Nz.numba.python.remlinkonce_odrentry)r6   modulemanglerr   FunctionTypePointerTyper
   get_or_insert_functionis_declarationlinkage	IRBuilderr  r   real_divmod_func_bodyrA   retr_   callrB   )r   r   rD   rE   floattyr%  fnamefntyfn	fnbuilderfxfypmoddivmodquotients                   r   real_divmodr;  w  s   66QVVffG^^FOO/!&&:E??7Wgr~~g7N$OPD		'	'e	<B	#
LL!6!6w!?@	wwB()RDST"cw0D||BAt-HW\\$'''r   c           	         t        j                  ||j                        }t        j                  ||j                        }t        j                  ||j                        }|j                  ||      }|j	                  |j                  ||      |      }|j                  ||       |j                  ||       |j                  d      }	|j                  d      }
|j                  d      }|j                  d||	      }|j                  d||	      }|j                  d||	      }|j                  |d      5 \  }}|5  |j                  d||      }|j                  |      5  |j                  |j                  ||      |       |j                  |j                  ||      |       d d d        d d d        |5  |j                  ||
|	      }|j                  ||       d d d        d d d        ~~|j                  |      }|j                  d||	      }|j                  |      5  t        j                   t        j"                  d}|t%        |j                           }| j'                  t(        j*                  t-        j.                  ||            } |||g      }|j                  ||      }|j                  ||      }t1        |j                  d	      }|j                  d
||      }|j                  |||      }|j                  ||       d d d        t        j2                  ||      5  |j5                  ||      }|j                  ||       |j	                  |j5                  ||      |      }|j                  ||       d d d        |j                  |      |j                  |      fS # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   kxY w)N        g       r   r5   r4   Tr2   )r   doubleg      ?r   )r
   r_   r6   fremrr   r  rA   fcmp_unorderedfcmp_orderedr@   r   r;   r  r   rB   r   float32float64strget_functionr   floorr   r   r   ifnotr   )r   r   vxwxr7  pdiv	pfloordivr9  r8  rF   NZEROrG   
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preds                              r   r-  r-    sH   \ w0Dw0D##GRWW5I
,,r2
C
,,w||B,b
1CMM#tMM#t 773<DGGDME
''#,C''c48J!!#r40F""3T2G	D	15Rnk !( 5 5dFG L!23gll34d;gll33T: 4   ..5CMM#t$	  
2  	S
,,t
C%%dC6J		$ %!&0s277|,&&tzz'-'7'7('KM7SE*||C2||Hc2%##Ct<>>$h?h	* 
% 
w
	+ll3$c4 <<S" 5r:h	*	 
, <<	"GLL$666G 43 ^ [ 
2	1* 
%	$ 
,	+so   8O>%N?#AN2(N?0
O:&O O'C*O&/AO22N<7N??O		OO	OO#&O/2O;c                    |\  }}t        j                  ||j                  d      }t        j                  ||j                  d      }|j                  t        j                  ||      d      5 \  }	}
|	5  | j
                  j                  |d|      sH|j                  ||      }|j                  ||      }|j                  ||       |j                  ||       d d d        |
5  t        | |||      \  }}|j                  ||       |j                  ||       d d d        d d d        t        j                  ||j                  |      |j                  |      f      S # 1 sw Y   xY w# 1 sw Y   SxY w# 1 sw Y   WxY w)NrX   rY   r[   Fr2   zmodulo by zero)r
   r_   r6   r@   r`   ra   rb   rr   r?  rA   r;  rj   rB   )r   r   r   r   locrD   rE   rX   r[   rd   re   rf   rg   s                r   real_divmod_implr_    sP   DAqwV<D


gqvvE
:C	//;E 
4w&&77,c3 LLA&LLA&a&a%  wA6DAqMM!T"MM!S! 
  g&||D17<<3DEG G W [
 
s=   1E;7A&E#
E;'6E/E;#E,	(E;/E8	4E;;Fc                 <   |\  }}t        j                  ||j                        }|j                  t        j                  ||      d      5 \  }}	|5  | j
                  j                  |d|      s$|j                  ||      }
|j                  |
|       d d d        |	5  t        | |||      \  }}
|j                  |
|       d d d        d d d        t        | ||j                  |j                  |            S # 1 sw Y   fxY w# 1 sw Y   DxY w# 1 sw Y   HxY w)NFr2   r]  )r
   r_   r6   r@   r`   ra   rb   r?  rA   r;  r   r   rB   )r   r   r   r   r^  rD   rE   r%   rd   re   r[   _s               r   real_mod_implrb    s    DAq


gqvv
.C	//;E 
4w&&77,c3 ll1a(c3'   '1a8FAsMM#s# 
 gw%ll3/1 1 W [
 
=   DAC:
D$DD:D	?DD	DDc                 <   |\  }}t        j                  ||j                        }|j                  t        j                  ||      d      5 \  }}	|5  | j
                  j                  |d|      s$|j                  ||      }
|j                  |
|       d d d        |	5  t        | |||      \  }
}|j                  |
|       d d d        d d d        t        | ||j                  |j                  |            S # 1 sw Y   fxY w# 1 sw Y   DxY w# 1 sw Y   HxY w)NFr2   rq   )r
   r_   r6   r@   r`   ra   rb   rr   rA   r;  r   r   rB   )r   r   r   r   r^  rD   rE   r%   rd   re   rX   ra  s               r   real_floordiv_implre  &  s    DAq


gqvv
.C	//;E 
4w&&77.5 ||Aq)dC(  !'7Aq9GD!MM$$ 
 gw%ll3/1 1 W [
 
rc  c                 "   |\  }}|j                   }| j                  r*| j                  t        j                  |      } |||      }n1|j                  d|j                  g      }	|j                  |	||f      }t        | ||j                  |      S )Nzllvm.pow)
r%  implement_powi_as_math_callrE  r   r   declare_intrinsicr6   r/  r   r   )
r   r   r   r   rD   rE   r%  impr%   r3  s
             r   real_power_implrj  9  s    DAq^^F**""488S1'4 %%j166(;ll21v&gwEEr   c                 X     |j                   dg| }t        | ||j                  |      S r   rA  r   r   r   s        r   real_lt_implrm  E  .    
'

s
*T
*CgwEEr   c                 X     |j                   dg| }t        | ||j                  |      S r   rl  r   s        r   real_le_implrp  J  .    
'

t
+d
+CgwEEr   c                 X     |j                   dg| }t        | ||j                  |      S r   rl  r   s        r   real_gt_implrs  O  rn  r   c                 X     |j                   dg| }t        | ||j                  |      S r   rl  r   s        r   real_ge_implru  T  rq  r   c                 X     |j                   dg| }t        | ||j                  |      S r   rl  r   s        r   real_eq_implrw  Y  rq  r   c                 X     |j                   dg| }t        | ||j                  |      S r   )r@  r   r   r   s        r   real_ne_implry  ^  s.    
 '
 
 
-
-CgwEEr   c                     |j                   \  }t        j                  ||      }| j                  t        j
                  |      } |||      S r   )r   r   r   rE  r   fabs)r   r   r   r   rC   r   s         r   real_abs_implr|  c  sB    88DR


2r
"C		3/Dr   c                 h    ddl m} |j                  ||d         }t        | ||j                  |      S Nr   mathimpl)numba.cpythonr  negate_realr   r   )r   r   r   r   r  r%   s         r   real_negate_implr  j  s0    &


wQ
0CgwEEr   c                     |j                   \  }|\  }| j                  ||||j                        }t        | ||j                  |      S r   r   r   s          r   real_positive_implr  p  r   r   c           	      4   |\  }t        |j                  d      }t        |j                  d      }t        |j                  d      }t        j                  ||j                        }|j	                  d||      }	|j	                  d||      }
|j                  |	      5 \  }}|5  |j                  ||       ddd       |5  |j                  |
      5 \  }}|5  |j                  ||       ddd       |5  |j                  ||       ddd       ddd       ddd       ddd       |j                  |      }t        | ||j                  |      S # 1 sw Y   xY w# 1 sw Y   sxY w# 1 sw Y   bxY w# 1 sw Y   fxY w# 1 sw Y   jxY w# 1 sw Y   nxY w)z
    np.sign(float)
    r/   r1   r   r   r4   N)
r   r6   r
   r_   rA  r@   rA   rB   r   r   )r   r   r   r   rD   r	  r
  rF   r  is_posis_neggt_zeronot_gt_zeror   not_lt_zeror%   s                   r   real_sign_implr  w  sJ    CQ
1661
C
1662
CAFFAD!!'1662G!!#q$/F!!#q$/F		 $:WkMM#w' (,BWkMM#w/   MM!W- ! )  
! ,,w
CgwEE W W [ )( [ 
!	 s   F$E7
FFE6E	,
E66E*		E6FFE	FE'#E6*E3/E66E?;FF	FFc                 ^    | j                  |||      }|j                  }t        | |||      S Nr   )make_complexrealr   r   r   r   r   cplxr%   s         r   complex_real_implr    3    E:D
))CgwS99r   c                 ^    | j                  |||      }|j                  }t        | |||      S r  )r  imagr   r  s         r   complex_imag_implr    r  r   c                     ddl m} | j                  ||j                  d   |d         }|j	                  ||j
                        |_        |j                         }t        | ||j                  |      S r~  )	r  r  r  r   r  r  	_getvaluer   r   )r   r   r   r   r  zr%   s          r   complex_conjugate_implr    s]    &Wchhqk47;A!!'1662AF
++-CgwEEr   c                     t        | |||      S r   r   )r   r   r   r   s       r   real_real_implr    s    gwU;;r   c                 \    t        j                  |j                        }t        | |||      S r   )r
   get_null_valuer6   r   )r   r   r   r   r%   s        r   real_imag_implr    s'    

 
 
,CgwS99r   c                 8    t        | ||j                  |d         S Nr   r   r   r   r   r   s       r   real_conjugate_implr    s    gwaIIr   c           	         |\  }}|j                   d   }|j                  }| j                  |||      }| j                  |||      }	| j                  ||      }
|j                  }|j	                         }|	j	                         }|
j	                         }| j                  |d      }| j                  |d      }|j                  d|	j                  |      }|j                  d|	j                  |      }|j                  ||      }|j                  |      5 \  }}|5  t        | ||||f      }| j                  |||      }|j                  |
_        |j                  |
_        d d d        |5  t        j                  dt        j                  di|   }t        j                   t        j"                         |j$                  gdz        }t'        j(                  |||      }|j+                  ||||f       d d d        d d d        |j-                  |      }t/        | ||j0                  |      S # 1 sw Y   xY w# 1 sw Y   FxY w# 1 sw Y   JxY w)Nr   r  r   r0   numba_cpowf
numba_cpow   )r   underlying_floatmake_helperr%  _getpointerget_constantrA  r  r  r8   r@   complex_mul_implr   	complex64
complex128r   r'  VoidTyper6   r
   r)  r/  rB   r   r   )r   r   r   r   cacbrC   ftyr#   r$   cr%  papbpcTWOrF   b_real_is_twob_imag_is_zerob_is_twothen	otherwiser%   cres	func_namer2  cpows                              r   complex_power_implr    s   HR	!B


CGRr2AGRr2AGR(A^^F	
B	
B	
B 

sA
&CQ'D((qvvs;M))$=N||M>:H		"&7tY"7GS2r(CC&&w#&>DYYAFYYAF     , I ??2;;=277)a-@D11&$	JDLLB|,  
#$ ,,r
CgwEE% T Y 
#	"s>   IAH0%
I/BH<7I0H9	5I<I	IIc                    |\  }}|j                   d   }| j                  |||      }| j                  |||      }| j                  ||      }	|j                  }
|j                  }|j                  }|j                  }|j	                  |
|      |	_        |j	                  ||      |	_        |	j                         }t        | ||j                  |      S Nr   r  )r   r  r  r  r  r  r   r   r   r   r   r   cxcyrC   rD   rE   r  r#   r$   r  dr%   s                  r   complex_add_implr        HR	!BWb3AWb3AWb)A	A	A	A	A\\!QAF\\!QAF
++-CgwEEr   c                    |\  }}|j                   d   }| j                  |||      }| j                  |||      }| j                  ||      }	|j                  }
|j                  }|j                  }|j                  }|j	                  |
|      |	_        |j	                  ||      |	_        |	j                         }t        | ||j                  |      S r  )r   r  r  r  r  r  r   r   r  s                  r   complex_sub_implr    r  r   c                 :   |\  }}|j                   d   }| j                  |||      }| j                  |||      }| j                  ||      }	|j                  }
|j                  }|j                  }|j                  }|j	                  |
|      }|j	                  ||      }|j	                  |
|      }|j	                  ||      }|j                  ||      |	_        |j                  ||      |	_        |	j                         }t        | ||j                  |      S )z'
    (a+bi)(c+di)=(ac-bd)+i(ad+bc)
    r   r  )
r   r  r  r  r   r  r  r  r   r   )r   r   r   r   r  r  rC   rD   rE   r  r#   r$   r  r  acbdadbcr%   s                      r   r  r  &  s    HR	!BWb3AWb3AWb)A	A	A	A	A	a	B	a	B	a	B	a	B\\"b!AF\\"b!AF
++-CgwEEr   nanc                 `    d }| j                  ||||      }t        | ||j                  |      S )Nc                    | j                   }| j                  }|j                   }|j                  }|s|st        d      t        |      t        |      k\  rA|st	        t
        t
              S ||z  }|||z  z   }t	        |||z  z   |z  |||z  z
  |z        S |st	        t
        t
              S ||z  }||z  |z   }t	        | j                   |z  | j                  z   |z  | j                  |z  | j                   z
  |z        S )Nzcomplex division by zero)r  r  r   r   complexNAN)r#   r$   arealaimagbrealbimagratiodenoms           r   complex_divz%complex_div_impl.<locals>.complex_div@  s   U#$>??u:U#sC((EMEEEM)E&%/&%/1 1
 sC((EMEEME)E%!&&(E1%!&&(E13 3r   r   r   r   )r   r   r   r   r  r%   s         r   complex_div_implr  ?  s4    36 
"
"7Kd
CCgwEEr   c                 R   ddl m} |j                  \  }|\  }| j                  |||      }| j                  ||      }|j	                  ||j
                        |_        |j	                  ||j                        |_        |j                         }t        | ||j                  |      S )Nr   r  r  )
r  r  r   r  r  r  r  r  r   r   )	r   r   r   r   r  r   r   cmplxr%   s	            r   complex_negate_implr  _  s    &HHESES  #S 9E


w
,C##GUZZ8CH##GUZZ8CH
--/CgwEEr   c                 :    |\  }t        | ||j                  |      S r   r   r   r   r   r   r   s        r   complex_positive_implr  k  s    ESgwEEr   c                 j   |\  }}|j                   d   }| j                  |||      }| j                  |||      }|j                  d|j                  |j                        }	|j                  d|j                  |j                        }
|j                  |	|
      }t        | ||j                  |      S )Nr   r  r0   )r   r  rA  r  r  r8   r   r   )r   r   r   r   r  r  r   rD   rE   reals_are_eqimags_are_eqr%   s               r   complex_eq_implr  p  s    HR
((1+CWc4AWc4A''affaff=L''affaff=L
,,|\
2CgwEEr   c                 j   |\  }}|j                   d   }| j                  |||      }| j                  |||      }|j                  d|j                  |j                        }	|j                  d|j                  |j                        }
|j                  |	|
      }t        | ||j                  |      S )Nr   r  r5   )r   r  r@  r  r  r   r   r   )r   r   r   r   r  r  r   rD   rE   reals_are_neimags_are_ner%   s               r   complex_ne_implr  |  s    HR
((1+CWc4AWc4A))$?L))$?L
++lL
1CgwEEr   c                 `    d }| j                  ||||      }t        | ||j                  |      S )z)
    abs(z) := hypot(z.real, z.imag)
    c                 V    t        j                  | j                  | j                        S r   )r   hypotr  r  )r  s    r   complex_absz%complex_abs_impl.<locals>.complex_abs  s    zz!&&!&&))r   r  )r   r   r   r   r  r%   s         r   complex_abs_implr    s4    * 
"
"7Kd
CCgwEEr   c                     |d   S )z;
    The no-op .item() method on booleans and numbers.
    r   r   r  s       r   number_item_implr    s     7Nr   c                     |j                   \  }|\  }| j                  ||||j                        }|j                  |      }t	        | ||j                  |      S r   )r   r   r   r<   r   )r   r   r   r   r   r   istruer%   s           r   number_not_implr    sO    HHESES\\'3S__=F
,,v
CgwEEr   c                     |\  }|S r   r   r  s        r   bool_as_boolr    s    ESJr   c                 X    |\  }|j                  d|t        |j                  d            S )Nr5   r   )r   r   r6   r  s        r   int_as_boolr    s)    ES  sHSXXq,ABBr   c                 X    |\  }|j                  d|t        |j                  d            S )Nr5   r=  )r@  r   r6   r  s        r   float_as_boolr    s)    ES!!$Xchh-DEEr   c                    |j                   \  }|\  }| j                  |||      }|j                  |j                  }}t	        |j
                  d      }	|j                  d||	      }
|j                  d||	      }|j                  |
|      S )Nr=  r5   )r   r  r  r  r   r6   r@  r   )r   r   r   r   r   r   r  r  r  zeroreal_istrueimag_istrues               r   complex_as_boolr    s    HHESES  #s3EUZZ$DDIIs#D((tT:K((tT:K;;{K00r   c                     | j                  ||j                  |j                        }| j                  |||j                  |      S r   )get_constant_genericliteral_typeliteral_valuer   r   r   fromtytotyr   lits         r   literal_int_to_numberr    sD    

&
&
C
 <<f&9&94@@r   c                 H   |j                   |j                   k(  r|S |j                   |j                   k  r!|j                  || j                  |            S |j                  r!|j	                  || j                  |            S |j                  || j                  |            S r   )ry   truncget_value_typer   sextzextr   r   r  r	  r   s        r   integer_to_integerr    s    }}'
		(}}S'"8"8">??	||C!7!7!=>> ||C!7!7!=>>r   c                 D    |j                  || j                  |            S r   )inttoptrr  r  s        r   integer_to_voidptrr    s     C!7!7!=>>r   c                     | j                  |      }|j                  |j                  k  r|j                  ||      S |j                  ||      S r   )r  ry   fpextfptruncr   r   r  r	  r   r   s         r   float_to_floatr    sD    

 
 
&C&}}S#&&sC((r   c                     | j                  |      }|j                  r|j                  ||      S |j                  ||      S r   )r  r   sitofpuitofpr  s         r   integer_to_floatr    s;    

 
 
&C}}~~c3''~~c3''r   c                     | j                  |      }|j                  r|j                  ||      S |j                  ||      S r   )r  r   fptosifptouir  s         r   float_to_integerr"    s;    

 
 
&C{{~~c3''~~c3''r   c                     | j                  ||||j                        }| j                  |j                  d      }| j                  ||      }||_        ||_        |j                         S r  )r   r  r  r  r  r  r  )r   r   r  r	  r   r  r  r  s           r   non_complex_to_complexr$    sa    <<fd.C.CDD 5 5q9D  $/EEJEJ??r   c                 *   |j                   }|j                   }| j                  |||      }| j                  ||      }| j                  ||j                  ||      |_        | j                  ||j                  ||      |_        |j                         S r  )r  r  r   r  r  r  )	r   r   r  r	  r   srctydsttysrcdsts	            r   complex_to_complexr*  &  s    ##E!!E


wc

:C


w
-C||GSXXue<CH||GSXXue<CH==?r   c                 (    | j                  |||      S r   )is_truer  s        r   any_to_booleanr-  1  s    ??7FC00r   c                     |j                  |t        j                  d            }| j                  ||t        j
                  |      S )N    )r  r   IntTyper   r   int32)r   r   r  r	  r   asints         r   boolean_to_anyr3  5  s3    LLbjjn-E<<T::r   c                     | j                  ||j                  |j                        }| j                  ||j                  |      S r   )r  r  r  r,  r  s         r   literal_int_to_booleanr5  <  sB    

&
&
C
 ??7F$7$7==r   c                     |j                   }| j                  |||j                        }| j                  |||j                        }t	        j
                  ||f      S r   )r  r  r  r  r   literal_struct)r   r   rC   pyvalr  r  r  s          r   constant_complexr9  H  sR    


C''ejjAD''ejjAD""D$<00r   c                 ~    t        |t        j                        rt        |      }| j	                  |      } ||      S r   )r\   npbool_boolr  )r   r   rC   r8  r   s        r   constant_integerr>  Q  s5    
 %"U

 
 
$Cu:r   c                    t        | t        j                  t        j                  f      rbt        |t        j                  j
                        r=| j                  |j                  j                  k7  rt        j                  d      d }|S yy)z) Typing for the np scalar 'view' method. zOChanging the dtype of a 0d array is only supported if the itemsize is unchangedc                     t        | |      S r   r   )scalarviewtys     r   r   zscalar_view.<locals>.implh  s    &&))r   N)
r\   r   Floatrw   abstract	DTypeSpecry   r^   r	   TypingError)rA  rB  r   s      r   scalar_viewrG  _  so    6EKK7865>>#;#;<??fll333$$() )	* = 	9r   r   )rr   r   numpyr;  llvmliter   llvmlite.irr   numba.core.imputilsr   
numba.corer   r   r	   r
   numba.cpython.unsafe.numbersr   r   r&   r*   r-   rR   rV   rh   rl   ro   rs   ru   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  r!  r;  r-  r_  rb  re  rj  rm  rp  rs  ru  rw  ry  r|  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r"  r$  r*  r-  r3  r5  r9  r>  rG  r   r   r   <module>rN     sM         2 5 5 /"FFF66r6>GF(F^:zF
F
F
F
F
F
F
F
F
F
(	FD
F	FFFFFFF'FTFFbF
F
F
F(,i7ZG21&1&	FF
F
F
F
F
F
FFF@::F<:J'FRF F F. ElF@	FF
	F	FFFF
C
F
14A??)((1;>1r   