
    i7             
       R1   S r SSKrSSKrSSKrSSKrSSKJr  SSKJr  SSK	r
SSKJrJr  SSKJrJrJrJrJr  SSKJrJrJrJrJrJrJrJrJrJr  SSKJrJ r J!r!  SS	K"J#r#J$r$J%r%J&r&J'r'J(r(J)r)J*r*J+r+J,r,J-r-  SS
K.J/r/  SSK0J1r1  SSK2J3r3J4r4J5r5J6r6J7r7  SSK8J9r9J:r:  SSK;J<r<  SSK=J>r>J?r?  SSK@JArAJBrB  SSK2JCrC  SSKDJErFJGrHJIrIJJrJJKrK  S rLS rMS rNS rOS rPS rQS rRS rSS rT GSYS jrUS rVS rW\4" \W5      S 5       rXS  rY\4" \Y5      S! 5       rZ\#" S"\R                  5      S# 5       r\S$ r]\#" S%\R                  5      \)" \-R                  5      S& 5       5       r` GSYS' jraS( rbS) rc\#" \R                  \R                  \R                  5      \#" \R                  \R                  \R                  5      \#" \R                  \R                  \R                  5      S* 5       5       5       rh\#" \R                  \R                  \R                  5      S+ 5       rj\#" \R                  \R                  \R                  \R                  5      S, 5       rm\#" \n\R                  5      S- 5       ro\#" S.\R                  5      S/ 5       rq\!S0:  a$  \#" S1\R                  \R                  5      S2 5       rr " S3 S4\s5      rt " S5 S6\t5      ru " S7 S8\t5      rv " S9 S:\t5      rw " S; S<\t5      rx " S= S>\t5      ry " S? S@\s5      rzSA r{\#" \R                  \R                  \R                  5      SB 5       r|SC r}SD r~SE rSF rSG rSH rSI rSJ r\6SK 5       r\6SL 5       r\3SM 5       rSN r\4" \
GR                  5      SO 5       r\3SP 5       r\4" \
GR                  5      SQ 5       r\4" \
GR                  5      SR 5       rSS r\4" \STSU9SV 5       r\4" \SWSU9SX 5       rSY rSZ r\#" S[\R                  5      S\ 5       rS] r\#" S[\R                  \R                  5      S^ 5       r\#" S[\R                  \GR0                  " \R                  5      5      S_ 5       r\4" \
GR4                  5      GSYS` j5       r\$" \R                  Sa5      Sb 5       r\4" \
GR:                  5      GSZSc j5       r\4" \
GR>                  5      GSZSd j5       r\4" \
GRB                  5      GS[Se j5       rSf rSg r\#" Sh\R                  \R                  5      Si 5       r\#" Sh\R                  \GR0                  " \R                  5      5      Sj 5       r\!Sk:  a  \4" \
GRN                  5      Sl 5       rO\4" \
GRN                  5      Sm 5       r\4" \
GRR                  5      Sn 5       r\4" \
GRV                  5      GSYSo j5       r\#" Sp\R                  5      Sq 5       r\#" \
GR\                  \R                  5      Sr 5       r\#" Ss\R                  5      St 5       r\3Su 5       r\3Sv 5       r\4" \
GRf                  5      GSYSw j5       r\5" \R                  Sx5      GS\Sy j5       rSz r\4" \
GRn                  5      S{ 5       r\4" \
GRr                  5      S| 5       r\4" \
GRv                  5      S} 5       r\4" \
GRz                  5      S~ 5       r\3S 5       r\Rj                  " \R                  S5      S 5       r\6S 5       rS r\4" \STSU9S 5       r\#" S\R                  \GR                  5      S 5       r\$" \R                  S5      S 5       r\$" \R                  S5      \$" \GR                  S5      S 5       5       r\$" \R                  S5      \$" \GR                  S5      S 5       5       r\$" \R                  S5      \$" \GR                  S5      S 5       5       r\$" \R                  S5      S 5       r\$" \R                  S5      \$" \GR                  S5      S 5       5       r\$" \R                  S5      \$" \GR                  S5      S 5       5       r\$" \GR                  S5      S 5       r\$" \GR                  S5      S 5       r\$" \GR                  S5      S 5       r\$" \GR                  S5      S 5       r\$" \R                  S5      S 5       r\$" \GR                  S5      S 5       r\'" \GR                  \GR                  5      \'" \GR                  \GR                  5      S 5       5       rS r\$" \R                  S5      S 5       r\$" \GR                  S5      \$" \GR                  S5      S 5       5       r\$" \GR                  S5      S 5       r\$" \R                  S5      S 5       r\$" \R                  S5      S 5       rS r\5" \R                  S5      \5" \R                  S5      S 5       5       rS r\$" \GR                  S5      " \5        \$" \GR                  S5      " \5        \#" S\GR                  \R                  5      S 5       r\%" \R                  5      S 5       r\#" S\R                  \Rb                  5      S 5       r\%" \GR                  5      S 5       r\&" \GR                  5      S 5       r\#" S\GR                  \Rb                  5      S 5       r\#" S\GR                  \GR                  5      S 5       r\#" S\GR                  \Rb                  \R                  5      S 5       r\#" S\GR                  \GR                  \R                  5      S 5       r\(" \R                  5      S 5       r\(" \GR                  5      S 5       r\(" \GR                  5      S 5       r\#" \GR                  \R                  \R                  5      S 5       r\7" \R                  S5      S 5       rS rS r  GS\S jr GSYS jrS rS rS r\$" \R                  S5      S 5       r\#" S%\GR                  5      \)" \-R                  5      S 5       5       r\#" \R                  \GR                  \R                  5      S 5       Gr \#" \R                  \GR                  \R                  \R                  5      S 5       Gr\#" \n\GR                  5      S 5       Gr\#" \
GR                  \R                  5      S 5       Gr\#" S%\GR
                  5      \)" \-R                  5      S 5       5       Gr\#" \\GR0                  " \R                  5      5      \#" \
GR                  \GR0                  " \R                  5      5      S 5       5       Gr\#" \\R                  5      \#" \
GR                  \R                  5      S 5       5       Gr	\#" S%\GR                  5      \)" \-R                  5      S 5       5       Gr\#" \
GR                  \R                  5      S 5       Gr\#" S%\GR                  5      \)" \-R                  5      S 5       5       Gr\#" \GR                   \GR                  \GR                  5      S 5       GrS Gr\C" \R                  SSWSU9S 5       GrS Gr\6S 5       GrS GrS GrS GrS Gr\6S 5       Gr\4" \
GR6                  5      G\4S j5       Gr\6S 5       Gr\4" \
GR>                  5      GSYS j5       Gr \6S 5       Gr!\5" \R                  S5      S 5       Gr"\4" \
GRF                  5      G\4S j5       Gr$\4" \
GRJ                  5      GSYS j5       Gr&\4" \
GRN                  5      GSYS j5       Gr(\4" \
GRR                  5      GSYS j5       Gr*\4" \
GRV                  5      GSYS j5       Gr,\4" \
GRZ                  5      GSYS j5       Gr.\4" \
GR^                  5      GSYS j5       Gr0S Gr1\Rh                  " G\15      S 5       Gr2\Rh                  " \
GRf                  5      SSG\4S j5       Gr4\4" \
GRj                  5      GS]S j5       Gr6\4" \
GRn                  5      S 5       Gr8\4" \
GRr                  5      GS]S j5       Gr:S Gr;\4" \
GRx                  5      \5" \R                  S5      GSYS j5       5       Gr=S Gr>\4" \
GR~                  5      GS\S j5       Gr@\4" \
GR                  5      GSZS j5       GrBS GrC\6S 5       GrD\#" S\R                  5      S 5       GrE\4" \
GR                  5      S 5       GrGGS  GrH\6GS 5       GrI\4" \
GR                  5      GS 5       GrK\4" \
GR                  5      GS 5       GrM\#" GS\R                  \GR                  5      \#" GS\R                  \Rb                  5      GS 5       5       GrN\6GS 5       GrO\5" \R                  GS5      GS 5       GrP\6GS	 5       GrQ\4" \
GR                  5      G\GS
S4GS j5       GrS\4" \5      GSYGS j5       GrT\4" \5      GSYGS j5       GrUGS GrVGS GrWGS GrXGS GrYGS GrZGS Gr[GS Gr\GS Gr]\6GS 5       Gr^\4" \
GR                  5      GSYGS j5       Gr`GS GraGS GrbGS GrcGS Grd\6GS 5       Gre\4" \
GR                  5      GS 5       GrfGS GrgGS Grh\4" \
GR                  5      GS  5       Grj\4" \
GR                  5      GS! 5       Grl\4" \
GR                  5      GS" 5       GrnGS# GroGS$ GrpGS% GrqGS& Grr\6GS' 5       Grs\4" \
GR                  5      GS]GS( j5       GruGS) Grv\6GS* 5       Grw\4" \
GR                  5      GS+ 5       GryGS, Grz\6GS- 5       Gr{\4" \
GR                  5      GS]GS. j5       Gr}GS/ Gr~\6GS0 5       Gr\4" \
GR                   5      GS1 5       Gr\6GS2 5       Gr\4" \
GR                  5      GS3 5       Gr\!S0:  a  \4" \
GR
                  5      " G\5        \6GS4 5       Gr\4" \
GR                  5      GS5 5       Gr\Rj                  " \R                  GS65      GS7 5       Gr\Rj                  " \R                  GS85      GS9 5       Gr\4" \
GR                  5      GS: 5       Gr\4" \
GR                  5      GS; 5       Gr\6GS< 5       Gr\4" \
GR                   5      GS= 5       Gr\4" \
GR$                  5      GS]GS> j5       Gr\4" \
GR(                  5      GS]GS? j5       Gr\4" \
GR,                  5      GS@ 5       Gr\4" \
GR0                  5      GSA 5       Gr\4" \
GR4                  5      GSB 5       Gr0 GrGSC GrGS^GSD jGrGSE Gr\#" GSF\R                  5      GSG 5       Gr\4" \
GRB                  5      GSH 5       Gr\#" GSI\R                  \Rb                  5      \#" \
GRF                  \R                  \Rb                  5      GSJ 5       5       Gr\'" \R                  \R                  5      GSK 5       Gr\'" \R                  \GRL                  5      \'" \R                  \GRN                  5      \'" \R                  \R                  5      \'" \R                  \GRP                  5      \'" \R                  \GRR                  5      \'" \R                  \GRT                  5      \'" \R                  \GRV                  5      GSL 5       5       5       5       5       5       5       Gr\'" \R                  \GRL                  5      GSM 5       GrGSN Gr\GR^                  " G\5      GSO 5       Gr\#" G\\R                  \R                  \R                  5      GSP 5       Gr\Rh                  " \
GRd                  GRf                  GRh                  5      GS_GSQ j5       Gr\Rh                  " \
GRd                  GRf                  GRj                  5      GSYGSR j5       Gr\4" G\5      GSS 5       Gr\4" \
GRp                  5      GST 5       Gr\4" \
GRt                  5      GSU 5       Gr\3GSV 5       Gr\4" \
GRz                  5      GSW 5       Gr\4" \
GR~                  5      GS`GSX j5       Grg(a  z[
Implementation of operations on Array objects and objects supporting
the buffer protocol.
    N)ir)Constant)pndindexliteral_unroll)typestypingerrorscgutils	extending)
as_dtype
from_dtypecarrayfarrayis_contiguous
is_fortrancheck_is_integertype_is_scalar
lt_complex	lt_floats)type_can_asarrayis_nonelikenumpy_version)lower_builtinlower_getattrlower_getattr_genericlower_setattr_generic
lower_castlower_constantiternext_implimpl_ret_borrowedimpl_ret_new_refimpl_ret_untrackedRefType)	signature)StringLiteral)register_jitableoverloadoverload_method	intrinsicoverload_attribute)	quicksort	mergesort)slicing)_make_constant_bytes
bytes_type)tuple_setitembuild_full_slice_tuple)overload_classmethod)parse_dtypeparse_shape_parse_nested_sequence_sequence_of_arrays_choose_concatenation_layoutc                     [        UR                  U5      [        UR                  U5      /nU R                  R                  U5      nUR	                  SU5        g)zn
Set the "range" metadata on a load instruction.
Note the interval is in the form [lower_bound, upper_bound).
rangeN)r   typemoduleadd_metadataset_metadata)builderloadlower_boundupper_boundrange_operandsmds         H/mnt/rpi/venvs/whisper/lib/python3.13/site-packages/numba/np/arrayobj.pyset_range_metadatarE   .   sK    
 tyy+6tyy+68N		$	$^	4Bgr"    c                 \    SUR                   R                  S-
  -  S-
  n[        XSU5        g)z>
Mark the result of a load instruction as positive (or zero).
   r   N)r:   widthrE   )r>   r?   rA   s      rD   mark_positiverJ   9   s,     1,-2Kwa5rF   c                    ^ ^^^^ T R                   m[        R                  " T5      mTR                  m " UU UUU4S jST5      mT$ )z
Return the Structure representation of the given *array_type*
(an instance of types.ArrayCompatible).

Note this does not call __array_wrap__ in case a new array structure
is being created (rather than populated).
c                   H   >^  \ rS rSrUU UU4S jr\UU4S j5       rSrU =r$ )make_array.<locals>.ArrayStructM   c                 b  > [        T
T	5      n U R                  R                  SU5      nU R                  R                  T	   nU R                  U5      nUc!  [        R                  " U R                  USS9nOUnU" U R                  U45      nXa4$ ! [         a    [        TU ]  U5      s $ f = f)N	__array__T)zfill)r$   _contextget_functionNotImplementedErrorsuper
_make_refsdata_model_manager_get_be_typer
   alloca_once_builder)selfrefsig
array_impl	datamodelbe_type	outer_refArrayStruct	__class__
array_typereal_array_types          rD   rV   *make_array.<locals>.ArrayStruct._make_refsO   s    OZ8C@!]]77SI

 88DI''	2G{#//w6:<	  	 T]]YL9C>! ' @[$:3??@s   B B.-B.c                 L  > U R                   nTS:X  a  TR                  U S5      $ U R                  S5      n/ n[        T5       HH  n[        R
                  " XSU5      nUR                  U5      nUR                  U5        [        X5        MJ     [        R                  " X5      $ )zD
Override .shape to inform LLVM that its elements are all positive.
r   shape)
rZ   __getattr___get_ptr_by_namer9   r
   gep_inboundsr?   appendrJ   
pack_array)	r[   r>   ptrdimsidimptrr?   basendims	          rD   rh   %make_array.<locals>.ArrayStruct.shapec   s    
 mmGqy''g66 ''0CD4[ --gAqA||F+D!g,	 ! %%g44rF    )	__name__
__module____qualname____firstlineno__rV   propertyrh   __static_attributes____classcell__)rc   rb   rd   rr   rs   re   s   @rD   rb   rM   M   s!    	" 	"( 
	5 
	5rF   rb   )as_arrayr
   create_struct_proxyrs   )rd   rb   rr   rs   re   s   `@@@@rD   
make_arrayr   A   sE     !))O&&7DD+5 +5d +5Z rF   c                 Z    U R                  UR                  5      nU R                  U5      $ )z:
Return the item size for the given array or buffer type.
)get_data_typedtypeget_abi_sizeof)contextrd   lltys      rD   get_itemsizer   }   s+       !1!12D!!$''rF   c                 b    UR                   (       a  SOSnU R                  XR                  UUS9$ )z+
Load the item at the given array pointer.
NrH   align)alignedunpack_valuer   )r   r>   arraytyrn   r   s        rD   	load_itemr      s4     OODE&+   - -rF   c                 b    UR                   (       a  SOSnU R                  XR                  X4US9$ )z,
Store the item at the given array pointer.
NrH   r   )r   
pack_valuer   )r   r>   r   valrn   r   s         rD   
store_itemr      s-     OODEg}}ceLLrF   c                     UR                   (       a:  U R                  XU[        R                  5      n[        R
                  " XU5      nU$ U R                  XU[        R                  5      nU$ )zE
Fix the integer index' type and value for the given dimension size.
)signedcastr   intpr-   	fix_indexuintp)r   r>   idxtyidxsizeinds         rD   fix_integer_indexr      sW     ||ll7

;d3 J ll7<JrF   c                 (   [        U[        R                  5      (       aq  UR                  S:X  aa  [        UR                  [        R
                  5      (       d   e[        U5      " XU5      n[        XX$R                  5      nUR                  U4$ X#4$ )zK
Normalize the index type and value.  0-d arrays are converted to scalars.
r   )	
isinstancer   Arrayrs   r   Integerr   r   data)r   r>   r   r   idxaryidxvals         rD   normalize_indexr      sr     %%%%**/%++u}}5555E"7S97UKK@{{F""zrF   c                     [        U5      (       a3  [        [        X#5       VVs/ s H  u  pE[        XUU5      PM     snn6 u  p#X#4$ s  snnf )zR
Same as normalize_index(), but operating on sequences of
index types and values.
)lenzipr   )r   r>   index_typesindicesr   r   s         rD   normalize_indicesr      sX    
 7||"7:;7P%'7P &5Wu58&:7P%'  ( 	%'s   A
c                 D   U R                   nU R                  nU R                  n	[        R                  " [        R
                  SS5      n
UR                  U
   n[        UR                  5      n[        U	R                  5      nX-  U:w  a6  X-
  nSU R                   S[        U5      S:  a  SOS SU S3n[        U5      eUc*  [        UR                  U	R                  S
5      5      S	5      nUR                  [        R                  5      n[!        U["        [$        45      (       a  [&        R(                  " XU5      n[!        U["        [$        45      (       a  [&        R(                  " XU5      n[!        U[*        5      (       a  U" U5      n[-        UUUUUS9nUc.  [        UR                  U	R                  S5      5      S	5      US'   OUUS'   UR/                  [        R                  S5      n[&        R0                  " XUR2                  R4                  5      nU H  nUR7                  UUS/S9nM     UUS'   [        UR9                  5       5      nUU:w  a  [        SR;                  UU-
  5      5      eUR=                  5        H  u  nn[?        U UU5        M     U $ )z
Helper function for populating array structures.
This avoids forgetting to set fields.

*shape* and *strides* can be Python tuples or LLVM arrays.
rH   CzThe datamodel for type z is missing fields  .Nmeminfo)rh   stridesr   itemsizer   parentnswflagsnitemszmissing {0}) rR   rZ   
_datamodelr   r   float64rW   set_fields_fe_typer   
ValueErrorr   get_value_typeget_typer   r   tuplelistr
   rm   intdictget_constantunpack_tupler:   countmulkeysformatitemssetattr)arrayr   rh   r   r   r   r   r   r>   r_   standard_arraystandard_array_type_datamodelrequired_fieldsdatamodel_fieldsmissingmsgintp_tattrsr   unpacked_shapeaxlen
got_fieldskvs                           rD   populate_arrayr      sn    nnGnnG  I [[37N$+$>$>~$N!7??@O9,,- 	*>!4((8 9!'lQ.sB7q	Do711y)+,02 ##EJJ/F%%''""76:'E4=))$$Wv>(C  (#u " 	#E ~"7#9#9x($*+/1h !h!!%**a0F))'%**:J:JKNVU5':  E(O UZZ\"J_$--o
.JKLL 1q!  LrF   c                 f   UR                   nUR                  nUR                  [        R                  S5      n[
        R                  " X1R                  U R                  5      nU H  nUR                  XFS/S9nM     XAl
        UR                  [        R                  [        X 5      5      Ul        g)z{
Update some auxiliary information in *array* after some of its fields
were changed.  `itemsize` and `nitems` are updated.
rH   r   r   N)rR   rZ   r   r   r   r
   r   rh   rs   r   r   r   r   )arytyr   r   r>   r   r   r   s          rD   update_array_infor     s    
 nnGnnG !!%**a0F))';;

KNV5':  L))%***6w*FHENrF   c                     [        5       e)z/Constrain axis values to valid positive values.rT   	func_namearg_namers   axiss       rD   normalize_axisr         

rF   c                    ^ [        U [        5      (       d  [        R                  " S5      e[        U[        5      (       d  [        R                  " S5      eU R                   SUR                   S3mU4S jnU$ )N func_name must be a str literal.arg_name must be a str literal.: Argument * out of bounds for dimensions of the arrayc                 H   > US:  a  X2-  nUS:  d  X2:  a  [        T5      eU$ Nr   r   )r   r   rs   r   r   s       rD   impl&normalize_axis_overloads.<locals>.impl%  s+    !8LD!8t|S/!rF   )r   r%   r	   TypingErrorliteral_value)r   r   rs   r   r   r   s        @rD   normalize_axis_overloadsr     sx    i//  !CDDh..  !BCC ""
#;x/E/E.F G4 	4 
 KrF   c                     [        5       e)zFNormalizes an axis argument into a tuple of non-negative integer axes.r   r   s       rD   normalize_axis_tupler   0  r   rF   c                   ^^^^ [        U [        5      (       d  [        R                  " S5      e[        U[        5      (       d  [        R                  " S5      eU R                   SUR                   S3mU R                   SUR                   S3m[        U[
        R                  5      (       a  U4S jnU$ [        U5      mST-  mUUUU4S	 jnU$ )
Nr   r   r   r   z: repeated axis in z	 argumentc                 J   > US:  a  X2-  nUS:  d  X2:  a  [        T5      eU4$ r   r   )r   r   rs   r   invalid_axis_msgs       rD   r   ,normalize_axis_tuple_overloads.<locals>.implH  s/    axax4< !1227NrF   r   c                    > T	n[        U5       H1  u  pVUS:  a  Xb-  nUS:  d  Xb:  a  [        T5      e[        XEU5      nM3     [        [	        U5      5      T:w  a  [        T
5      eU$ r   )	enumerater   r0   r   r   )r   r   rs   r   	norm_axisrp   axaxis_lenr   norm_axis_initrepeated_axis_msgs          rD   r   r   T  sn    &I"46JB6RZ$%566));	 ) 3y>"h. !233rF   )r   r%   r	   r   r   r   r   r   )	r   r   rs   r   r   r   r   r   r  s	        @@@@rD   normalize_axis_tuple_overloadsr  5  s    i//  !CDDh..  !BCC ""
#;x/E/E.F G4 	4  ""
##6!!
")	- 
 $&&	4 K# t9	 	 KrF   getiterc                    UR                   u  nUu  nU R                  XR                  5      nU R                  [        R
                  S5      n[        R                  " X5      nXl        XVl	        U R                  (       a  U R                  R                  XU5        UR                  5       n	[        XUR                  U	5      n
U
$ r   )argsmake_helperreturn_typer   r   r   r
   alloca_once_valueindexr   
enable_nrtnrtincref	_getvaluer!   )r   r>   r]   r  r   r   iterobjzeroindexptrresouts              rD   getiter_arrayr  e  s    IWGU!!'??;G

A.D((7HMM 7U3



C 7S__c
BCJrF   c           
         [         R                  " XR                  UR                  S9n[         R                  " XR                  UR                  S9nUR                  US   U5      n[         R                  " XR                  U5      n	USS n
USS n[        U[        R                  5      (       a  [        XX4UXU5      nUR                  5       $ U
(       a   e[        XX95      $ )z0Evaluate `ary[idx]`, where idx is a single int. r   r   rH   N)r
   r   rh   rs   r   r   pointer_addr   r   r   Buffer	make_viewr  r   )r   r>   r  r   aryr   shapesr   offsetdataptrview_shapesview_stridesretarys                rD   _getitem_array_single_intr   }  s     !!'99EJJGF""7KKuzzJG[[S)F!!'88V<G*K12;L+u||,,7U"?!! 5::rF   iternextc           	      \   UR                   u  nUu  nUR                  nU R                  XUS9n[        U5      " XUR                  S9n	[
        R                  " XR                  SS9u  n
UR                  UR                  5      nUR                  SX5      nUR                  U5        UR                  U5         [        XUR                  XyU5      nUR                  U5        [
        R                   " X5      nUR#                  XR                  5        S S S 5        g ! , (       d  f       g = f)NvaluerH   r  <)r  rd   r  r   r   r
   r   rh   r?   r	  icmp_signed	set_validif_thenr   
yield_typeyield_increment_indexstore)r   r>   r]   r  resultitertyiterr   r  r  r   r	  is_validr$  nindexs                  rD   iternext_arrayr2    s     xxHVFTG!!'!>G
W
ggmm
DC""7IIQ?GFLL'E""36H
X		")f//u
 	e((8fmm, 
#	"	"s   9AD
D+c           
         U R                  [        R                  S5      nU R                  [        R                  S5      n[        R                  " XR
                  UR                  5      n	[        R                  " XR                  UR                  5      n
/ n/ n/ n[        U Vs/ s H  n[        U5      (       d  M  UPM     sn5      nSn[        XT5       GH  u  nnU[        R                  L ap  UR                  [        U5      -
  S-   U-   n[        U5       HA  nUR                  U5        UR                  U	U   5        UR                  U
U   5        US-  nMC     M  [        U[        R                  5      (       a  U R!                  UUUS9n["        R$                  " XUU5        ["        R&                  " UUU	U   5        UR                  UR(                  5        ["        R*                  " UU5      n["        R,                  " UUU
U   5      nUR                  U5        UR                  U5        O[        U[        R.                  5      (       aF  [1        XUUU	U   5      nU(       a  [        R2                  " XUU	U   U5        UR                  U5        OG[        U5      (       a(  UR                  U5        UR                  U5        US-  nO[5        SU< 35      eUS-  nGM     UUR                  ::  d   eUUR                  :  a?  UR                  U	U   5        UR                  U
U   5        US-  nUUR                  :  a  M?  [        R6                  " XX#USSS9nUX4$ s  snf )z
Perform basic indexing on the given array.
A (data pointer, shapes, strides) tuple is returned describing
the corresponding view.
r   rH   r#  unexpected index type: F
wraparoundboundscheck)r   r   r   r
   r   rh   rs   r   r   r   r   ellipsisr9   rl   r   	SliceTyper  r-   guard_invalid_slice	fix_slicestartget_slice_length
fix_strider   r   do_boundscheckrT   get_item_pointer)r   r>   r   r  r   r   r7  r  oner  r   output_indicesoutput_shapesoutput_stridesr   num_newaxesr   indexvalr   	n_missingrp   sliceshstr   r  s                             rD   basic_indexingrK    s    

A.D


uzz1
-C!!'99ejjAF""7KKDGNMNkFks[5EskFGK	
Bw4%ENN"

S\1A5CI9%%%d+$$VBZ0%%gbk2a	 &
 eU__--''h'GE''%GgufRj9!!%++.))'59B##GUGBK@B  $!!"%u}}--#GeX$*2J0C&&wfRj"M!!#&  %!!$'!GB%U&LMM
aA 5F 
uzz/VBZ(gbk*
a uzz/ &&w'527ULG ]33a Gs   &M(>M(c           
          [        U5      " X5      n[        UUUUUR                  UR                  UR                  S9  U$ )z>
Build a view over the given array with the given parameters.
r   rh   r   r   r   r   )r   r   r   r   r   )	r   r>   r   r  r  r   r  r   r  s	            rD   r  r    sB    
 $W6F6"LL;;**& MrF   c           
          [        XX4XVU R                  S9u  pxn	[        U[        R                  5      (       a  [        XX4UXxU	5      n
U
R                  5       $ U(       a   e[        XX75      $ )zd
Return the result of indexing *ary* with the given *indices*,
returning either a scalar or a view.
r7  )rK  enable_boundscheckr   r   r  r  r  r   )r   r>   r  r   r  r   r   r  r  r  r  s              rD   _getitem_array_genericrQ    sr     	w[#*#=#=	? 'G, +u||,,7U"?!! 5::rF   c           	         UR                   u  pEUu  pg[        U[        R                  5      (       d  UR                  S:  d   e[        U5      " XU5      n[        XUR                  XFU4U45      n[        XUR                  U5      $ )z1
Basic indexing with an integer, slice, or None.
rH   )	r  r   r   NoneTypers   r   rQ  r  r    	r   r>   r]   r  r   r   r  r   r  s	            rD   getitem_arraynd_intprU    sz     88LEHC eU^^,,zzQ
U
Gc
2C
 3??!&eXv?CWsDDrF   c           
      b   UR                   u  pEUu  pg[        U5      " XU5      nUR                  n[        R                  " X[        U5      S9n	[        XX5      u  p[        S U 5       5      (       a  [        XX#XFX5      $ [        XUR                  XFX5      n
[        XUR                  U
5      $ )z*
Basic or advanced indexing with a tuple.
r  c              3   V   #    U  H  n[        U[        R                  5      v   M!     g 7fNr   r   r   ).0tys     rD   	<genexpr>&getitem_array_tuple.<locals>.<genexpr>:  s     
=2:b%++&&   '))r  r   r   r
   r   r   r   anyfancy_getitemrQ  r  r    )r   r>   r]   r  r   tuptyr  tupr   r   r  s              rD   getitem_array_tuplerc  +  s    
 88LEHC
U
Gc
2C++K""7s5zBG,W-8CK 
=
===Ws"? 	? !3??!&[CCWsDDrF   c           
         UR                   u  pEnUu  pxn	[        U[        R                  5      (       a+  UR                  n
[        R
                  " X[        U5      S9nOU4n
U4n[        U5      " XU5      n[        XX5      u  p [        XXGXU R                  S9u  pn[        U5      nU(       a  [        XX#X5      $ U R                  XXdR                  5      n	[!        XXIW5        g! [         a    Sn NLf = f)z<
array[a] = scalar_or_array
array[a,..,b] = scalar_or_array
r  rO  TN)r  r   r   	BaseTupler
   r   r   r   r   rK  rP  boolrT   fancy_setslicer   r   r   )r   r>   r]   r  r   r   valtyr  r   r   r   r   r  r  r   use_fancy_indexings                   rD   setitem_arrayrj  D  s    ((E%MCc%))kk&&w3u:Fh&
U
Gc
2C -W-8CK*7U'.'A'AC 	! "&\ g)4 	4 ,,wUKK
8CwW5  "!"s   C( (C76C7c                     UR                   u  nUu  n[        U5      nU" XU5      nUR                  nUR                  US5      n[	        XUR
                  U5      $ r   )r  r   rh   extract_valuer"   r  )	r   r>   r]   r  r   r  arysttyshapearyr  s	            rD   	array_lenro  m  sX    xxHUFSG
'C
(CyyH


!
,CgEErF   z
array.itemc           	      h   UR                   u  nUu  n[        U5      " XU5      nUR                  nUR                  UR	                  SXfR                  S5      5      SS9   SnU R                  R                  U[        U45        S S S 5        [        XXER                  5      $ ! , (       d  f       N$= f)N!=rH   Flikelyz>item(): can only convert an array of size 1 to a Python scalar)r  r   r   r(  r&  r:   	call_convreturn_user_excr   r   r   )r   r>   r]   r  r   r  r   r   s           rD   
array_itemrv  x  s    XXFEDC
U
Gc
2CZZF	,,T6;;q>J % 
 
'N))':vF
'
 Wuhh77
' 
's    %B##
B1   r   zarray.itemsetc           	         UR                   u  pEUu  pgXTR                  :X  d   e[        U5      " XU5      nUR                  nUR	                  UR                  SXR                  S5      5      SS9   Sn	U R                  R                  U[        U	45        S S S 5        [        XXGUR                  5        U R                  5       $ ! , (       d  f       N5= f)Nrq  rH   Frr  z/itemset(): can only write to an array of size 1)r  r   r   r   r(  r&  r:   rt  ru  r   r   r   get_dummy_value)
r   r>   r]   r  r   rh  r  r   r   r   s
             rD   array_itemsetr{    s    xx####6__W00v{{1~N$)  +CC--gzC6J+
 	7U:&&((+ +s   1%C
Cc                   <    \ rS rSrSrS rS rS rS rS r	S r
S	rg
)Indexeri  ze
Generic indexer interface, for generating indices over a fancy indexed
array on a single dimension.
c                     [         e)zM
Prepare the indexer by initializing any required variables, basic
blocks...
r   r[   s    rD   prepareIndexer.prepare  
    
 "!rF   c                     [         e)z-
Return this dimension's size as an integer.
r   r  s    rD   get_sizeIndexer.get_size  
     "!rF   c                     [         e)z+
Return this dimension's shape as a tuple.
r   r  s    rD   	get_shapeIndexer.get_shape  r  rF   c                     [         e)ze
Return a half-open [lower, upper) range of indices this dimension
is guaranteed not to step out of.
r   r  s    rD   get_index_boundsIndexer.get_index_bounds  r  rF   c                     [         e)a  
Start indexation loop.  Return a (index, count) tuple.
*index* is an integer LLVM value representing the index over this
dimension.
*count* is either an integer LLVM value representing the current
iteration count, or None if this dimension should be omitted from
the indexation result.
r   r  s    rD   	loop_headIndexer.loop_head  s
     "!rF   c                     [         e)z
Finish indexation loop.
r   r  s    rD   	loop_tailIndexer.loop_tail  r  rF   ru   N)rv   rw   rx   ry   __doc__r  r  r  r  r  r  r{   ru   rF   rD   r}  r}    s%    
""""	""rF   r}  c                   B    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
rg)EntireIndexeri  z2
Compute indices along an entire array dimension.
c                     Xl         X l        X0l        X@l        XPl        U R                   R                  [        R                  5      U l        g rX  )	r   r>   r   r  dimr   r   r   ll_intp)r[   r   r>   r   r  r  s         rD   __init__EntireIndexer.__init__  s5    
||225::>rF   c                 $   U R                   nUR                  U R                  R                  U R                  5      U l        [        R                  " XR                  5      U l	        UR                  5       U l        UR                  5       U l        g rX  )r>   rl  r  rh   r  r   r
   rY   r  r	  append_basic_blockbb_startbb_endr[   r>   s     rD   r  EntireIndexer.prepare  sa    ,,))$((..$((C	((,,?
224002rF   c                     U R                   $ rX  r   r  s    rD   r  EntireIndexer.get_size  s    yyrF   c                     U R                   4$ rX  r  r  s    rD   r  EntireIndexer.get_shape  s    		|rF   c                 <    U R                  S5      U R                  4$ r   r  r   r  s    rD   r  EntireIndexer.get_index_bounds      Q++rF   c                    U R                   nU R                   R                  [        U R                  S5      U R                  5        UR                  U R                  5        UR                  U R                  5        UR                  U R                  5      nUR                  UR                  SX R                  5      SS9   UR                  U R                  5        S S S 5        X"4$ ! , (       d  f       X"4$ = fNr   >=Frr  )r>   r,  r   r  r	  branchr  position_at_endr?   r(  r&  r   r  )r[   r>   	cur_indexs      rD   r  EntireIndexer.loop_head  s    ,,8DLL!4djjAt}}%.LL,	__W00y))L$)  +NN4;;'+ ##+ + ##s   C))
C9c                    U R                   n[        R                  " XR                  U R                  5      5      nUR                  X R                  5        UR                  U R                  5        UR                  U R                  5        g rX  )
r>   r
   r+  r?   r	  r,  r  r  r  r  r[   r>   
next_indexs      rD   r  EntireIndexer.loop_tail  sZ    ,,,,Wll4::6NO
j**-t}}%,rF   )
r  r   r  r  r>   r   r  r	  r  r   Nrv   rw   rx   ry   r  r  r  r  r  r  r  r  r{   ru   rF   rD   r  r    s*    ?3,
$-rF   r  c                   B    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
rg)IntegerIndexeri  z(
Compute indices from a single integer.
c                     Xl         X l        X0l        U R                   R                  [        R
                  5      U l        g rX  )r   r>   r   r   r   r   r  )r[   r   r>   r   s       rD   r  IntegerIndexer.__init__  s+    ||225::>rF   c                     g rX  ru   r  s    rD   r  IntegerIndexer.prepare      rF   c                 .    [        U R                  S5      $ NrH   )r   r  r  s    rD   r  IntegerIndexer.get_size  s    a((rF   c                     gNru   ru   r  s    rD   r  IntegerIndexer.get_shape  s    rF   c                     U R                   U R                  R                  U R                   U R                  5       5      4$ rX  )r   r>   addr  r  s    rD   r  IntegerIndexer.get_index_bounds  s,    $,,**488T]]_EFFrF   c                     U R                   S 4$ rX  )r   r  s    rD   r  IntegerIndexer.loop_head  s    xx~rF   c                     g rX  ru   r  s    rD   r  IntegerIndexer.loop_tail  r  rF   )r>   r   r   r  Nr  ru   rF   rD   r  r    s+    ?)GrF   r  c                   B    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
rg)IntegerArrayIndexeri   z3
Compute indices from an array of integer indices.
c                     Xl         X l        X0l        X@l        XPl        UR
                  S:X  d   eU R                   R                  [        R                  5      U l	        g r  )
r   r>   r   r   r   rs   r   r   r   r  )r[   r   r>   r   r   r   s         rD   r  IntegerArrayIndexer.__init__%  sE    
	zzQ||225::>rF   c                    U R                   n[        R                  " XR                  R                  5      S   U l        [        R                  " XR                  5      U l        UR                  5       U l
        UR                  5       U l        g r   )r>   r
   r   r   rh   idx_sizerY   r  	idx_indexr  r  r  r  s     rD   r  IntegerArrayIndexer.prepare.  sb    ,,,,Wkk6G6GHK ,,WllC224002rF   c                     U R                   $ rX  r  r  s    rD   r  IntegerArrayIndexer.get_size5  s    }}rF   c                     U R                   4$ rX  r  r  s    rD   r  IntegerArrayIndexer.get_shape8  s    rF   c                 <    U R                  S5      U R                  4$ r   r  r  s    rD   r  $IntegerArrayIndexer.get_index_bounds;  r  rF   c                    U R                   nU R                   R                  [        U R                  S5      U R                  5        UR                  U R                  5        UR                  U R                  5        UR                  U R                  5      nUR                  UR                  SX R                  5      SS9   UR                  U R                  5        S S S 5        [        U R                  XR                  R                   U R                  U R"                  U5      n[%        U R                  UU R                  R                   X0R&                  5      nX24$ ! , (       d  f       N= f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	  s       rD   r  IntegerArrayIndexer.loop_head?  s   ,,8DLL!4dnnEt}}%.LL0	__i?  
 NN4;;'	
 *LL'::#3#3TZZ
 "$,,"&**"2"2E99F
 
s   E  
E.c                    U R                   n[        R                  " UUR                  U R                  5      5      nUR                  X R                  5        UR                  U R                  5        UR                  U R                  5        g rX  )
r>   r
   r+  r?   r  r,  r  r  r  r  r  s      rD   r  IntegerArrayIndexer.loop_tailT  s`    ,,,,W-4\\$..-IK
j..1t}}%,rF   )
r  r  r>   r   r  r  r   r   r  r   Nr  ru   rF   rD   r  r     s*    ?3 , *-rF   r  c                   B    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
rg)BooleanArrayIndexeri]  z6
Compute indices from an array of boolean predicates.
c                     Xl         X l        X0l        X@l        UR                  S:X  d   eU R                   R                  [        R                  5      U l        [        U R                  S5      U l
        g NrH   r   )r   r>   r   r   rs   r   r   r   r  r   r  )r[   r   r>   r   r   s        rD   r  BooleanArrayIndexer.__init__b  sR    
zzQ||225::>T\\1-	rF   c                    U R                   n[        R                  " XR                  R                  5      S   U l        [        R                  " XR                  5      U l        [        R                  " XR                  5      U l	        UR                  5       U l        UR                  5       U l        UR                  5       U l        g r   )r>   r
   r   r   rh   r   rY   r  r  r   r  r  bb_tailr  r  s     rD   r  BooleanArrayIndexer.preparek  s    ,,((++2C2CDQG	 ,,WllC((,,?
224113002rF   c           	         U R                   n[        R                  " XR                  5      n[        R                  " XR
                  5       nUR                  U5      n[        U R                  XR                  R                  U R                  U R                  UR                  5      nUR                  XAR                  XTR                  5      5      nUR!                  XB5        S S S 5        UR                  U5      $ ! , (       d  f       N= frX  )r>   r
   r  r  	for_ranger   r?   r   r   r   r   r   r	  r  zextr:   r,  )r[   r>   r   loopcpreds         rD   r  BooleanArrayIndexer.get_sizet  s    ,,))'99=w		2dU#A,gzz'7'7

DKKD A||D&&9:AMM!# 3 ||E"" 32s   BC>>
Dc                 $    U R                  5       4$ rX  r  r  s    rD   r  BooleanArrayIndexer.get_shape      !!rF   c                 <    U R                  S5      U R                  4$ r   r  r  s    rD   r  $BooleanArrayIndexer.get_index_bounds  s     Q++rF   c                    U R                   nU R                   R                  U R                  U R                  5        U R                   R                  U R                  U R                  5        UR                  U R                  5        UR                  U R                  5        UR                  U R                  5      nUR                  U R                  5      nUR                  UR                  SX R                  5      SS9   UR                  U R                  5        S S S 5        [        U R                  XR                  R                   U R                  U R"                  U5      nUR                  UR%                  U5      5         UR                  U R&                  5        S S S 5        [(        R*                  " X5      nUR                  XPR                  5        X#4$ ! , (       d  f       N= f! , (       d  f       NS= f)Nr  Frr  )r>   r,  r  r  r   r  r  r  r?   r(  r&  r   r  r   r   r   r   r   not_r  r
   r+  )r[   r>   r  	cur_countr  
next_counts         rD   r  BooleanArrayIndexer.loop_head  s^   ,,499dnn5499djj1t}}%.LL0	LL,	__W00y))L$)  +NN4;;'+ )LL'::#3#3TZZ
 __W\\$/0NN4<<( 1 ,,W@
j**-##+ + 10s   G G1 
G.1
G?c                    U R                   nUR                  U R                  5        UR                  U R                  5        [        R
                  " UUR                  U R                  5      5      nUR                  X R                  5        UR                  U R                  5        UR                  U R                  5        g rX  )r>   r  r  r  r
   r+  r?   r  r,  r  r  r  s      rD   r  BooleanArrayIndexer.loop_tail  s    ,,t||$-,,W-4\\$..-IK
j..1t}}%,rF   )r  r  r  r>   r   r   r  r   r   r  r   r  Nr  ru   rF   rD   r  r  ]  s*    .3#",
$0-rF   r  c                   B    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
rg)SliceIndexeri  z 
Compute indices along a slice.
c                     Xl         X l        X0l        X@l        XPl        X`l        Xpl        U R                   R                  [        R                  5      U l
        [        U R                  S5      U l        g r   )r   r>   r   r  r  r   rH  r   r   r   r  r   r  )r[   r   r>   r   r  r  r   rH  s           rD   r  SliceIndexer.__init__  sQ    


||225::>T\\1-	rF   c                    U R                   nUR                  U R                  R                  U R                  5      U l        [        R                  " U R                  XR                  U R                  5        [        R                  " XR                  U R
                  5        [        R                  " XR                  R                  5      U l        [        R                   " XR"                  5      U l        [        R                   " XR"                  5      U l        UR)                  5       U l        UR)                  5       U l        g rX  )r>   rl  r  rh   r  dim_sizer-   r:  r   r   rH  r;  r
   
is_neg_intstepis_step_negativerY   r  r	  r   r  r  r  r  s     rD   r  SliceIndexer.prepare  s    ,,--dhhnndhhG##DLL'::$(JJ	0'::t}}= ' 2 27JJOO L((,,?
((,,?
224002rF   c                 X    [         R                  " U R                  U R                  5      $ rX  )r-   r=  r>   rH  r  s    rD   r  SliceIndexer.get_size  s    ''djjAArF   c                 $    U R                  5       4$ rX  r  r  s    rD   r  SliceIndexer.get_shape  r  rF   c                 b    [         R                  " U R                  U R                  5      u  pX4$ rX  )r-   get_slice_boundsr>   rH  )r[   loweruppers      rD   r  SliceIndexer.get_index_bounds  s&    //djjI|rF   c           	      (   U R                   nU R                   R                  U R                  R                  U R                  5        U R                   R                  U R
                  U R                  5        UR                  U R                  5        UR                  U R                  5        UR                  U R                  5      nUR                  U R                  5      nUR                  U R                  UR                  SUU R                  R                  5      UR                  SUU R                  R                  5      5      nUR                  USS9   UR                  U R                   5        S S S 5        X#4$ ! , (       d  f       X#4$ = f)Nz<=r  Frr  )r>   r,  rH  r<  r	  r  r   r  r  r  r?   selectr  r&  stopr(  r  )r[   r>   r  r  is_finisheds        rD   r  SliceIndexer.loop_head  s$   ,,4::++TZZ8499djj1t}}%.LL,	LL,	nnT%:%:%,%8%8y9=&J%,%8%8y9=&JK
 __[_7NN4;;' 8## 87##s   F
Fc                    U R                   nUR                  UR                  U R                  5      U R                  R
                  S/S9nUR                  X R                  5        [        R                  " XR                  U R                  5      5      nUR                  X0R                  5        UR                  U R                  5        UR                  U R                  5        g )Nr   r   )r>   r  r?   r	  rH  r   r,  r
   r+  r   r  r  r  r  )r[   r>   r  r  s       rD   r  SliceIndexer.loop_tail  s    ,,[[djj!94::??(-w ! 0
j**-,,Wll4::6NO
j**-t}}%,rF   )r  r   r  r  r>   r   r   r  r  r   r	  r  r  rH  r  Nr  ru   rF   rD   r  r    s+    	.3B"$$-rF   r  c                   <    \ rS rSrSrS rS rS rS rS r	S r
S	rg
)FancyIndexeri  z,
Perform fancy indexing on the given array.
c           
      t   Xl         X l        X0l        [        R                  " X$R
                  UR                  5      U l        [        R                  " X$R                  UR                  5      U l        U R                   R                  [        R                  5      U l        / U l        / n[        U Vs/ s H  n[        U5      (       d  M  UPM     sn5      n	Sn
Sn[!        Xe5       GH)  u  pU[        R"                  L aZ  UR                  [        U5      -
  S-   U	-   n[%        U5       H+  n['        XX4U
5      nUR)                  U5        U
S-  n
US-  nM-     Ms  [+        U[        R,                  5      (       a4  UR/                  X-U5      n[1        XX4U
UU5      nUR)                  U5        GOY[+        U[        R2                  5      (       a9  [5        XXU R                  U
   5      n[7        XU5      nUR)                  U5        GO[+        U[        R8                  5      (       a  [;        U5      " XU5      n[+        UR<                  [        R2                  5      (       a  [?        XUUU R                  U
   5      nO9[+        UR<                  [        R@                  5      (       a  [C        XUU5      nO eUR)                  U5        O@[        U5      (       a!  U R                  R)                  U5        U
S-  n
O[E        SU< 35      eU
S-  n
US-  nGM,     XR                  ::  d   XR                  45       eXR                  :  a4  ['        XX4U
5      nUR)                  U5        U
S-  n
XR                  :  a  M4  [        U5      UR                  :X  d   [        U5      UR                  45       eXpl#        g s  snf )Nr   rH   r4  )$r   r>   r   r
   r   rh   rs   r  r   r   r   r   r  newaxesr   r   r   r8  r9   r  rl   r   r9  r  r  r   r   r  r   r   r   r  Booleanr  AssertionErrorindexers)r[   r   r>   r   r  r   r   r  r   rE  r   new_axrF  r   rG  rp   indexerrH  r   r   s                       rD   r  FancyIndexer.__init__  s   
**7IIuzzJ++G[[%**M||225::>+J+3S9I3+JK"78OH&!JJW59KG	y)A+Ge"MGOOG,!GBaKF	 *
  %11++GHE&wR',e5(E5==11'%(,B9(3?(E5;;//#E*7XFekk5==991'2726++b/CG  U]];;1'27AG 1(U####F+a$E%KLL!GBaKFQ  9V ZZ1"jj!11::o#Ge"EGOOG$!GB ::o
 8}

*GS]EJJ,GG* m Ks   3N5N5c                 f   U R                    H  nUR                  5         M     U R                  R                  [        R
                  S5      nU R                    Vs/ s H  oR                  5       PM     nnU R                   H  nUR                  X45        M     [        US5      U l
        g s  snf )NrH   ru   )r  r  r   r   r   r   r  r  insertsumindexers_shape)r[   rp   rA  	res_shapes       rD   r  FancyIndexer.prepare:  s    AIIK  ll''

A6 -1MM:Mq[[]M	: AQ'  ")R0 ;s   B.c                     U R                   $ )z/
Get the resulting data shape as Python tuple.
)r   r  s    rD   r  FancyIndexer.get_shapeM  s     """rF   c           	         [        U5      U R                  R                  :X  d   eU R                  n[        R
                  nU R                  S5      nU R                  S5      nUnUn[        U R                  U R                  U5       H  u  pnUR                  UUR                  SX5      5      nU	R                  5       u  pUR                  X5      nUR                  XR                  X5      5      nUR                  SX5      nUR!                  UUR#                  UUU5      5      nUR!                  UUR#                  UUU5      5      nM     UR!                  X5      nUR#                  XEU5      nUR#                  XEU5      nXx4$ )z
Get a half-open [lower, upper) range of byte offsets spanned by
the indexer with the given strides and itemsize.  The indexer is
guaranteed to not go past those bounds.
r   rH   ==r%  )r   r   rs   r>   r
   	false_bitr  r   r  r   or_icmp_unsignedr  r   subr&  r  r  )r[   r   r   r>   is_emptyr  rA  r	  r
  r  rh   stridelower_indexupper_indexlower_offsetupper_offsetis_downwardss                    rD   get_offset_boundsFancyIndexer.get_offset_boundsS  sh    7|tzz...,,$$||All1o&)$--9L9L*1'3"GF{{8#*#8#8u#KMH (/'?'?'A$K";;v;L";;v{{;/LML"..sFALKK '|/;/;!=>E KK '|/;/;!=>E'3& E,xu5xu5|rF   c                 >    [        S U R                   5       6 u  pX4$ )Nc              3   @   #    U  H  oR                  5       v   M     g 7frX  )r  )rZ  rp   s     rD   r\  +FancyIndexer.begin_loops.<locals>.<genexpr>z  s     E}!}s   )r   r  )r[   r   countss      rD   begin_loopsFancyIndexer.begin_loopsy  s     Et}}EFrF   c                 \    [        U R                  5       H  nUR                  5         M     g rX  )reversedr  r  )r[   rp   s     rD   	end_loopsFancyIndexer.end_loops}  s    $--(AKKM )rF   )	r   r>   r   r  r   r  r  r  r   N)rv   rw   rx   ry   r  r  r  r  r2  r8  r<  r{   ru   rF   rD   r  r    s(    @!D1&#$LrF   r  c                 L   [         R                  " XR                  5      n[         R                  " XR                  5      n	UR                  n
[        XXEXg5      nUR                  5         UR                  nUR                  5       n[        XX5      nUR                  n[         R                  " UU R                  [        R                  S5      5      nUR                  5       u  nn[         R                  " XXU	UR                   USU R"                  S9	n[%        XUU5      nUR'                  U5      nUR)                  UU/5      n[+        XUUU5        [         R,                  " UU5      nUR/                  UU5        UR1                  5         [3        XXR5                  5       5      $ )Nr   Fr5  )r
   r   rh   r   r   r  r  r  r  _empty_nd_implr  r   r   r   r8  get_item_pointer2layoutrP  r   r?   gepr   r+  r,  r<  r!   r  )r   r>   r]   r  r   r  r   r   r  r   r   r  out_ty
out_shapesr  out_dataout_idx_rn   r   curnext_idxs                         rD   r`  r`    se    !!'995F""7KK8G88D7U&1GOO __F""$J
6
>CxxH''(/(<(<UZZ(KMG $$&JGQ 
#
#GdG$)LL'e070J0JLC GeS
1C ,,w
C
++h
&Cwc2&&w4HMM(G$GfmmoFFrF   c           
         UR                   u  pEUu  pg[        U5      " XU5      nUR                  S:X  a@  [        XXW5      u  pW[	        XUR
                  XFU4U45      n[        XUR
                  U5      $ [        XX#XFU4U45      $ )z+
Advanced or basic indexing with an array.
r   )r  r   rs   r   rQ  r  r    r`  rT  s	            rD   fancy_getitem_arrayrK    s    
 88LEHC
U
Gc
2CzzQ$WuB
$Ws%*%C6C 3??CHH Ws"%C6; 	;rF   c           	         UR                   nUR                  S5      nUR                  S5      nUR                  S;   a   Un	UR                  XcR                  5      n
X4$ Un	Un
[        UR                  5       H~  nUR                  X[   UR                  XK   U5      5      nUR                  SX5      nUR                  UUR                  X5      U
5      n
UR                  UXR                  X5      5      n	M     UR                  X5      n
UR                  SUR                  U5      nUR                  XU
5      n
UR                  XU	5      n	X4$ )z
Compute a half-open range [lower, upper) of byte offsets from the
array's data pointer, that bound the in-memory extent of the array.

This mimics offset_bounds_from_strides() from
numpy/core/src/private/mem_overlap.c
r   rH   CFr  r&  )r   r:   rA  r   r   r9   rs   r*  r&  r  r  )r   r>   arrtyarrr  r   r   r  rA  r	  r
  rp   max_axis_offset
is_upwardsr+  s                  rD   offset_bounds_from_stridesrR    s9    ||H==D
))A,C||t Hjj10 <+ uzz"A &kk'**1++fi*EGO ,,T?IJNN:#*;;u#FOENN:#(++e*MOE # E,&&tSZZ>xu5xu5<rF   c                     UR                  XBR                  5      nUR                  XR5      nUR                  XS5      nXg4$ )zy
Given [lower, upper) byte offsets and a base data pointer,
compute the memory pointer bounds as pointer-sized integers.
)ptrtointr:   r  )r   r>   r	  r
  r   data_ptr_as_intr<  ends           rD   compute_memory_extentsrW    s<    
 &&tZZ8OKK/E
++o
-C:rF   c                 :    [        XX#XE5      u  px[        XXxU5      $ )zf
Compute a half-open range [start, end) of pointer-sized integers
which fully contain the array data.
)rR  rW  )	r   r>   rN  rO  r  r   r   r	  r
  s	            rD   get_array_memory_extentsrY    s&     .g.4?LE!'E$GGrF   c                 j    UR                  UR                  SX%5      UR                  SXC5      5      nU$ )zO
Whether two memory extents [a_start, a_end) and [b_start, b_end)
may overlap.
r%  )and_r)  )r   r>   a_starta_endb_startb_endmay_overlaps          rD   extents_may_overlapra    s:     ,,c72c72K rF   c                 J  ^ ^^^^^^^^^^^^ TR                   mSm[        R                  " TT5      mTmS mTR                  TSS9   TR	                  UR
                  UR                  5      nT R                  R                  TU5      n	U	R                   mTR                  U	T5      n	TR                  U	T5        T R                  [        R                  5      n
[        R                  " TTU
5       n[        R                  " T TTTTTR                   U5      n[        R                  " T TU	TTTU5      nTR                  TR#                  U5      U5        S S S 5        S S S 5        UU UUUUUUUUUU4S jnUU UUU4S jnX4$ ! , (       d  f       N4= f! , (       d  f       N== f)Nr   Frr  c                   > [         R                  " TT
5      nTR                  TSS9 u  p#U   TR                  [         R                  " TTTR                  T5      TT	TU SS9U5        S S S 5        U   TR                  [         R                  " TTTTTTR                  U SS9U5        S S S 5        S S S 5        [        TTTTR                  U5      5      $ ! , (       d  f       Ns= f! , (       d  f       ND= f! , (       d  f       NM= f)NFrr  r6  )r
   rY   if_elser,  r@  r?   rA  r   )source_indicessrc_ptrif_copy	otherwiser>   r   	copy_datacopy_layoutcopy_shapescopy_stridesptrtysrc_data
src_shapessrc_stridessrctyuse_copys       rD   src_getitem&maybe_copy_source.<locals>.src_getitem-  s    %%gu5__Xe_48L--gw.5ll9.E.9<.9>9>	@
   --gw.8+.3llN9>@   5  '5',,w2GHH   54s:   C8;C)
C836C')C8
C$	 C8'
C5	1C88
Dc                     > TR                  TSS9   TR                  T5      n TR                  U T5      n TR                  R	                  TU 5        S S S 5        g ! , (       d  f       g = f)NFrr  )r(  r?   bitcastr  free)r   r>   r   rj  rs  	voidptrtys    rD   src_cleanup&maybe_copy_source.<locals>.src_cleanupA  sQ    __Xe_4<<	*D??43DKKWd+ 544s   A A
A))r:   r
   r  r(  r   r   r   r  allocaterw  r,  r   r   r   	loop_nestr@  rA  r?   )r   r>   rs  rr  srcrp  rq  ro  	allocsizer   r   r   rg  dest_ptrrt  rz  rj  rk  rl  rm  rn  ry  s   ```` ```        @@@@@@rD   maybe_copy_sourcer    sd   MMEK))'8<IKL	%	0 KKcjj9	{{##GY7II	tU+dI& ''

3w
F;w//(0:K05gGG 00'41<l1<gGH MM',,w/: < 
1,I I I(, , ##I <; 
1	0s&   B*F1A$FF
F	F
F"c                    U R                  [        R                  S5      nU R                  [        R                  S5      n[        U5      [        U5      :  a,  [        U5      [        U5      -
  nU/U-  U-   nU/U-  U-   nX#4$ [        U5      [        U5      :  a  [        U5      [        U5      -
  nUSU  Vs/ s H  nUR	                  SX5      PM     n	n[
        R                  " UR                  U	[        R                  5      n
UR                  UR                  U
5      SS9   SnU R                  R                  U[        U45        SSS5        X'S nX7S nX#4$ s  snf ! , (       d  f       N= f)aI  
Preprocess dimension for broadcasting.
Returns (shapes, strides) such that the ndim match *target_shape*.
When expanding to higher ndim, the returning shapes and strides are
prepended with ones and zeros, respectively.
When truncating to lower ndim, the shapes are checked (in runtime).
All extra dimension must have size of 1.
r   rH   Nr&  Frr  z,cannot broadcast source array for assignment)r   r   r   r   r)  	functoolsreducer[  r
   true_bitr(  r  rt  ru  r   )r   r>   r  r   target_shaper  rA  nd_diffrI  
dim_is_oneacceptedr   s               rD   _bc_adjust_dimensionr  K  si    Q/D


u{{A
.C <3v;&l#c&k16)&7"W," ? 
\	S[	(f+L 11 &x 02 0" ++D": 0 	 2##GLL*$+$4$46 __W\\(3E_B@C--gzC6J C !(#?2
 CBs   ;E (%E%%
E3c           
         / n/ nU R                  [        R                  S5      nU R                  [        R                  S5      n[        XB5       V	V
s/ s H  u  pUR	                  SX5      PM     nn	n
U V
s/ s H  oR	                  SX5      PM     nn
[        X5       VVs/ s H  u  pUR                  X5      PM     nnn[        XU5       VV	V
s/ s H  u  npUR                  UX5      PM     nn	nn
[        X5       VV
s/ s H  u  nn
UR                  UXz5      PM     nnn
XV4$ s  sn
n	f s  sn
f s  snnf s  sn
n	nf s  sn
nf )z
Broadcast shapes and strides to target_shape given that their ndim already
matches.  For each location where the shape is 1 and does not match the
dim for target, it is set to the value at the target and the stride is
set to zero.
r   rH   rq  r&  )r   r   r   r   r&  r[  r  )r   r>   r  r   r  	bc_shapes
bc_stridesr  rA  taroldmismatch
src_is_onexypredsps                    rD   _bc_adjust_shape_stridesr  p  sB    IJQ/D


u{{A
.C !$L 9; 9HC ##D#3 9  ;AGH#%%dC5JH,/,EF,EDAW\\!,EEF$'V$DF$D[Q 3,$D  F !$E 35 3fa ..D. 3  5  ;HFF5s   D)8D/#D4D:Ec           
         [         R                  " XR                  5      n[         R                  " XR                  5      n[	        XXVU5      u  pV[        XUXd5      u  pVUR                  [        U5      SS9n[        U5      " X5      n[        UUR                  [         R                  " X5      [         R                  " X5      UR                  UR                  UR                  S9  Xx4$ )zL
Broadcast the given array to the target_shape.
Returns (array_type, array)
Ars   rA  rM  )r
   r   rh   r   r  r  copyr   r   r   r   rm   r   r   r   )	r   r>   arrtyperO  r  r  r   new_arrtypenew_arrs	            rD   _broadcast_to_shaper    s     !!'995F""7KK8G*7V+79OF.w/6FOF,,C$5c,BK%g7G7 ++G<"--g?LL;;**& rF   c                 T    UR                  UR                  SSS9nU" X5      nS nXE4$ )Nr  T)rs   rA  readonlyc                 b   Uu  pEUR                   S   n[        U5      " XU5      n[        R                  " X5      n[	        XXdU5      u  px[        US[        U R                  UR                  R                  S5      5      S 5      5        UR                  5       n	[        XUR                  U	5      $ )Nr   r   )r  r   r
   r   r  r   r   r   r   r   r  r    r  )
r   r>   r]   r  r~  shape_rr  rG  destr  s
             rD   codegen$_numpy_broadcast_to.<locals>.codegen  s    #6%%g6%gFL 	h&&t'?'?'IJ! 	 nn 3??CHHrF   )r  r   )	typingctxr   rh   retr]   r  s         rD   _numpy_broadcast_tor    s4    
**%++cD*
AC
e
CI <rF   c                 <    UR                  SS9nU" U5      nS nX44$ )NTr  c                     Uu  nUR                   S   n[        U5      " XU5      n[        R                  " UR                  R
                  5      Ul        UR                  5       n[        XUR                  U5      $ r   )	r  r   r
   get_null_valuer   r:   r  r    r  )r   r>   r]   r  r~  rr  r  r  s           rD   r  #get_readonly_array.<locals>.codegen  sb    % 37,,T[[-=-=>nn 3??CHHrF   )r  )r  rO  r  r]   r  s        rD   get_readonly_arrayr    s-     ((D(
!C
c(CI <rF   c                    U R                   n[        U5      n[        U5      nX4:  a  [        S5      eU H  nUS:  d  M  [        S5      e   SnXC-
  nXc:  a1  X&   nX   n	X:X  d  US:X  a  US-  nUS-  nO[        S5      eXc:  a  M0  g g )NzDinput operand has more dimensions than allowed by the axis remappingr   z4all elements of broadcast shape must be non-negativerH   z=operands could not be broadcast together with remapped shapes)rh   r   r   )
r   
dest_shape	src_shapesrc_ndim	dest_ndimr   	src_index
dest_indexsrc_dimdest_dims
             rD   _can_broadcastr    s    I9~HJI 1 2 	2!8 , - -  I%J

&) 'Q,NI!OJ 4 5 5 
rF   c                 Z    [         R                  " U 5      n [        X5        [        X5      $ rX  )npasarrayr  r  r   rh   s     rD   _default_broadcast_to_implr    s#    JJuE5 u,,rF   c           	         [        U 5      (       d  [        R                  " S5      e[        U[        R
                  5      (       a  S nU$ [        U[        R                  5      (       aG  [        UR                  [        R
                  5      (       d  Sn[        R                  " U5      e[        $ [        U[        R                  5      (       ak  UR                  S:  a[  [        U Vs/ s H  n[        U[        R                  5      PM     sn5      (       d  SU S3n[        R                  " U5      e[        $ [        U[        R                  5      (       at  UR                  S:X  ad  [        U [        R                  5      =(       a    U R                  S:H  n[        U 5      (       d  U(       a  S nU$ Sn[        R                  " U5      eS	U-  n[        R                  " U5      es  snf )
Nz-The first argument "array" must be array-likec                 0    [         R                  " X45      $ rX  )r  broadcast_tor  s     rD   r    numpy_broadcast_to.<locals>.impl  s    ??5(33rF   z7The second argument "shape" must be a tuple of integersr   "z," object cannot be interpreted as an integerc                 D    [         R                  " U 5      n [        U 5      $ rX  )r  r  r  r  s     rD   r   r    s     

5))%00rF   z/Cannot broadcast a non-scalar to a scalar arrayz:The argument "shape" must be a tuple or an integer. Got %s)r   r	   r   r   r   r   UniTupler   r  Tupler   allIntegerLiteralr   rs   r   )r   rh   r   r   typis_scalar_arrays         rD   numpy_broadcast_tor    s}   E""   "1 2 	2 %''	4	E5>>	*	*%++u}}55KC$$S))))	E5;;	'	'EKK!OUKUcJsE$8$89UKLLeWHIC$$S))))	E5;;	'	'EKK1,<$UEKK8LUZZ1_%  O1
 K DC$$S))   %%+ Ls   )$G)c                     [        [        U5      5       HR  nU[        U5      -
  U-   nX#   nUS:  a  [        S5      eUS:X  a  M1  X   S:X  a  XPU'   M?  X   U:w  d  MI  [        S5      e   g )Nr   #negative dimensions are not allowedrH   z=shape mismatch: objects cannot be broadcast to a single shape)r9   r   r   )rmrh   rp   r   tmps         rD   numpy_broadcast_shapes_listr    sv    3u:E
NQh7BCC!8419aDTS[ 2 3 3 rF   c                    ^^	 [        U 5       H  u  p[        U[        R                  5      n[        U[        R                  5      =(       a$    [        UR
                  [        R                  5      n[        U[        R                  5      =(       a    [        UR                  5      S:H  nU(       a  M  U(       a  M  U(       a  M  SU SU 3n[        R                  " U5      e   SmU  Hf  n[        U[        R                  5      (       a  [        TS5      mM0  [        U[        R                  5      (       d  MQ  [        T[        U5      5      mMh     TS:X  a  S $ ST-  m	UU	4S jnU$ )Nr   z	Argument z* must be either an int or tuple[int]. Got rH   c                      gr  ru   r  s    rD   <lambda>+ol_numpy_broadcast_shapes.<locals>.<lambda>B  s    RrF   rH   c                  ,  > S/T-  nTn[        U 5       H[  n[        U[        5      (       a  [        U5      S:  a  [	        UTU5        M6  [        U[
        5      (       d  MM  [	        UTU45        M]     [        U5       H  u  pE[        X$U5      nM     U$ r  )r   r   r   r   r  r   r   r0   )r  r  rb  argr   elemr  tup_inits         rD   r   'ol_numpy_broadcast_shapes.<locals>.implF  s    aAC%d+c5))c#hl/1c:S))/1sf=	 ,
 'q\	#Cd3 *JrF   )r   r   r   r   r  r   r  r   r	   r   maxre  )
r  r   r  is_intis_int_tupleis_empty_tupler   r   r  r  s
           @@rD   ol_numpy_broadcast_shapesr  ,  s    dOC/!#u~~6 1syy%--0 	#C5M#cii.A:M,,..se $ C$$S)) $ 	
Ac5==))Aq	AU__--As3x A	  	Av!8	 rF   c                    ^^ [        U 5       H/  u  p[        U5      (       a  M  [        R                  " SU S35      e   S nS nU  Hf  n[	        U[
        R                  [
        R                  45      (       a  UR                  nOUnUc  UnMH  X4:w  d  MO  [        R                  " SU  35      e   Sm[        U 5       H  u  p[	        U[
        R                  5      (       a  [        TUR                  5      mM<  [	        U[
        R                  [
        R                  [
        R                  45      (       a  [        TS5      mM  [        R                  " SU 35      e   ST-  mUU4S jnU$ )	Nz
Argument "z" must be array-likezTMismatch of argument types. Numba cannot broadcast arrays with different types. Got r   rH   zUnhandled type r   c                  n  > S/T-  n[        U 5       H.  n[        UT[        R                  " U5      R                  5        M0     Tn[        T5       H  n[        X4X   5      nM     / n[        U 5       H=  nUR                  [        R                  " [        R                  " U5      U5      5        M?     U$ r  )	r   r  r  r  rh   r9   r0   rl   r  )r  rh   r   rb  rp   outsr  r  s         rD   r   $numpy_broadcast_arrays.<locals>.implx  s    
 a#D)E'q"**U2C2I2IJ * qA1C  #D)EKK

5(93?@ *rF   )r   r   r	   r   r   r   r   re  r   ArrayCompatibler  rs   Numberr  )r  r   r  unified_dtypedtr   r  r  s         @@rD   numpy_broadcast_arraysr  U  sH    dO$$$$z# 75 &5 6 6 $
 M	BcEKK9::BB M $$ &,,06&3 4 4  	
AdOc50011Asxx AellEMM5??KLLAq	A$$se%<== $ axH( KrF   c                     [         e)zTargets should implement this if they wish to specialize the error
handling/messages. The overload implementation takes two tuples as arguments
and should raise a ValueError.r   rp  index_shapes     rD   raise_with_shape_contextr    
     rF   generic)targetc                    [        U [        R                  5      (       aj  [        U[        R                  5      (       aJ  U R                  UR                  :X  a/  [        U R                  [        R                  5      (       a  S nU$ g g g g )Nc                     [        S5      e)Nz0cannot assign slice from input of different sizer   r  s     rD   r   1ol_raise_with_shape_context_generic.<locals>.impl  s    OPPrF   r   r   r  r   r   rp  r  r   s      rD   #ol_raise_with_shape_context_genericr    sp     	:u~~..;//K---z''77	Q	 8 	. 	0 	/rF   CPUc                    [        U [        R                  5      (       aj  [        U[        R                  5      (       aJ  U R                  UR                  :X  a/  [        U R                  [        R                  5      (       a  S nU$ g g g g )Nc           	      \   [        U 5      S:X  a
  SU S    S3nO/SSR                  U  Vs/ s H  n[        U5      PM     sn5       S3n[        U5      S:X  a
  SUS    S3nO/SSR                  U Vs/ s H  n[        U5      PM     sn5       S3nSU SU 3n[        U5      es  snf s  snf )	NrH   (r   z,), )zcannot assign slice of shape z from input of shape )r   joinstrr   )rp  r  	shape_strr  	index_strr   s         rD   r   -ol_raise_with_shape_context_cpu.<locals>.impl  s    :!#
1b1			:*F:a3q6:*F GHJ	;1$A/r2			;*G;a3q6;*G HIK	29+ >%;(CS/! +G +Hs   B$
2B)
r  r  s      rD   ol_raise_with_shape_context_cpur    so    :u~~..;//K---z''77	"  8 	. 	0 	/rF   c                   ^ ^^(^)^* UR                   u  pgm*Uu  pm([        U5      " T TU5      n[        R                  " TUR                  5      n	[        R                  " TUR
                  5      n
UR                  n[        T TXhXE5      nUR                  5         S n[        T*[        R                  5      (       Ga  T*R                  m)UR                  5       n[        T*5      " T TT(5      m([        T TT*T(U5      u  m*m([        R                  " TT(R                  5      n[        R                  " TT(R
                  5      nT(R                  n[        R                  n[!        U5      [!        U5      :X  d   e[#        X5       H)  u  nnTR%                  UTR'                  SUU5      5      nM+     TR)                  USS9   U" T TUU5        SSS5        [+        T TT*T(UUU5      u  nnUR-                  U
UR.                  5      u  nn[1        T TUUU5      u  nn[3        T TUUUU5      n[5        T TUT*T(UUU5      u  nnO[        T*[        R6                  5      (       a  T*R                  m)UR                  5       n[!        U5      S:X  d   eT R9                  [         [;        [        R<                  T*5      5      nU" TT(45      nTR'                  SUS   U5      nTR)                  USS9   U" T TU4US   45        SSS5        UU U(U)U*4S jnS	 nOT*m)U(4S
 jnS nT R?                  [        R@                  S5      n URC                  5       u  n!n"[E        U"5      n"URF                   H  n#U"RI                  U#U 5        M     U" V$s/ s H
  n$U$c  M  U$PM     n%n$U" U%5      n&T RK                  TU&T)UR                  5      n&[        RL                  " T TUXURN                  U!ST RP                  S9	n'[S        T TUU&U'5        URU                  5         U" 5         T RW                  5       $ ! , (       d  f       GN[= f! , (       d  f       GN?= fs  sn$f )z
Implement slice assignment for arrays.  This implementation works for
basic as well as fancy indexing, since there's no functional difference
between the two for indexed assignment.
c           	         U R                   R                  [        5      n[        R                  " [        R
                  [        U5      5      [        R                  " [        R
                  [        U5      5      4nUR                  U R                   U0 5      nU R                  XF5      nU" XR                  XR                  S   U5      U R                  XR                  S   U5      45        g Nr   rH   )typing_contextresolve_value_typer  r   r  int64r   get_call_typerS   
make_tupler  )r   r>   rp  r  fntyargtys	raise_sigfuncs           rD   raise_shape_mismatch_error2fancy_setslice.<locals>.raise_shape_mismatch_error  s     %%88$&..c*o>..c+.>?A&&w'='=vrJ	##D4W))'>>!3D*46))'>>!3D*578 	9rF   rq  Frr  NrH   r   c                    > U u  nTR                  [        R                  [        TT[        R
                  5      5      nU" TTU45      $ rX  )rS   operatorgetitemr$   r   r   )rf  r   getitem_implr>   r   r~  	src_dtyperr  s      rD   rt  #fancy_setslice.<locals>.src_getitem  sF    !DC"//  )UEJJ7L  #s44rF   c                      g rX  ru   ru   rF   rD   rz  #fancy_setslice.<locals>.src_cleanup      rF   c                    > T$ rX  ru   )rf  r~  s    rD   rt  r  $  s    JrF   c                      g rX  ru   ru   rF   rD   rz  r  '  r  rF   r5  ),r  r   r
   r   rh   r   r   r  r  r   r   r  r   r  r  r'  r   r   r(  r&  r(  rY  r2  r   rW  ra  r  SequencerS   r$   r   r   r   r8  r   r  r  r   r@  rA  rP  r   r<  rz  )+r   r>   r]   r  r   r   r   rG  r  dest_shapesdest_strides	dest_datar  r  r  rp  rq  ro  shape_errorur   	src_startsrc_end
dest_lower
dest_upper
dest_startdest_endrs  rt  rz  len_implseq_lenr  dest_indicesr7  rp   r  rf  r   r  r~  r  rr  s+   ``                                      @@@rD   rg  rg    s    hhOEeKCC
U
GWc
2C&&w		:K''=LI7GU&1GOO9 %&&KK	'')#6('5#)46
s))'399=
**7CKK@88 '';3z?222
0DAq!++k&-&9&9$1&EGK 1 __[_7&w'24 8
 6gw69:6A8M	7 ")!:!:<;><<"I
J5gw6@*6? A
H 'wG'18= $5Wgx5:C5@($L [ 
E5>>	*	*KK	 '');1$$$''Yuzz5-IJ7SF+))$AH__[_7&w'(3A'8: 8	5 	5	 			 Q/D"..0L& &\F
 __a  "(9A1aN9
n
%C ,,wY
<C (('9)4).|495<5O5O	QH
 wX6M""$$A 87B 87V :s$   =P&P/?Q
Q
P,/
P>c           
         UR                   S   nUR                   SS  nUS   nUSS  n[        XW5       VV	s/ s H&  u  pU R                  XU[        R                  5      PM(     nnn	[
        R                  " XUS   R                  5      n
[        R                  " [        R                  [        U5      S9n[        R                  " UR                  XK5      nXj4nX4$ s  sn	nf )Nr   rH   r   r   )r  r   r   r   r   r
   rm   r:   r  r   r   r$   r  )r   r>   r]   r  r   dimtysr  ro   r[  r   rh   shapetynew_signew_argss                 rD   vararg_to_tupler1  U  s    HHQKEXXab\F
q'C8D v,., LLr5::6, 	 . wd1gll;Enn5::SY?Gs?GzH.s   -Czarray.transposec                 <    [        XUR                  S   US   5      $ r   )array_Tr  r   r>   r]   r  s       rD   array_transposer5  h  s    7SXXa[$q'::rF   c                     [        U 5      [        [        U 5      5      :w  a  [        S5      e[        U5      nU  H"  nXC:  d  [        U5      U:  d  M  [        S5      e   X   US S & X    US S & g )Nzrepeated axis in transposez2axis is out of bounds for array of given dimension)r   r   r   abs)r   rh   r   r  r  s        rD   permute_arraysr8  m  sn    
4yCD	N"566
e*C8s1v| / 0 0 
 {E!HGAJrF   c           
      r   UR                   S   n[        U5      " XUS   5      nUR                   S   US   pvUR                  UR                  pU R	                  [
        R                  5      n
[        R                  " X5      nXuR                  UR                  /nU Vs/ s H  n[        R                  " X5      PM     nn[        X5       H  u  nnUR                  UU5        M     [
        R                  " U	SSS9nU R!                  [
        R                  U R#                  U
5      5      nU Vs/ s H  n[        U5      " X5      PM     nn[        UU5       HR  u  nn[%        UUR'                  UU
R)                  5       5      U R!                  [
        R                  U5      /U/US S9  MT     U R+                  U[,        [.        R0                  " [
        R2                  UUU5      U Vs/ s H  nUR5                  5       PM     sn5        [        UR6                  5      " X5      n[%        UUR8                  UR;                  US   5      UR;                  US   5      UR<                  UR>                  UR@                  S9  UR5                  5       n[C        XUR6                  U5      $ s  snf s  snf s  snf )Nr   rH   r   r   rs   rA  r   rh   r   r   r   rx  rM  )"r  r   r   r   r   r   r   r   	ArrayTyperh   r   r
   rY   r   r,  r   r   r   r   rw  
as_pointercompile_internalr8  r   r$   voidr  r  r   r?   r   r   r   r    )r   r>   r]   r  r   r  axistyr   num_axisr   r  ll_ary_sizearysrG  ll_arysr~  dst	np_ary_tynp_itemsizenp_arysnp_aryll_aryar  r  s                            rD   array_transpose_tuplerL  |  sH   HHQKE
U
Gd1g
6C88A;QDllFLLe$$UZZ0G,,w1K ))S[[)DBFG$Qw""78$GG &Sc3 ' %a<I&&uzz'.'='=g'FHK AEE1z)$W6GE gw/v#OOFG4F4F4HI%225::xHI +} +#	% 0 Wn#--ejj.7IO5<=WakkmW=? S__
%g
7C3 gaj1"<<
3LL;;**& --/CWsDDO H F  >s     J*2J/,J4c                 6    [        XX#5      u  pE[        XXE5      $ rX  )r1  rL  r   r>   r]   r  r/  r0  s         rD   array_transpose_varargrO    s    '#DG 7EErF   c                     [        U [        R                  5      (       a  [        R                  " S5      eUc  SS jnU$ SS jnU$ )Nz#np.transpose does not accept tuplesc                 "    U R                  5       $ rX  	transposerK  axess     rD   np_transpose_impl*numpy_transpose.<locals>.np_transpose_impl  s    ;;= rF   c                 $    U R                  U5      $ rX  rR  rT  s     rD   rV  rW    s    ;;t$$rF   rX  )r   r   re  r	   r   )rK  rU  rV  s      rD   numpy_transposerY    sD    !U__%%  !FGG|	! 	% rF   Tc                 (   UR                   S::  a  UnO[        U5      " XU5      n[        U5      " X5      n[        R                  " XR                  UR                   5      n[        R                  " XR
                  UR                   5      n[        UUR                  [        R                  " XS S S2   5      [        R                  " XS S S2   5      UR                  UR                  UR                  S9  UR                  5       n[        XX$5      $ )NrH   rM  )rs   r   r
   r   rh   r   r   r   rm   r   r   r   r  r    )	r   r>   r  r$  r  r  r  r  r   s	            rD   r3  r3    s    
xx1}og6og/%%gyy#((C&&wSXXFsHH$//"F&11'4R4=I #"{{!jj	* mmoWs88rF   c                 Z   [        U [        R                  5      (       d  [        R                  " S5      e[        U[        R                  5      (       d  [        R                  " S5      e[        U[
        [        R                  45      (       d  [        R                  " S5      eSS jnU$ )Nz+The first argument "start" must be a numberz+The second argument "stop" must be a numberz+The third argument "num" must be an integerc                 ^    [         R                  " XU5      n[         R                  " SU5      $ )Ng      $@)r  linspacepower)r<  r  numr  s       rD   r   numpy_logspace.<locals>.impl  s#    KKS)xxa  rF   2   )r   r   r  r	   r   r   r   )r<  r  ra  r   s       rD   numpy_logspacere    s|    eU\\**  !NOOdELL))  !NOOcC/00  !NOO! KrF   c                   ^ [        U [        R                  5      (       d  Sn[        R                  " U5      e[        U[        R                  5      (       d  Sn[        R                  " U5      e[        U[
        [        R                  45      (       d  Sn[        R                  " U5      e[        S X4 5       5      (       a=  [        [        R                  " [        U 5      [        U5      S 5      5      mSU4S jjnU$ SS jnU$ )Nz%The argument "start" must be a numberz$The argument "stop" must be a number%The argument "num" must be an integerc              3   V   #    U  H  n[        U[        R                  5      v   M!     g 7frX  r   r   ComplexrZ  r  s     rD   r\  "numpy_geomspace.<locals>.<genexpr>       
C]c:c5==))]r^  c                 d  > U S:X  d  US:X  a  [        S5      eT	" U 5      n T	" U5      n[        S:  a  U R                  S:H  UR                  S:H  -  n[        R                  " U 5      S:H  [        R                  " U5      S:H  -  nSnU(       a  U R
                  n UR
                  nSnU(       a	  U * n U* nU* nO[        R                  " U 5      nX-  n X-  n[        R                  " U 5      n[        R                  " U5      n[        R                  " XgU5      nUS:  a  XS'   US:  a  XS'   XX-  $ )Nr   &Geometric sequence cannot include zerorw  r\  rH   y              ?)r   r   realr  signimaglog10logspace)
r<  r  ra  both_imaginaryboth_negativeout_signlogstartlogstopr-  result_dtypes
            rD   r   numpy_geomspace.<locals>.impl  s   zTQY !IJJ 'E%Dv%"'**/dii1n!E!#2!5"''$-2:M N!!JJE99D!H "FE 5D (yH775>! xxHhhtnG[[C8F Qw!q	7!%2J$$rF   c                 p   U S:X  d  US:X  a  [        S5      e[        R                  " U 5      S:H  [        R                  " U5      S:H  -  nSnU(       a	  U * n U* nU* n[        R                  " U 5      n[        R                  " U5      n[        R                  " XVU5      nUS:  a  XS'   US:  a  XS'   XG-  $ )Nr   ro  r\  rH   )r   r  rq  rs  rt  )r<  r  ra  rv  rw  rx  ry  r-  s           rD   r   r{  !  s    zTQY !IJJWWU^r1bggdmr6IJMHu$9xxHhhtnG[[C8F Qw!q	7!%2J$$rF   rc  )r   r   r  r	   r   r   r   r_  r   r  result_typer   )r<  r  ra  r   r   rz  s        @rD   numpy_geomspacer~    s    eU\\**5  %%dELL))4  %%cC/005  %%

Ce]
CCC!"..%19$#G H 	%p K+	%* KrF   c                 <   [        U[        [        R                  45      (       d  [        R
                  " S5      e[        U [        R                  5      (       d  [        R
                  " S5      eU R                  S:  a  [        R                  " S5      eSS jnU$ )Nz*The second argument "k" must be an integerz'The first argument "m" must be an arrayrx  Input must be >= 2-d.c                 V   US-  nUS:X  a  U S S  $ US:X  a,  [         R                  " [         R                  " U 5      SS5      $ US:X  a*  [         R                  " [         R                  " U 5      5      $ US:X  a,  [         R                  " [         R                  " U SS5      5      $ [        e)N   r   rH   rx     )r  swapaxesfliplrflipudr  )r  r   s     rD   r   numpy_rot90.<locals>.implD  s    E6Q4K!V;;ryy|Q22!V99RYYq\**!V99R[[Aq122  rF   r  )	r   r   r   r   r	   r   r   rs   NumbaValueError)r  r   r   s      rD   numpy_rot90r  9  sx     a#u}}-..  !MNNa%%  !JKKvvz$$%<==! KrF   c                    U R                  [        R                  5      nUR                  5       nU R                  [        R                  5      n	[
        R                  " U	XxUXxUXy/5      n
[        R                  " UR                  U
S5      nU" UR                  5      n[        R                  " XR                  S5      SS5      n[        R                  " XR                  S5      SS5      nU" U5      n[        R                  " XSS5      n[        R                  " XSS5      nU	" S5      nUR                  XXXEUUR                  U/5      nU$ )z
Call into Numba_attempt_nocopy_reshape() for the given array type
and instance, and the specified new shape.

Return value is non-zero if successful, and the array pointed to
by *newstrides* will be filled up with the computed results.
numba_attempt_nocopy_reshaperh   r   r   )r   r   r   r=  intcr   FunctionTyper
   get_or_insert_functionr;   rs   rk   rj   callr   )r   r>   r   r  newndnewshape
newstridesr  ll_intp_starll_intcr  fnndrh   r   
is_f_orderr  s                    rD   _attempt_nocopy_reshaper  T  s1    $$UZZ0G%%'L$$UZZ0G??7||% D 
	'	'(F
HB 
	B  *>*>w*GANE""7,@,@,K#$a)GENE##Gq!<H%%g1a@JJ
,,r!ZLL*6 7C JrF   c                    SnSn[        U5       H  u  pEUS:  a	  US-  nUnM  X5-  nM     US:X  a  X:w  a  [        S5      eg US:X  a0  US:X  a  SnU S:H  nOX-  nX-  S:H  nU(       d  [        S5      eXqW'   g [        S5      e)Nr   rH   z)total size of new array must be unchangedzmultiple negative shape values)r   r   )	origsizerh   num_neg_value
known_sizer   r   neg_axinferredoks	            rD   normalize_reshape_valuer  x  s    MJ5!q5QMFOJ " !HII " 
!	?HQB-H&!+BHII f 9::rF   zarray.reshapec           
         UR                   S   nUR                  nUR                   S   nUS   nU R                  [        R                  5      n[
        R                  " XR                  5      n	[        U5      " XUS   5      n
[        R                  " X5      nUR                  X{5        [        R                  " UR                  SSS9n[        U5      " X5      nU R                  [        R                  U R                  U5      5      n[!        UUR#                  XR%                  5       5      U R                  [        R                  UR                  5      /U/US S9  U
R&                  nU R)                  U[*        [,        R.                  " [        R0                  [        R2                  U5      XR5                  5       /5        UR                  n[        R                  " X5      n[7        XXJUUU5      nUR9                  SUUR;                  S5      5      nUR=                  U5         SnU R>                  RA                  U[B        U45        S S S 5        [        U5      " X5      n[!        UU
RD                  URG                  U5      URG                  U5      U
RH                  U
RJ                  U
RL                  S9  UR5                  5       n[O        XUR                  U5      $ ! , (       d  f       N= f)	Nr   rH   r   r:  r;  r&  zincompatible shape for arrayrM  )(r  r  r   r   r   r   r<  r   r   r
   rY   r,  r   r   r   r   r   rw  r=  r   r>  r  r   r$   r?  r   r  r  r)  r:   r(  rt  ru  rT   r   r?   r   r   r   r    )r   r>   r]   r  r   rettyr.  rh   r  ll_shaper  r  shape_ary_ty	shape_aryshape_itemsizer   r  r  r  failr   r  r  s                          rD   array_reshaper    s[   HHQKEOOEhhqkGGE$$UZZ0G||G]]3H
U
Gd1g
6C ""75HMM%" ;;W]]3GL<(:I))%***1*@*@*IKN92D2D2FG!..uzz7==IJ*+*! ::D W&=#--ejj.3kk<I"$7$7$9:< MME$$W7J	 5u!):
7B  r2771:6D		,))'3FO 
 U
G
-C3 h/"<<
3LL;;**& --/CWsDD 
	s   )%K##
K1c                 6    [        XX#5      u  pE[        XXE5      $ rX  )r1  r  rN  s         rD   array_reshape_varargr    s    '#DG7==rF   )rx  rH   c                     S nU$ )Nc                 $    U R                  U5      $ rX  reshape)rK  r  s     rD   np_reshape_impl#np_reshape.<locals>.np_reshape_impl  s    99X&&rF   ru   )rK  r  r  s      rD   
np_reshaper    s    	'rF   c                     S nU$ )Nc                 $    U R                  U5      $ rX  r  )rK  rh   s     rD   r  r    s    99U##rF   ru   )rK  rh   r  s      rD   r  r    s    	$rF   c                 Z   [        U 5      (       d  Sn[        R                  " U5      e[        U[        R
                  5      (       a)  [        UR                  [        R                  5      (       d7  [        U[        R                  5      (       d  Sn[        R                  " U5      eS nU$ )N#The argument "a" must be array-likezBThe argument "new_shape" must be an integer or a tuple of integersc                 N   [         R                  " U 5      n [         R                  " U 5      n [        U[        5      (       a7  Sn[         R                  " U5       H  nX#-  nUS:  d  M  Sn[        U5      e   OUS:  a  Sn[        U5      eUnU R                  S:X  a/  [         R                  " U5      R                  U R                  5      $ U* U R                  -  * nU n[        US-
  5       H  n[         R                  " Xp45      nM     US U n[         R                  " Xq5      $ )NrH   r   z0All elements of `new_shape` must be non-negative)r  r  ravelr   r   r   r   zerosastyper   r9   concatenater  )	rK  	new_shapenew_size
dim_lengthr   msg2repeatsr  rp   s	            rD   r   numpy_resize.<locals>.impl  s    JJqMHHQKi''H jj3
&>LC$S/)	 4 1}I && H66Q;88I&--agg66I'(w{#A..#*C $)8nzz#))rF   )r   r	   r   r   r   r  r   r   )rK  r  r   r   s       rD   numpy_resizer    s     A3  %%	5>>22	77y%--00%  %%*8 KrF   c                 @   [        U 5      (       d  [        R                  " S5      e[        U5      (       d  [        R                  " S5      e[        U5      (       a  SS jnU$ [	        U[
        R                  5      (       d  [        R                  " S5      eSS jnU$ )Nz+The first argument "arr" must be array-likez/The second argument "values" must be array-likec                     [         R                  " [         R                  " U 5      5      n [         R                  " [         R                  " U5      5      n[         R                  " X45      $ rX  )r  r  r  r  rO  valuesr   s      rD   r   np_append.<locals>.impl%	  s@    ((2::c?+CXXbjj01F>>3-00rF   z,The third argument "axis" must be an integerc                 .    [         R                  " X4US9$ Nr   r  r  r  s      rD   r   r  /	  s    >>3-d;;rF   rX  )r   r	   r   r   r   r   r   )rO  r  r   r   s       rD   	np_appendr  	  s     C    !NOOF##   ". / 	/ 4	1 K $..$$ &/ 0 0	<KrF   zarray.ravelc                     S nS nUR                   S   R                  S:X  a  UnOUnU R                  XX#5      n[        XUR                  U5      nU$ )Nc                 8    U R                  U R                  5      $ )zNo copy version)r  r   r  s    rD   
imp_nocopyarray_ravel.<locals>.imp_nocopy7	  s    {{388$$rF   c                 "    U R                  5       $ )zCopy version)flattenr  s    rD   imp_copyarray_ravel.<locals>.imp_copy;	  s    {{}rF   r   r   )r  rA  r>  r!   r  )r   r>   r]   r  r  r  impr  s           rD   array_ravelr  4	  sY    %
 xx{S  

"
"7
;C
7S__c
BCJrF   c                 ,    S nU R                  XX#5      $ )Nc                 "    U R                  5       $ rX  )r  rK  s    rD   np_ravel_implnp_ravel.<locals>.np_ravel_implM	  s    wwyrF   )r>  )r   r>   r]   r  r  s        rD   np_ravelr  K	  s     ##GCFFrF   zarray.flattenc                 ^    S nU R                  XX#5      n[        XUR                  U5      nU$ )Nc                 T    U R                  5       R                  U R                  5      $ rX  )r  r  r   r  s    rD   r  array_flatten.<locals>.impV	  s    xxz!!#((++rF   )r>  r!   r  )r   r>   r]   r  r  r  s         rD   array_flattenr  S	  s2    , 
"
"7
;C
7S__c
BCJrF   c                    Uc  [         R                  " U 5      OUn[         R                  " XU5      u  pVn[         R                  " UR                  5       H&  nXX   n	Xh   n
Xx   n[        [        X5      U5      XH'   M(     U$ rX  )r  
empty_likebroadcast_arraysndindexrh   minr  )rK  a_mina_maxr  r  a_ba_min_ba_max_br	  val_a	val_a_min	val_a_maxs               rD   _np_clip_implr  ^	  su     "k"--
sC//%@C'CII&
N	N	U.	:
	 ' JrF   c                     [         R                  " U R                  5       H.  nX   nX   nU(       a  [        XV5      X4'   M!  [	        XV5      X4'   M0     U$ rX  )r  r  rh   r  r  )rK  buse_minr  r	  r  val_bs          rD   _np_clip_impl_noner  l	  sI    AGG$U*CJU*CJ % JrF   c                    [        U 5      (       d  [        R                  " S5      e[        U[        R
                  5      (       d&  [        U5      (       d  [        R                  " S5      e[        U[        R
                  5      (       d&  [        U5      (       d  [        R                  " S5      e[        U[        R                  5      (       d(  [        U5      (       d  Sn[        R                  " U5      eUS L =(       d    [        U[        R
                  5      nUS L =(       d    [        U[        R
                  5      nU(       a  U(       a  SS jnU$ [        U[        R                  5      n[        U[        R                  5      n	U(       a  U	(       a  SS jn
U
$ U(       a  U	(       d  U(       a  SS jnU$ SS jnU$ U(       d  U	(       a  U(       a  SS	 jnU$ SS
 jnU$ U(       a  SS jnU$ U(       a  SS jnU$ SS jnU$ )Nr  z6The argument "a_min" must be a number or an array-likez6The argument "a_max" must be a number or an array-likez5The argument "out" must be an array if it is providedc                     [        S5      e)Nz&array_clip: must set either max or minr   rK  r  r  r  s       rD   
np_clip_nnnp_clip.<locals>.np_clip_nn	  s    EFFrF   c                     Uc  [         R                  " U 5      OUn[         R                  " U R                  5       H  nX   n[	        [        Xa5      U5      XE'   M      U$ rX  )r  r  r  rh   r  r  rK  r  r  r  r  r	  r  s          rD   
np_clip_ssnp_clip.<locals>.np_clip_ss	  sP     '*k"--"sCAGG, U!2E:
 - JrF   c                     Uc  [         R                  " U 5      OUn[         R                  " U R                  5       H  nX   n[	        Xa5      XE'   M     U$ rX  )r  r  r  rh   r  r  s          rD   
np_clip_snnp_clip.<locals>.np_clip_sn	  I     +.+bmmA&3ZZ0EHE!$U!2CJ 1 
rF   c                 F    [         R                  " X5      n[        XX#5      $ rX  r  	full_liker  )rK  r  r  r  
a_min_fulls        rD   
np_clip_sanp_clip.<locals>.np_clip_sa	  s    
  \\!3
$QE??rF   c                     Uc  [         R                  " U 5      OUn[         R                  " U R                  5       H  nX   n[	        Xb5      XE'   M     U$ rX  )r  r  r  rh   r  r  s          rD   
np_clip_nsnp_clip.<locals>.np_clip_ns	  r   rF   c                 F    [         R                  " X5      n[        XXC5      $ rX  r  )rK  r  r  r  
a_max_fulls        rD   
np_clip_asnp_clip.<locals>.np_clip_as	  s    
  \\!3
$Qz??rF   c                     Uc  [         R                  " U 5      OUn[         R                  " X5      u  pV[        XVSU5      $ )NTr  r  r  r  )rK  r  r  r  r  r  r  s          rD   
np_clip_nanp_clip.<locals>.np_clip_na	  s7    *-+bmmA&3!221<)#cBBrF   c                     Uc  [         R                  " U 5      OUn[         R                  " X5      u  pV[        XVSU5      $ )NFr  )rK  r  r  r  r  r  r  s          rD   
np_clip_annp_clip.<locals>.np_clip_an	  s7    *-+bmmA&3!221<)#sCCrF   c                     [        XX#5      $ rX  )r  r  s       rD   
np_clip_aanp_clip.<locals>.np_clip_aa	  s     %Qu::rF   rX  )	r   r	   r   r   r   rS  r   r   r  )rK  r  r  r  r   a_min_is_nonea_max_is_noner  a_min_is_scalara_max_is_scalarr  r  r  r  r  r  r  r  s                     rD   np_clipr  x	  s   A  !FGGuenn-- ''   #4 6 	6 uenn-- ''   "4 5 	5 sEKK((K,<,<E  %% TMFZu~~%FMTMFZu~~%FM	G  5O 5O?		 		 @ 	 @  C D ; rF   clipc                     SS jnU$ )Nc                 0    [         R                  " XX#5      $ rX  )r  r  r  s       rD   r   array_clip.<locals>.impl	  s    wwq,,rF   NNNru   )rK  r  r  r  r   s        rD   
array_clipr"  	  s    -KrF   c           	      `  ^^^^ UR                   UR                   :X  d   eUR                  UR                  :X  d   e[        UR                  5      n[        S5      m[        S5      m[        S5      m[        R                  mUUUU4S jnU R                  [        R                  [        X5      5      nU R                  [        R                  [        X5      5      nU R                  [        R                  UR                   5      n	[        R                  " XR                  S5      SS5      n
[        R                  " UUR                  S5      SS5      n[        R                  " [        R                  SSS	9nU R                  U5      n[        R                  " UU R                  [        R                  UR                   5      /5      nU R                  U R                  [        R                  5      5      nU R                  [        R                  U5      n[        R                  " X/5      nU" X5      n[!        UU
UUUS
S9  U" X5      n[!        UUUUUS
S9  UR#                  5       nUR#                  5       nU	UUXxU R                  [        R                  U5      /n[%        [        R&                  [        R                  UU[        R                  [        R                  [        R                  5      nU R)                  XUU5      n[+        X45        [-        XUR.                  U5      nU$ )z
Attempt to fix up *ary* for switching from *oldty* to *newty*.

See Numpy's array_descr_set()
(np/core/src/multiarray/getset.c).
Attempt to fix the array's shape and strides for a new dtype.
False is returned on failure, True on success.
r  r   Fc                    > UT	:X  a#  US   U:X  a	  T" T
5      nOUS   U:X  a  T" T5      nX4:w  a  UT	:X  d  U S:X  a  gUT
:X  a  U S-
  nOSnXC:  a  X4-  S:w  a  gX4-  nX==   U-  ss'   XBU'   gXC:  a  X   U-  nX-  S:w  a  gX-  X'   XBU'   g g)Nr\  r   FrH   Tru   )r  ro   r   old_itemsizenew_itemsizerA  rp   newdim
bytelength
any_layoutc_layoutf_layoutint8s            rD   r  _change_dtype.<locals>.imp
  s     Zr{l*h|+h'Vz-AR1WXQAA& +1!1FGvG%AJ"  ( </J)a/ 0DG%AJ  rF   rh   r   r   rH   r:  Nr;  )rs   rA  ordr   r-  r   r   r   r
   rk   rj   r   r   rm   r   r   r   r  r$   booleanr>  r   r    r  )r   r>   oldtynewtyr  
new_layoutr  r&  r'  r  
shape_datastrides_datashape_strides_array_typearyclsshape_constantsizeof_intpstrides_constantr  strides_aryrh   r   r  r]   r  r*  r+  r,  r-  s                           @@@@rD   _change_dtyper<  	  s    ::###<<5<<'''U\\"JSJ3xH3xH::D. .` ''

(4W(DFL''

(4W(DFL 
		ejj%**	5B%%g/C/CG/L&',J''(+(<(<Y(GAOL  %{{!CP 89F'')0)=)=ejj>Cjj*J )KLN (()>)>uzz)JKK&&uzz;?K))'=Aw(I9"'+'! *K;$'+'! !E##%Gw  Z8:D EMMJJ,,JJJJJJC 
"
"7d
;Ce!
Gcoos
CCJrF   c                 X    [        U 5      (       d  [        R                  " S5      eS nU$ )Nz+The argument to np.shape must be array-likec                 B    [         R                  " U 5      R                  $ rX  )r  r  rh   r  s    rD   r   np_shape.<locals>.impl|
  s    zz!}"""rF   r   r	   r   rK  r   s     rD   np_shaperB  w
  s)    A  !NOO#KrF   c                 X    [        U 5      (       d  [        R                  " S5      eS nU$ )Nz*The argument to np.size must be array-likec                 B    [         R                  " U 5      R                  $ rX  )r  r  r   r  s    rD   r   np_size.<locals>.impl
  s    zz!}!!!rF   r@  rA  s     rD   np_sizerF  
  s)    A  !MNN"KrF   c                     S nU$ )Nc                 <   S n[         R                  " U R                  5       5      n[        US S 5      n[	        USS  5       VVs/ s H/  u  pEX$   U:w  d  M  U" X$   5      (       a  U" U5      (       a  M-  UPM1     nnn[         R
                  " X6-   5      $ s  snnf )Nc                     X :X  + $ rX  ru   )r  s    rD   isnan0np_unique.<locals>.np_unique_impl.<locals>.isnan
  s
    <rF   rH   )r  sortr  r   r   r   )arrJ  r  headrp   r  tails          rD   np_unique_impl!np_unique.<locals>.np_unique_impl
  s    	  GGBHHJAbqE{#AabE*
*$!tqy "'++%( * 	 
 xx$$	
s   BB7Bru   )rM  rP  s     rD   	np_uniquerR  
  s    
% rF   c                    S n[        U [        R                  [        R                  [        R                  [        R
                  [        R                  45      (       a  [        U[        R                  5      (       a  [        $ [        U[        R                  [        R                  45      (       a+  [        UR                  [        R                  5      (       a  U$ [        R                  " S5      eg )Nc                 F   [         R                  " U[         R                  S9nUR                  S   S:X  a  [	        XS   5      $ [         R
                  " US:  5      (       a  [        S5      e[         R                  " U 5      nUR                  5       nUR                  S   nUR                  UR                  :w  a  [        S5      e[         R                  " [         R                  " U5      UR                  S9nSn[        U5       H  nXH   XgXrU   -   & XrU   -  nM     U$ )Nr   r   rH   r  z(operands could not be broadcast together)r  r  r  rh   np_repeat_impl_repeats_scalerr_  r   r  emptyr  r   r9   )	rK  r  repeats_arrayasaaraveln	to_returnposrp   s	            rD   !np_repeat_impl_repeats_array_like4np_repeat.<locals>.np_repeat_impl_repeats_array_like
  s    

7"((;q!Q&0!4DEE66-!#$$BCCjjmLLO<<=...:< <HHRVVM2#))D	qA6<iIC"223##C  rF   zIThe repeats argument must be an integer or an array-like of integer dtype)r   r   r   Listre  r  r  r   rV  r   r	   r   )rK  r  r^  s      rD   	np_repeatra  
  s    
, !ekkjjoollmm	   gu}}--00%++uzz!:;;'--7788  01 	1rF   c                    US:  a  [        S5      e[        R                  " U 5      nUR                  5       nUR                  S   nUS:X  a  [        R
                  " SUR                  S9$ US:X  a  [        R                  " U5      $ [        R
                  " XA-  UR                  S9n[        U5       H  nX6   XVU-  US-   U-  & M     U$ )Nr   r  rU  rH   )	r   r  r  r  rh   rW  r   r  r9   )rK  r  rY  rZ  r[  r\  rp   s          rD   rV  rV  
  s    {>??
**Q-CYY[FQA!|xx++	AwwvHHQ[		:	qA9?I'kQUg$56 rF   repeatc                     S nU$ )Nc                 .    [         R                  " X5      $ rX  )r  rc  )rK  r  s     rD   array_repeat_impl'array_repeat.<locals>.array_repeat_impl
  s    yy$$rF   ru   )rK  r  rf  s      rD   array_repeatrh  
  s    % rF   c                 :    [         R                  " U5      nS nX#4$ )z"Computes the itemsize of the dtypec                     U R                  UR                  S   R                  5      nU R                  UR                  5      nU" U R	                  U5      5      $ r   )r   r  r   r  r   )cgctxr>   r]   llargsr   llintps         rD   r  %_intrin_get_itemsize.<locals>.codegen
  sJ    ""388A;#4#45$$S__5e**4011rF   )r   r   )tyctxr   r]   r  s       rD   _intrin_get_itemsizerp  
  s!     **U
C2 <rF   c                     g rX  ru   )rK  r   s     rD   _compatible_viewrr  
      rF   c                     S nU$ )zDDetermines if the array and dtype are compatible for forming a view.c                     [        U5      nX R                  :w  a  U R                  S:X  a  Sn[        U5      e U R                  S-
  nU R                  U   S:g  nU R
                  S:g  nU R                  U   U R                  :g  nU(       a  U(       a  U(       a  Sn[        U5      eX R                  :  a'  US:X  d  U R                  U-  S:w  a  Sn	[        U	5      eg U R                  U   U R                  -  n
X-  S:w  a  Sn[        U5      eg g )Nr   zOChanging the dtype of a 0d array is only supported if the itemsize is unchangedrH   zJTo change to a dtype of a different size, the last axis must be contiguouszZWhen changing to a smaller dtype, its size must be a divisor of the size of original dtypezuWhen changing to a larger dtype, its size must be a divisor of the total size in bytes of the last axis of the array.)rp  r   rs   r   rh   r   r   )rK  r   
dtype_sizemsg1r   p1p2p3r  msg3r(  msg4s               rD   r    ol_compatible_view.<locals>.impl
  s   )%0
#vv{7 &&  66A:D!#B1B4AJJ.Brb2 &&JJ&?ajj:&=&BID$T** 'C
 3&!+1D %T**	 ,9 $rF   ru   rK  r   r   s      rD   ol_compatible_viewr  
  s    "+F KrF   z
array.viewc                    UR                   S   nUR                  n[        U5      " XUS   5      n[        U5      " X5      n[        UR                  R
                  5      n[        U5       HN  n	[        Xi5      n
U	S:X  a.  UR                  R                  nUR                  X5      Ul        MB  [        XyU
5        MP     [        S:  aZ  U R                  nUR                  [        5      nUR!                  U/ UR                   Q70 5      nU R#                  X5      nU" X5        [%        XXEU5      nUR'                  SU[)        UR                  S5      5      nUR+                  U5         SnU R,                  R/                  U[0        U45        S S S 5        UR3                  5       n[5        XUR                  U5      $ ! , (       d  f       N5= f)Nr   r   )rH      r&  z"new type not compatible with array)r  r  r   r   r   r   sortedgetattrr   r:   rw  r   r   r  r  rr  r	  rS   r<  r)  r   r(  rt  ru  r   r  r    )r   r>   r]   r  r   r  r  r  fieldsr   r   rn  ro  r  _compatible_view_sigr   r  r  r   r  s                       rD   
array_viewr     sx   HHQKEOOE
U
Gd1g
6C
U
G
-C''(FF^co;HHMMEs2CHCC    &&''(89#11%388rJ##D?W	ws	;B  r8BGGQ+?@D		2))':vF 
 --/CWsDD 
	s   '%F;;
G	r   c                 :    U R                  5       n[        XX$5      $ rX  )rz  r"   r   r>   r  r$  r  s        rD   array_dtyper  K  s    

!
!
#Cg99rF   rh   c                 Z    [        U5      nU" XU5      nUR                  n[        XX&5      $ rX  )r   rh   r"   r   r>   r  r$  r   r   r  s          rD   array_shaper  Q  s/     oGGe,E
++Cg99rF   r   c                 Z    [        U5      nU" XU5      nUR                  n[        XX&5      $ rX  )r   r   r"   r  s          rD   array_stridesr  Z  s/     oGGe,E
--Cg99rF   rs   c                 n    U R                  [        R                  UR                  5      n[	        XX$5      $ rX  )r   r   r   rs   r"   r  s        rD   
array_ndimr  c  s+     

uzz388
4Cg99rF   r   c                 Z    [        U5      nU" XU5      nUR                  n[        XX&5      $ rX  )r   r   r"   r  s          rD   
array_sizer  j  s-    oGGe,E
,,Cg99rF   r   c                 Z    [        U5      nU" XU5      nUR                  n[        XX&5      $ rX  )r   r   r"   r  s          rD   array_itemsizer  r  s/     oGGe,E
..Cg99rF   nbytesc                     [        U5      nU" XU5      nUR                  UR                  UR                  5      n[	        XX&5      $ )z
nbytes = size * itemsize
)r   r   r   r   r"   r  s          rD   array_nbytesr  {  s>     oGGe,E
++ellENN
3Cg99rF   
contiguousc                 n    U R                  [        R                  UR                  5      n[	        XX$5      $ rX  )r   r   r0  	is_contigr"   r  s        rD   array_contiguousr    s)    


u}}cmm
<Cg99rF   c_contiguousc                 n    U R                  [        R                  UR                  5      n[	        XX$5      $ rX  )r   r   r0  is_c_contigr"   r  s        rD   array_c_contiguousr    )    


u}}coo
>Cg99rF   f_contiguousc                 n    U R                  [        R                  UR                  5      n[	        XX$5      $ rX  )r   r   r0  is_f_contigr"   r  s        rD   array_f_contiguousr    r  rF   r  c                 x    U R                  [        R                  UR                  (       + 5      n[	        XX$5      $ rX  )r   r   r0  mutabler"   r  s        rD   array_readonlyr    s+    


u}}#++o
>Cg99rF   ctypesc                     [        U5      nU" XU5      n[        R                  " U5      nU R                  X5      nUR                  Ul        UR
                  Ul        UR                  5       n[        XXh5      $ rX  )r   r   ArrayCTypesr  r   r   r  r    )	r   r>   r  r$  r   r   actctinfor  s	            rD   array_ctypesr    sh    oGGe,E


C
 C  .F**FK]]FN



CWs88rF   r   c                     U R                  XUS9nUR                  nUR                  XPR                  [        R
                  5      5      n[        XX%5      $ Nr#  )r  r   rT  r   r   r   r"   )r   r>   r  r$  r  r  s         rD   array_ctypes_datar    sL      U ;F
++C


3 6 6uzz B
CCg99rF   c                     U R                  XUS9nUR                  nUR                  X`R                  U5      5      n[	        XX65      $ r  )r  r   rw  r   r"   )r   r>   fromtytotyr   r  r  s          rD   array_ctypes_to_pointerr    sH        <F
++C
//#55d;
<Cg::rF   c                    [        U5      " XUS9n[        R                  " [        R                  UR                  5      nUR                  UR                  UR                  5      5      n[        [        R                  XU[        R                  5      nUR                  UR                  UR                  [        R                  U5      /nUR                  X UU5      n	U	$ )a  Helper to invoke the contiguous checker function on an array

Args
----
checker :
    ``numba.numpy_supports.is_contiguous``, or
    ``numba.numpy_supports.is_fortran``.
context : target context
builder : llvm ir builder
aryty : numba type
ary : llvm value
r#  )r   r   r  r   rs   r   r   r   r$   bool_rh   r   r   r>  )
checkerr   r>   r   r  tup_intpr   	check_sig
check_argsr  s
             rD   _call_contiguous_checkr    s     U
GC
8C~~ejj%**5H%%g&<&<U[[&IJH%++x5::FI))S[[&&uzz8<>J((9)35IrF   r   c                     U R                  U[        R                  " U5      5      nX4l        UR	                  5       nU R
                  R                  XU5        [        XX%5      $ rX  )r  r   
ArrayFlagsr   r  r  r  r!   )r   r>   r  r$  flagsobjr  s         rD   array_flagsr    sS    ""7E,<,<S,ABHO



CKKwU+Gc77rF   c                 .   UR                   R                  S:w  a7  U R                  XUS9n[        [        XUR                   UR
                  5      nO9UR                   R                  S:H  nU R                  [        R                  U5      n[        XX%5      $ )Nr   r#  )
rd   rA  r  r  r   r   r   r   r0  r"   )r   r>   r  r$  r  r  r   s          rD   array_flags_c_contiguousr    s     ~~#&&w5&A$]G%(^^X__F nn##s*""5==#6g99rF   c                 p   UR                   R                  S:w  a7  U R                  XUS9n[        [        XUR                   UR
                  5      nOZUR                   R                  nUR                   R                  S:  a  US:H  OUS;   nU R                  [        R                  U5      n[        XX%5      $ )Nr$  r#  rH   rM  )rd   rA  r  r  r   r   rs   r   r   r0  r"   )r   r>   r  r$  r  r  rA  r   s           rD   array_flags_f_contiguousr    s    
~~#&&w5&A$Z%(^^X__F &&"~~22Q6fmFdN""5==#6g99rF   rp  c                     UR                   [        R                  ;   a  [        XX#SS9$ UR                   [        R                  ;   a  [        XX#5      $ [        SR                  [        R                   5      5      e)Nrp  attrzunsupported .real for {})	r   r   complex_domainarray_complex_attrnumber_domainr    rT   r   r:   )r   r>   r  r$  s       rD   array_real_partr    s]    
yyE(((!'CVLL	e))	) 3>>!"<"C"CDJJ"OPPrF   rr  c                    UR                   [        R                  ;   a  [        XX#SS9$ UR                   [        R                  ;   a  [        UR                  SS9U5      n[        XXC/5      u  pV[        XXV5      n[        R                  " XR                  UR                  UR                  UR                  5      S5        [        XUR                   UR#                  5       5      $ [%        SR'                  [(        R                   5      5      e)Nrr  r  Tr  r   zunsupported .imag for {})r   r   r  r  r  r$   r  _parse_empty_like_argsr?  r
   memsetr   r   r   r   r!   r  r  rT   r   r:   )r   r>   r  r$  r]   r  r  r  s           rD   array_imag_partr    s    
yyE(((!'CVLL	e))	)$/503PWw?w'++cll69jj+BCD	F#// #1 	1 ""<"C"CDJJ"OPPrF   c                    US;  d  UR                   [        R                  ;  a  [        SR	                  U5      5      e[        U5      nU" XU5      nUR                   R                  nU R                  U R                  U5      5      nUR                  R                  U5      n	U R                  U5      R                  5       n
UR                  UR                  U
5      nUS:X  a-  UR                  U[         R"                  " S5      " S5      /5      nUR%                  USS9n[        U5      " X5      n['        XS9n[(        R*                  " XU5        [-        XXR/                  5       5      $ )	at  
Given a complex array, it's memory layout is:

    R C R C R C
    ^   ^   ^

(`R` indicates a float for the real part;
 `C` indicates a float for the imaginary part;
 the `^` indicates the start of each element)

To get the real part, we can simply change the dtype and itemsize to that
of the underlying float type.  The new layout is:

    R x R x R x
    ^   ^   ^

(`x` indicates unused)

A load operation will use the dtype to determine the number of bytes to
load.

To get the imaginary part, we shift the pointer by 1 float offset and
change the dtype and itemsize.  The new layout is:

    x C x C x C
      ^   ^   ^
)rp  rr  zcannot get attribute `{}`rr      rH   r  r   rA  )r   r   )r   r   r  rT   r   r   underlying_floatr   r   r   r:   r   r=  rw  r   rB  r   IntTyper  r   r
   copy_structr    r  )r   r>   r  r$  r  r   r   fltysizeof_fltyr   
llfltptrtyr  resulttyr-  repls                  rD   r  r    s5   8 ##syy8L8L'L!"="D"DT"JKKoGGe,E 99%%D(()>)>t)DEK~~"";/H ''-88:Jooejj*5G v~++g

2q(9':; xxd3x/H!'3FW0Dt,Wx9I9I9KLLrF   conj	conjugatec                     S nU$ )Nc                 .    [         R                  " U 5      $ rX  )r  r  rO  s    rD   r   array_conj.<locals>.implX  s    wws|rF   ru   rO  r   s     rD   
array_conjr  U  s    KrF   c                 "    U R                  5       $ rX  )rz  )r   r>   dtypetydtypevals       rD   
dtype_typer  `  s    ""$$rF   r:   kindstatic_getitemc                     UR                   n[        U[        R                  5      (       a#  U R	                  U5      " S5      n[        XXE5      $ Sn[        R                  " U5      e)zThis handles the "static_getitem" when a Numba type is subscripted e.g:
var = typed.List.empty_list(float64[::1, :])
It only allows this on simple numerical types. Compound types, like
records, are not supported.
NzlUnreachable; the definition of __getitem__ on the numba.types.abstract.Type metaclass should prevent access.)r  r   r   r   r   r"   r	   LoweringError)r   r>   r]   r  r  r  r   s          rD   static_getitem_number_clazzr  m  s[     OOE%%% $$U+D1!'E??L""3''rF   c           
         [        U5      nU" XU5      nUR                  n[        U[        R                  5      (       d  [        SU< SU< S35      eUR                  U5      nUR                  U5      n	[        U[        R                  5      (       a3  UR                  UR                  UR                  UR                  -   SS9n
OUR                  USS9n
[        U
5      nU" X5      nU R                  [        R                  U	5      n[        R                  " XR                  XR                  R                   S9n[        U[        R                  5      (       a  [        R"                  " XR$                  UR                  5      nXR$                   Vs/ s H#  nU R                  [        R                  U5      PM%     sn-  n[        R"                  " XR&                  UR                  5      nUUR&                   Vs/ s H#  nU R                  [        R                  U5      PM%     sn-  nU R)                  U R+                  UR                  5      5      nO8UR$                  nUR&                  nU R)                  U R+                  U5      5      n[-        UUUUU R                  [        R                  U5      UR.                  UR0                  S9  UR3                  5       n[5        XU
U5      $ s  snf s  snf )	ze
Generic getattr() implementation for record arrays: fetch the given
record member, i.e. a subarray.
z
attribute z of z not definedr  r:  r  )r  rM  )r   r   r   r   RecordrT   typeofr  NestedArrayr  rs   r   r   r
   r  r   r:   r   rh   r   r   r   r   r   r   r  r    )r   r>   r  r$  r  r   r   rectyper   r  restyrarytyraryconstoffset
newdataptrrh   rp   r   datasizer  s                       rD   array_record_getattrr    sS    oGGe,EiiGgu||,,!%)3#0 1 	1NN4 E^^D!F%**++++CHHuzz$9#  G uS1F'#D&&uzz6:K$$[yy~~J %**++$$Wkk388D{{K{!'&&uzz15{KK&&wsxxHOAG((Q7OO))'*?*?*LM --))'*?*?*FG4""#00XF ==,,( ..
CWuc::' L Ps   *K/?*K4c                 ~    US   n[        U[        5      (       d  [        e[        XUR                  S   US   U5      $ r  )r   r  rT   r  r  )r   r>   r]   r  r	  s        rD   array_record_getitemr    s;    GEeS!!!!#((1+tAwNNrF   c           
         U R                  X$5        UR                  U5      nUR                  U5      n[        U[        R
                  5      (       Ga3  [        U5      nU" X5      nUR                  n	UR                   V
s/ s H"  oR                  [        R                  U
5      PM$     nn
UR                   V
s/ s H"  oR                  [        R                  U
5      PM$     nn
[        R                  " XUU R                  U	5      5      n[        UU[        R                   " X5      [        R                   " X5      U R                  [        R                  UR"                  5      SSS9  UR%                  5       n['        XX.5      $ [        R                  " XUU R                  U5      5      nUR(                  (       a  SOSnU R+                  XUU5      n['        XX.5      $ s  sn
f s  sn
f )zL
Generic getattr() implementation for records: get the given record member.
NrM  rH   )sentry_record_alignmentr  r  r   r   r  r   r   rh   r   r   r   r
   get_record_memberr   r   rm   r   r  r    r   r   )r   r>   r  r$  r  r  elemtyr   r  r   r   r  r  newdatar  dptrr   s                    rD   record_getattrr    s   
 ##C.ZZFZZF&%++,, 6"G%LL"  =>((Q7  	 " nn&$ ?@**5::q9$ 	 &++GF,3,A,A%,HJ$$W7&&w;))%**fkkB	
 mmo 3<<(()0)>)>v)FH""7D%@ 3<<-"&s   )G":)G'c           	         UR                   u  pVUu  pxU R                  XT5        UR                  U5      n	UR                  U5      n
[	        U
[
        R                  5      (       a  [        R                  " U5      " XUS   S9nUR                  n[        R                  " XU	UR                  R                  5      n[        R                  " XUU R                  [
        R                  U
R                   5      5        g[        R                  " XU	U R#                  U
5      5      nU R%                  XXj5      nUR&                  (       a  SOSnU R)                  XXUS9  g)zL
Generic setattr() implementation for records: set the given record member.
rH   r#  Nr   )r  r  r  r  r   r   r  r
   r~   r   r  r:   pointeememcpyr   r   r   r   r   r   r   )r   r>   r]   r  r  r  rh  r  r   r  r  
val_structr~  r  r  r   s                   rD   record_setattrr    s   
 JCKF##C.ZZFZZF&%++,,007>B1gG
oo((&),)9)9;wc++EJJF	H ((&)0)>)>v)FHll777CUCrF   c                     U R                  UR                  S   US   5      nU" XUR                  S   US   US   5      $ )+
Record.__getitem__ redirects to getattr()
r   rH   )get_getattrr  )r   r>   r]   r  r   s        rD   record_static_getitem_strr    sC    
 sxx{DG4D#((1+tAwQ@@rF   c                 ,   UR                   S   R                  n[        UR                   S   R                  5      nU R	                  UR
                  XT   5      nU R                  UR                   S   U5      nU" XUR                   S   US   XT   5      $ )r  rH   r   )r  r   r   r  insert_const_stringr;   r  )r   r>   r]   r  r   r  ll_fieldr   s           rD   record_static_getitem_intr    s    
 ((1+
#
#C#((1+$$%F**7>>6;GHsxx{H5D#((1+tAwDDrF   static_setitemc                     UR                   u  pEnUu  pxn	[        UR                  XF5      n
U R                  X5      nUc   eU" XU	45      $ )+
Record.__setitem__ redirects to setattr()
)r  r$   r  get_setattr)r   r>   r]   r  rectyrG  rh  recr   r   getattr_sigr   s               rD   record_static_setitem_strr  !  sU    
 hhOEeMCcCOOU:Ks0Ds$$rF   c                     UR                   u  pEnUu  pxn	[        UR                  XF5      n
[        UR                   S   R                  5      nU R                  X   U
5      nUc   eU" XU	45      $ )r  r   )r  r$   r  r   r  r  )r   r>   r]   r  r  rG  rh  r  r   r   r  r  r   s                rD   record_static_setitem_intr  .  sq    
 hhOEeMCcCOOU:K#((1+$$%Fv{K8Ds$$rF   c                 &    U R                  XU5      $ )z:
Create a constant array (mechanism is target-dependent).
)make_constant_array)r   r>   r[  pyvals       rD   constant_arrayr  @  s    
 &&wE::rF   c                     [         R                  " [         R                  " S5      UR                  5      nU" [	        UR                  5       5      5      n[        R                  " X5      $ )z?
Create a record constant as a stack-allocated array of bytes.
   )r   r<  r  r  	bytearraytobytesr
   r  )r   r>   r[  r  ltyr   s         rD   constant_recordr   H  sF    
 ,,rzz!}ell
3C
i(
)C$$W22rF   c                 ~    [         R                  " [        U5      [         R                  S9nU R	                  XU5      $ )zE
Create a constant array from bytes (mechanism is target-dependent).
rU  )r  r   r  uint8r  )r   r>   r[  r  bufs        rD   constant_bytesr$  R  s0    
 ((9U#288
4C&&wC88rF   c                 r    UR                   u  pEXE:w  a  [        R                  $ S nU R                  XX#5      $ )Nc                     U R                   UR                   :H  =(       aM    U R                  UR                  :H  =(       a-    U R                  R                  UR                  R                  :H  $ rX  )rh   r   r  r   rK  r  s     rD   array_is_implarray_is.<locals>.array_is_impld  sI    177" /		QYY&/.	0rF   )r  r
   r'  r>  )r   r>   r]   r  atybtyr(  s          rD   array_isr,  ^  s8    xxHC
z   0
 ##GCFFrF   __hash__c                     S $ )Nc                     g rX  ru   r  s    rD   r  ol_array_hash.<locals>.<lambda>q  s    trF   ru   r  s    rD   ol_array_hashr1  o  s    rF   c                     [        U S5      $ )ze
Return the Structure representation of the given *flatiterty* (an
instance of types.NumpyFlatType).
flat_make_flattening_iter_cls)
flatitertys    rD   make_array_flat_clsr7  w  s    
 %Z88rF   c                     [        U S5      $ )zj
Return the Structure representation of the given *nditerty* (an
instance of types.NumpyNdEnumerateType).
ndenumerater4  nditertys    rD   make_array_ndenumerate_clsr<    s    
 %X}==rF   c                    U R                  [        R                  S5      nUR                  S5      n	Ub   UR	                  [
        R                  U5        [        [        U5      5       H  n
[
        R                  " XU
5      n[
        R                  " XR                  U5      5      nX:   nUR                  SX5      n[
        R                  " X5         UR	                  X5        Ub  U" U
5        UR                  U	5        S S S 5        UR	                  X5        Uc  M  U" U
5        M     Ub   UR	                  [
        R                  U5        UR                  U	5        UR!                  U	5        g ! , (       d  f       Nv= f)Nr   end_incrementr%  )r   r   r   r  r,  r
   
false_byter;  r9   rk   r+  r?   r&  	if_likelyr  	true_byter  )r   r>   rs   rh   r   end_flagloop_continue
loop_breakr  bbendr  idxptrr   r   	in_boundss                  rD   _increment_indicesrH    s,   

A.D&&7Eg(((3d$%%g<%%g||F/CD
''S8	w2MM#&(c"NN5! 3 	d#!sO %" g''2NN5E" 32s   .E22
F 	c                     [         R                  " XR                  UR                  5      n[	        XUR                  XdU5        g rX  )r
   r   rh   rs   rH  )r   r>   rN  rO  r   rB  rh   s          rD   _increment_indices_arrayrJ    s.      ))UZZ@EwUXNrF   c                   ^ ^^^^^^^	^
^ T R                   m
T R                  m[        T R                  5      m	T R                  (       a  T
OSm " S S[
        5      n " S SU5      m " U 4S jSU5      m " S S	U5      m " S
 SU5      m " S SU5      m " UUUUUUU	U
U U4
S jS[        R                  " T 5      5      nU$ )ze
Return the Structure representation of the given *nditerty* (an
instance of types.NumpyNdIterType).
rH   c                   Z    \ rS rSrSrS rS r\R                  S 5       r	S r
S rS rS	rg
)$make_nditer_cls.<locals>.BaseSubIteri  z6
Base class for sub-iterators of a nditer() instance.
c                 F    Xl         X l        X0l        X@l        XC-
  U l        g rX  )nditermember_name	start_dimend_dimrs   )r[   rO  rP  rQ  rR  s        rD   r  -make_nditer_cls.<locals>.BaseSubIter.__init__  s!     K*&N"L+DIrF   c                 F    [        U R                  U R                  U5        g rX  )r   rO  rP  )r[   rn   s     rD   set_member_ptr3make_nditer_cls.<locals>.BaseSubIter.set_member_ptr  s    DKK!1!137rF   c                 B    [        U R                  U R                  5      $ rX  )r  rO  rP  r  s    rD   
member_ptr/make_nditer_cls.<locals>.BaseSubIter.member_ptr  s    4;;(8(899rF   c                     g rX  ru   )r[   r   r>   s      rD   init_specific2make_nditer_cls.<locals>.BaseSubIter.init_specific  r  rF   c                     g rX  ru   r[   r   r>   logical_dims       rD   rC  2make_nditer_cls.<locals>.BaseSubIter.loop_continue  r  rF   c                     g rX  ru   r^  s       rD   rD  /make_nditer_cls.<locals>.BaseSubIter.loop_break  r  rF   )rR  rP  rs   rO  rQ  N)rv   rw   rx   ry   r  r  rU  r  cached_propertyrX  r[  rC  rD  r{   ru   rF   rD   BaseSubIterrM    s:    		,	8 
	"	"	: 
#	:			rF   rd  c                   0    \ rS rSrSrS rS rS rS rSr	g)	$make_nditer_cls.<locals>.FlatSubIteri  z
Sub-iterator walking a contiguous array in physical order, with
support for broadcasting (the index is reset on the outer dimension).
c                     UR                  [        R                  S5      nU R                  [        R
                  " X#5      5        g r   )r   r   r   rU  r
   r  )r[   r   r>   r  s       rD   r[  2make_nditer_cls.<locals>.FlatSubIter.init_specific  s1    ''

A6D 9 9' HIrF   c                 r    UR                  U R                  5      nUR                  UR                  U/5      $ rX  )r?   rX  rB  r   )r[   r   r>   r   rN  rO  r	  s          rD   compute_pointer4make_nditer_cls.<locals>.FlatSubIter.compute_pointer  s+    LL1E;;sxx%11rF   c                     X0R                   S-
  :X  aM  UR                  U R                  5      n[        R                  " X$5      nUR                  X@R                  5        g g r  )rs   r?   rX  r
   r+  r,  )r[   r   r>   r_  r	  s        rD   rC  2make_nditer_cls.<locals>.FlatSubIter.loop_continue  sG    ii!m+T__5//?e__5	 ,rF   c                 F   US:X  a<  UR                  [        R                  S5      nUR                  X@R                  5        g X0R
                  S-
  :X  aM  UR                  U R                  5      n[        R                  " X%5      nUR                  XPR                  5        g g r  )	r   r   r   r,  rX  rs   r?   r
   r+  )r[   r   r>   r_  r  r	  s         rD   rD  /make_nditer_cls.<locals>.FlatSubIter.loop_break  su    a++EJJ:dOO4		A-T__5//?e__5	 .rF   ru   N)
rv   rw   rx   ry   r  r[  rj  rC  rD  r{   ru   rF   rD   FlatSubIterrf    s    	
	J	2	6		6rF   rp  c                   ,   > \ rS rSrSrU 4S jrS rSrg)+make_nditer_cls.<locals>.TrivialFlatSubIteri  z`
Sub-iterator walking a contiguous array in physical order,
*without* support for broadcasting.
c                 ,   > TR                   (       a   eg rX  )need_shaped_indexing)r[   r   r>   r;  s      rD   r[  9make_nditer_cls.<locals>.TrivialFlatSubIter.init_specific  s    44444rF   c                 x    [        U5      S::  d   [        U5      5       eUR                  UR                  U5      $ r  )r   rB  r   r[   r   r>   r   rN  rO  s         rD   rj  ;make_nditer_cls.<locals>.TrivialFlatSubIter.compute_pointer  s2    w<1$2c'l2$;;sxx11rF   ru   N)rv   rw   rx   ry   r  r[  rj  r{   r:  s   rD   TrivialFlatSubIterrr    s    	
	5	2rF   ry  c                       \ rS rSrSrS rSrg)'make_nditer_cls.<locals>.IndexedSubIteri  z1
Sub-iterator walking an array in logical order.
c           	      f    [        U5      U R                  :X  d   e[        R                  " XXEUSS9$ NFrd  )r   rs   r
   r@  rw  s         rD   rj  7make_nditer_cls.<locals>.IndexedSubIter.compute_pointer  s6    w<499,,,++Ge,3G GrF   ru   Nrv   rw   rx   ry   r  rj  r{   ru   rF   rD   IndexedSubIterr{    s    		GrF   r  c                       \ rS rSrSrS rSrg)'make_nditer_cls.<locals>.ZeroDimSubIteri  z%
Sub-iterator "walking" a 0-d array.
c                     UR                   $ rX  )r   rw  s         rD   rj  7make_nditer_cls.<locals>.ZeroDimSubIter.compute_pointer  s    88OrF   ru   Nr  ru   rF   rD   ZeroDimSubIterr    s    		rF   r  c                       \ rS rSrSrS rSrg)&make_nditer_cls.<locals>.ScalarSubIteri  z(
Sub-iterator "walking" a scalar value.
c                     U$ rX  ru   rw  s         rD   rj  6make_nditer_cls.<locals>.ScalarSubIter.compute_pointer  s    JrF   ru   Nr  ru   rF   rD   ScalarSubIterr    s    		rF   r  c                      >
 \ rS rSrSr\R                  U UUUUU4S j5       rUUUU	4S jrU4S jr	S r
S rUUUU	4S jrS	 rS
 rSrg)make_nditer_cls.<locals>.NdIteri  z
.nditer() implementation.

Note: 'F' layout means the shape is iterated in reverse logical order,
so indices and shapes arrays have to be reversed as well.
c           	         > / nTR                   (       a  TOTTTTS.n[        TR                  5       H+  u  p4Uu  pVpxSU-  n	X%   n
UR                  U
" X	Xg5      5        M-     U$ )N)r3  indexed0dscalarzindex%d)rt  r   r  rl   )r[   l	factoriesrp   r*  r  rQ  rR  rG  rP  factoryrp  r  r  ry  r  r;  s              rD   subiters(make_nditer_cls.<locals>.NdIter.subiters#  ss    A080M0M0$2-#0	I $H$5$56.1+'!m#/IGH	 7
 HrF   c                   > UR                  [        R                  S5      nUR                  U[        R                  " U5      U5      U l        [        U5       HP  u  pg[        U[        R                  5      (       a  M&  SU-  n[        R                  " X$U   5      n	[        XU	5        MR     U R                  XX45      n[        R                  " [        R                  T5      n
SnSn[        U5       HT  u  pm[        U[        R                  5      (       d  M&  UR                  T:X  d  M8  XF   R                  nXF   R                   n  O<   TS:X  d   eUR                  X*S5      nUR                  [        R                  S5      nS n[#        X45       H  u  p[        U[        R                  5      (       d  M&  UR                  S:  d  M8  [%        [        R&                  [        R                  " [        R                  UR                  5      U
5      nUR)                  X.UUR                  U45        M     [        R*                  " X+5      nTS:X  a  USSS2   nUR-                  S	X5      nUR/                  U[        R0                  [        R2                  5      nTR4                  (       d  U4n[7        U5      T:X  d   e[        R8                  " X%R:                  TS
9n[=        T5       H-  n[        R>                  " UUU5      nURA                  UU5        M/     UU l!        [        RD                  " UUUR:                  5      U l        [        R                  " UU5      U l#        U RH                   H  nURK                  X5        M     g)zA
Initialize the nditer() instance for the specific array inputs.
r   scalar%dNru   rH   c                     [        U 5      n[        U5       H(  nX   U[        U5      U-
  U-      :w  d  M  [        S5      e   g )Nz2nditer(): operands could not be broadcast together)r   r9   r   )rh   
main_shaper[  rp   s       rD   check_shapeBmake_nditer_cls.<locals>.NdIter.init_specific.<locals>.check_shapeV  sH    JqAx:c*o.AA.E#FF( *> ? ? "rF   r$  r\  r&  r  )&r   r   r   r
  r  arraysr   r   r   r
   r  r   _arrays_or_scalarsr  rs   rh   r   r   r$   noner>  r   r&  r  rA  r?  rt  r   rY   r:   r9   rk   r,  r   rm   	exhaustedr  r[  )r[   r   r>   arrtysr  r  rp   r[  rP  slotmain_shape_tyr  main_nitemsrN  r  rO  r]   r  shape_is_emptyr  r   r  rF  subiterrA  rs   r;  nshapess                           rD   r[  -make_nditer_cls.<locals>.NdIter.init_specific3  s    ''

A6D ",,Wekk&6I-35DK #6*!"ekk22",q.K"44WQiHDDt4 + ,,WvNF "NN5::t<MJK%f-eU[[11ejjD6H!'J"()"2"2K	 . qy y$//K
%225::qA? "&1
eU[[11ejj1n#EJJ$)NN5::uzz$J$13C ,,W-0399j2IK 2 ))'>F}" %00{IN~w7H7H'.'9'9;I 00 &v;')))))'997KGW~ --gwDdF+ & #DL ++GVTYYGDJ$66w	JDN  ==%%g7 )rF   c                 <  > UR                  S5      n[        R                  " UUR                  U R                  5      5      n[        R
                  " X%5         UR                  S5        UR                  U5        SSS5        TR                  n[        R                  " X R                  5      nU R                  XXg5      nU R                  nUR                  S5        U R                  XXU5      n	U	 V
s/ s H  oR                  5       PM     n	n
[        U	5      S:X  a  UR                  U	S   5        O,UR                  UR!                  UTR"                  U	5      5        [        R                  " X R$                  5      n['        X[        U5      UXR                  [(        R*                  " U R,                  UU5      [(        R*                  " U R.                  UU5      5        UR                  U5        UR1                  U5        g! , (       d  f       GN= fs  sn
f )z2
Compute next iteration of the nditer() instance.
rV  FNTrH   r   )r  r
   as_bool_bitr?   r  if_unlikelyr'  r  r  r   r  r   _make_viewsr  r   r*  r
  r)  rh   rH  r  partial_loop_continue_loop_breakr  )r[   r   r>   r-  rE  r  r  r  r   viewsr   rh   r;  s               rD   iternext_specific1make_nditer_cls.<locals>.NdIter.iternext_specific  s    ..u5E  ++G,3LL,HJI$$W8  'u% 9 __F))';;?F,,WvNFllG T"$$WwOE,12Eq[[]EE25zQeAh'g00(:M:M168 9 ((**=EwUU&(001D1D1818 :  )001A1A1818 :! NN5!##E*? 98 3s   #H6H
Hc                     U R                    HH  nUR                  Us=::  a  UR                  :  d  M&  O  M*  UR                  XX4R                  -
  5        MJ     g rX  )r  rQ  rR  rC  r[   r   r>   r  r*  s        rD   r  .make_nditer_cls.<locals>.NdIter._loop_continue  s?    }}==C5#++55%%gmm8KL %rF   c                     U R                    HH  nUR                  Us=::  a  UR                  :  d  M&  O  M*  UR                  XX4R                  -
  5        MJ     g rX  )r  rQ  rR  rD  r  s        rD   r  +make_nditer_cls.<locals>.NdIter._loop_break  s=    }}==C5#++55NN7S==5HI %rF   c                 N  > S/T-  nTR                   nU R                  nTR                  n	[        U	[        R
                  5      (       a  [        U	5      n	OU	/n	[        T5       V
s/ s H)  n
UR                  [        R                  " X#U
5      5      PM+     nn
[        Xx5       H_  u  pUu      pX<R                  UR                   nTS:X  a  USSS2   nU H(  n
Xj   b   eU R                  XUX   XJ   XZ   U5      Xj'   M*     Ma     [        S U 5       5      (       d   eU$ s  sn
f )z"
Compute the views to be yielded.
Nr$  r\  c              3   $   #    U  H  ov   M     g 7frX  ru   rZ  r   s     rD   r\  >make_nditer_cls.<locals>.NdIter._make_views.<locals>.<genexpr>  s     (%Qq%s   )r  r  r)  r   r   re  r   r9   r?   r
   rk   r   rQ  rR  
_make_viewr  )r[   r   r>   r   r  r  r  r  r  rettysrp   r*  r  rG  array_indicessub_indicesrA  narraysr;  r  s                   rD   r  +make_nditer_cls.<locals>.NdIter._make_views  s3    FW$E((H}}H((F&%//22f  %g0 .1 ||G$8$81$MN .  0 !$H 7),&1a%&7&7HS="-dd"3K&A 8+++#w/5y/5y&)W NEH ' !8 (%(((((L0s   '0D"c           	         [        U[        R                  5      (       a  UR                  S:X  d   eUR	                  XX5U5      nUR                  U5      " X5      n	[        X5      n
UR                  U[        R                  " [        R                  S5      S5      nUR                  U[        R                  " [        R                  S5      S5      n[        XXU
SS9  U	$ )z,
Compute a 0d view for a given input array.
r   ru   N)r   )r   r   r   rs   rj  r   r   r
  r  r   r   )r[   r   r>   r   r  rN  rO  r  rn   viewr   rh   r   s                rD   r  *make_nditer_cls.<locals>.NdIter._make_view  s    
 eU[[11ejjAoEE))'GCPC%%e,W>D#G3H&&wuzz10M')+E((%..Q2O)+-G 4ehMKrF   c           	         / n[        [        X45      5       Hm  u  nu  px[        U[        R                  5      (       a(  UR                  UR                  U5      " UUUS95        MO  UR                  [        U SU-  5      5        Mo     U$ )Nr#  r  )r   r   r   r   r   rl   r   r  )	r[   r   r>   r  r  r  rp   rN  rO  s	            rD   r  2make_nditer_cls.<locals>.NdIter._arrays_or_scalars  s}     A#,S-@#A<EeU[[11HHW//6w7>=@B C HHWT:>:; $B HrF   )r  r  r   rh   N)rv   rw   rx   ry   r  r  rc  r  r[  r  r  r  r  r  r  r{   )
rp  r  r  ry  r  rA  r  rs   r;  r  s
   rD   NdIterr    sZ    	 
	"	"	 	 
#	M	8 M	8^(	+T	M
	J
	 	8	(	rF   r  )rs   rA  r   r  rt  objectr
   r~   )r;  rd  r  rp  r  r  ry  r  rA  r  rs   r  s   `  @@@@@@@@@rD   make_nditer_clsr    s    
 ==D__F(//"G33dGf 86k 6@2[ 2G G  V V V,,X6 Vp MrF   c                 d   ^ U R                   m " U4S jS[        R                  " U 5      5      nU$ )zf
Return the Structure representation of the given *nditerty* (an
instance of types.NumpyNdIndexType).
c                   2   > \ rS rSrSrU 4S jrU 4S jrSrg)%make_ndindex_cls.<locals>.NdIndexIteri  z
.ndindex() implementation.
c                   > UR                  [        R                  S5      n[        R                  " X$R
                  UR                  [        R                  T5      S9n[        R                  " U[        R                  5      n[        T5       H  n[        R                  " X%U5      nUR                  XH5        X7   n	UR                  SX5      n
[        R                  " X*5         UR                  [        R                  U5        S S S 5        M     XPl        X`l        [        R                   " X#UR
                  5      U l        g ! , (       d  f       M  = fNr   r  r&  )r   r   r   r
   rY   r:   r  r?  r9   rk   r,  r)  r  rA  r   r  rm   rh   )r[   r   r>   r  r  r   r  r  rF  r  dim_is_emptyrs   s              rD   r[  3make_ndindex_cls.<locals>.NdIndexIter.init_specific  s   ''

A6D))'99/6/C/CEJJDH0JKG  11'7;M;MNIT{ --gDd+ ";&44T8J((?MM'"3"3Y? @? # #L&N ++GTYYGDJ @?s   &!E
E	c           
        > UR                  [        R                  S5      nUR                  S5      n[        R
                  " UUR                  U R                  5      5      n[        R                  " X&5         UR                  S5        UR                  U5        S S S 5        [        T5       Vs/ s H4  nUR                  [        R                  " UU R                  U5      5      PM6     nnU H  n	[        X)5        M     UR                  [        R                   " X(UR"                  5      5        UR                  S5        [        R$                  " X R&                  T5      n
[)        XTU
U R                  U R                  5        UR                  U5        UR+                  U5        g ! , (       d  f       GN= fs  snf )Nr   rV  FT)r   r   r   r  r
   r  r?   r  r  r'  r  r9   rk   r   rJ   r*  rm   r:   r   rh   rH  r  )r[   r   r>   r-  r  rE  r  r  r   r?   rh   rs   s              rD   r  7make_ndindex_cls.<locals>.NdIndexIter.iternext_specific  s`   ''

A6D..u5E++G,3LL,HJI$$W8  'u% 9 #(+/ #.3 ||G$8$89=9<%> ? #.  /  g,   MM',,WtyyIJT"((**dCEwu#||T^^= NN5!##E*' 98/s   9#F*1;F<*
F9)r  r   rh   N)rv   rw   rx   ry   r  r[  r  r{   rs   s   rD   NdIndexIterr    s    		H,	+ 	+rF   r  )rs   r
   r~   )r;  r  rs   s     @rD   make_ndindex_clsr    s.    
 ==D5+g11(; 5+n rF   c                    ^ TS;   d   eU R                   nUR                  S:X  a$   " U4S jS[        R                  " U 5      5      nU$  " U4S jS[        R                  " U 5      5      nU$ )N)r3  r9  r   c                   >   > \ rS rSrSrU 4S jrU 4S jrS rS rSr	g)	6_make_flattening_iter_cls.<locals>.CContiguousFlatIteri=  zB
.flat() / .ndenumerate() implementation for C-contiguous arrays.
c                   > UR                  [        R                  S5      n[        R                  " X%5      U l        UR                  U l        T	S:X  a  [        R                  " X%R                  UR                  [        R                  UR                  5      S9n[        UR                  5       H+  n[        R                  " X&U5      nUR                  XX5        M-     X`l        g g )Nr   r9  r  )r   r   r   r
   r  r	  r   r,  rY   r:   rs   r9   rk   r,  r   )
r[   r   r>   rN  rO  r  r   r  rF  r  s
            rD   r[  D_make_flattening_iter_cls.<locals>.CContiguousFlatIter.init_specificB  s    ++EJJ:$66wE
 "ll=(%11$11%**ejjIKG  %UZZ0!(!5!5g!Ld3  1 $+L )rF   c                 d  > UR                   nUR                  nUR                  U R                  5      nUR	                  SX5      n	UR                  U	5        [        R                  " X)5         UR                  UR                  U/5      n
[        XX:5      nTS:X  a  UR                  U5        OU R                  n[        U5       Vs/ s H*  nUR                  [        R                  " UUU5      5      PM,     nn[        R                  " X.UR!                  ["        R$                  5      S9nUR                  [        R&                  " UX/5      5        [)        XUXL5        [        R*                  " X(5      nUR-                  XR                  5        S S S 5        g s  snf ! , (       d  f       g = f)Nr%  r3  r[  )rs   r   r?   r	  r&  r'  r
   r@  rB  r   r   r*  r   r9   rk   rm   r   r   r   make_anonymous_structrJ  r+  r,  )r[   r   r>   rN  rO  r-  rs   r   r	  r0  rn   r$  r   r  idxvalsidxtupler  s                   rD   r  H_make_flattening_iter_cls.<locals>.CContiguousFlatIter.iternext_specific[  sy   zzTZZ0"..sEB  *&&w9!++chh8C%gCEv~e, #',, /4Dk#; /:s $+<<0D0DWELEH1J $K /:   #; $+#5#5g9@9N9N:?**:F$G #99';C:KMN 1514? $33GCEMM%4- :9#; :9s    .AF!	1F:BF!F!!
F/c                 T    UR                  UR                  U/5      n[        XX65      $ rX  )rB  r   r   r[   r   r>   rN  rO  r	  rn   s          rD   r  >_make_flattening_iter_cls.<locals>.CContiguousFlatIter.getitem{  s%    kk#((UG4 5>>rF   c                 X    UR                  UR                  U/5      n[        XX6U5        g rX  )rB  r   r   r[   r   r>   rN  rO  r	  r$  rn   s           rD   setitem>_make_flattening_iter_cls.<locals>.CContiguousFlatIter.setitem  s$    kk#((UG47U3?rF   )r	  r   r,  N)
rv   rw   rx   ry   r  r[  r  r  r  r{   r  s   rD   CContiguousFlatIterr  =  s    +25@?@rF   r  c                   >   > \ rS rSrSrS rU 4S jrS rS rS r	Sr
g	)
+_make_flattening_iter_cls.<locals>.FlatIteri  z
Generic .flat() / .ndenumerate() implementation for
non-contiguous arrays.
It keeps track of pointers along each dimension in order to
minimize computations.
c                    UR                  [        R                  S5      nUR                  nUR                  n[
        R                  " X$R                  U5      n[
        R                  " X%R                  UR                  [        R                  UR                  5      S9n	[
        R                  " X&R                  UR                  [        R                  UR                  5      S9n
[
        R                  " U[
        R                  5      n[        U5       H  n[
        R                  " X)U5      n[
        R                  " X*U5      nUR                  Xn5        UR                  X]5        X   nUR                  SX5      n[
        R                   " UU5         UR                  [
        R"                  U5        S S S 5        M     Xl        Xl        Xl        g ! , (       d  f       M  = fr  )r   r   r   r   rs   r
   r   rh   rY   r:   r  r?  r9   rk   r,  r)  r  rA  r   pointersr  )r[   r   r>   rN  rO  r  r   rs   r  r   r  r  r  rF  ptrptrr  r  s                    rD   r[  9_make_flattening_iter_cls.<locals>.FlatIter.init_specific  su   ++EJJ:xxzz --gyy$G!--YYW-A-A%**BG**.NO #..YYW-A-A%**BG**.NO $55g6=6H6HJ	 !;C$11'CHF$11'SIFMM$/MM$/  &{H#*#8#8x#NL ,,WlCg&7&7C DC '  ' (!* DCs   !G
G'	c           
      t  > UR                   n[        R                  " X$R                  U5      n[        R                  " X$R                  U5      nU R
                  n	U R                  n
UR                  [        R                  S5      nUR                  S5      n[        R                  " X"R                  U R                  5      5      n[        R                  " X-5         UR                  S5        UR!                  U5        S S S 5        UR                  S5        [        R"                  " X*US-
  5      nUR                  U5      n[%        XX?5      nTS:X  a  UR'                  U5        O[)        U5       Vs/ s H*  nUR                  [        R"                  " UU	U5      5      PM,     nn[        R*                  " UU5      nUR'                  [        R,                  " UUU/5      5        [/        [)        U5      5       GHD  n[        R"                  " X)U5      n[        R0                  " UUR                  U5      5      nUU   nUU   nUR3                  SUU5      n[        R4                  " UU5         UR7                  UU5        [        R"                  " X*U5      nUR                  U5      n[        R8                  " X/U5      nUR7                  UU5        [)        US-   U5       H-  n[        R"                  " UU
U5      nUR7                  UU5        M/     UR!                  U5        S S S 5        UR7                  UU5        GMG     UR7                  [        R:                  U R                  5        UR!                  U5        UR=                  U5        g ! , (       d  f       GN= fs  snf ! , (       d  f       N= f)Nr   rV  FTrH   r3  r%  )rs   r
   r   rh   r   r   r  r   r   r   r  r  r?   r  r  r'  r  rk   r   r*  r9   rm   r  r;  r+  r&  r@  r,  r  rA  r  )r[   r   r>   rN  rO  r-  rs   r  r   r   r  r  rE  is_exhaustedlast_ptrrn   r$  r  r  r  rF  r   r   r,  rG  r  	inner_dimr  s                              rD   r  =_make_flattening_iter_cls.<locals>.FlatIter.iternext_specific  s   zz --gyy$G!..wTJ,,==++EJJ:2259  '22\\$..9 ;((?$$U+NN5) @   & #//4!8Lll8,!'E?6>MM%( +0+7 +63  '||G,@,@AHAD-F  G +6  7  '11'7CHMM55g7?6GIJ $E$K0C$11'CHF!11'29,,v2FHC #3KE$S\F ' 3 3Ce DI **7I>c62!(!5!5g!M%ll62%11'Gc62).sQw)=I%,%9%9':B:C&EF $MM#v6	 *>
  u- ? MM$// 14 g//@u%''.k @?7& ?>s   #N61N$1B5N)
N!)
N7	c           	         UR                   n[        R                  " X$R                  US9n[        R                  " X$R                  US9n/ n	[        [        U5      5       H:  n
U	R                  UR                  XWU
   5      5        UR                  XWU
   5      nM<     U	R                  5         [        R                  " XUR                  XxUR                  U	5      nU$ )Nr  )rs   r
   r   rh   r   r;  r9   rl   uremudivreverser@  r   rA  )r[   r   r>   rN  rO  r	  rs   r  r   r   r  rn   s               rD   _ptr_for_index:_make_flattening_iter_cls.<locals>.FlatIter._ptr_for_index  s    zz --gyyM!..w4P #E$K0CNN7<<c{#CD#LLs<E 1 !//#((06079 
rF   c                 @    U R                  XX4U5      n[        XX65      $ rX  )r  r   r  s          rD   r  3_make_flattening_iter_cls.<locals>.FlatIter.getitem  s#    ))'EN 5>>rF   c                 D    U R                  XX4U5      n[        XX6U5        g rX  )r  r   r  s           rD   r  3_make_flattening_iter_cls.<locals>.FlatIter.setitem	  s"    ))'EN7U3?rF   )r  r   r  N)rv   rw   rx   ry   r  r[  r  r  r  r  r{   r  s   rD   FlatIterr    s%    +BC/J"?@rF   r  )rd   rA  r
   r~   )r6  r  rd   r  r  s    `   rD   r5  r5  7  sr    ****&&JCD	@'"="=j"I D	@L #"E	@w22:> E	@N rF   r3  c                 0   [        [        R                  " U5      5      nU" X5      nX5l        U R	                  U5      nU" XUR                  S5      S9nUR                  XX#5        UR                  5       n[        X[        R                  " U5      U5      $ Nr   )r\   )	r7  r   NumpyFlatTyper   r   rj   r[  r  r    )r   r>   rN  rO  flatiterclsflatiterarrclsr  s           rD   make_array_flatiterr    s    %e&9&9%&@AK7,HN&F
x'@'@'I
JC7U8



CWu/B/B5/I3OOrF   c                     UR                   u  nUu  n[        U5      nU" XUS9nUR                  nU R                  U5      n	U	" XUR                  S9n
UR                  XXU5        g r  )r  r7  rd   r   r   r  )r   r>   r]   r  r-  r6  r  r  rN  r  rO  s              rD   iternext_numpy_flatiterr     si     88LZJX%j1K78<H!!E&F

8CwVDrF   c                     UR                   S   nUu  pV[        U5      nU" XUS9nUR                  nU R                  U5      n	U	" XUR                  S9n
UR                  XXU5      n[        XUR                  U5      $ Nr   r#  )r  r7  rd   r   r   r  r    r  )r   r>   r]   r  r6  r  r	  r  rN  r  rO  r  s               rD   iternext_numpy_getitemr
  0  s~    !JOH%j1K78<H!!E&F

8C


7U
?CWsDDrF   c                     UR                   S   nUu  pVn[        U5      nU" XUS9nUR                  n	U R                  U	5      n
U
" XUR                  S9nUR                  XXXg5        U R                  5       $ r	  )r  r7  rd   r   r   r  rz  )r   r>   r]   r  r6  r  r	  r$  r  rN  r  rO  s               rD   iternext_numpy_getitem_anyr  @  s}     !J!HU%j1K78<H!!E&F

8CWu5@""$$rF   c                     UR                   S   n[        U5      nU" XUS   S9nU R                  UR                  5      nU" XUR                  S9nUR
                  $ r	  )r  r7  r   rd   r   r   )	r   r>   r]   r  r6  r  r  r  rO  s	            rD   iternext_numpy_getitem_flatr  Q  sY    !J%j1K747;H
 5 56F

8C::rF   c                 @   UR                   u  nUu  n[        [        R                  " U5      5      nU" X5      nXWl        U R                  U5      nU" XUR                  S5      S9nUR                  XXE5        UR                  5       n	[        XUR                  U	5      $ r   )r  r<  r   NumpyNdEnumerateTyper   r   rj   r[  r  r    r  )
r   r>   r]   r  rN  rO  	nditerclsrO  r  r  s
             rD   make_array_ndenumerater  \  s    XXFEDC*5+E+Ee+LMIw(FL&F
v'>'>w'G
HC
56



CWsDDrF   c                     UR                   u  nUu  n[        U5      nU" XUS9nUR                  nU R                  U5      n	U	" XUR                  S9n
UR                  XXU5        g r  )r  r<  rd   r   r   r  )r   r>   r]   r  r-  r;  rO  r  rN  r  rO  s              rD   iternext_numpy_nditerr  n  si     JXHV*84Iwv6FE&F

6C
Wu6BrF   c           
      r   [        UR                  U5       VVs/ s H&  u  pEU R                  XU[        R                  5      PM(     nnn[        [        R                  " [        U5      5      5      nU" X5      nUR                  XU5        UR                  5       n	[        XUR                  U	5      $ s  snnf )zndindex(*shape))r   r  r   r   r   r  NumpyNdIndexTyper   r[  r  r    r  )
r   r>   r]   r  argtyr  rh   r  rO  r  s
             rD   make_array_ndindexr  ~  s    
  #388T242 \\'uzz:2 
 4 !!7!7E
!CDIw(F
51



CWsDD4s   -B3c           	         UR                   R                  nUS:  ag  UR                  S   R                  nUS   n[        R
                  " XU5      nU Vs/ s H$  nU R                  XU[        R                  5      PM&     nnO/ n[        [        R                  " [        U5      5      5      n	U	" X5      n
U
R                  XU5        U
R                  5       n[        XUR                   U5      $ s  snf )zndindex(shape)r   )r  rs   r  r   r
   r   r   r   r   r  r  r   r[  r  r    )r   r>   r]   r  rs   r   rb  rh   r   r  rO  r  s               rD   make_array_ndindex_tupler    s     ??Dax!!1g$$W48!#!S gE5::>! 	 #  !7!7E
!CDIw(F
51



CWsDD#s   +C/c                 p    UR                   u  nUu  n[        U5      nU" XUS9nUR                  XU5        g r  )r  r  r  )r   r>   r]   r  r-  r;  rO  r  s           rD   iternext_numpy_ndindexr    s<     JXHV *Iwv6F
Wv6rF   c                 H   UR                   nUR                  n[        UR                  S   [        R
                  5      (       a  [        R                  " XS   5      nOUS   /n[        U5      " X5      nUR                  XXV5        UR                  5       n[        XXH5      $ )z
nditer(...)
r   )r  r  r   r  r   re  r
   r   r  r[  r  r    )	r   r>   r]   r  r;  r  r  rO  r  s	            rD   make_array_nditerr    s    
 H__F#((1+u//%%gAw7q'X&w8F
6:



CWx==rF   c                 l    UR                   u  nUu  n[        U5      " XUS9nUR                  XU5        g r  )r  r  r  )r   r>   r]   r  r-  r;  rO  s          rD   iternext_numpy_nditer2r     s7     JXHVX&wvFF
Wv6rF   c                     UR                   u  pE[        R                  " [        R                  " S5      [	        XE:H  5      5      n[        XUR                  U5      $ r  )r  r   r   r  r   r"   r  )r   r>   r]   r  arg1arg2r  s          rD   dtype_eq_implr$    s?    JD
++bjjmS%6
7CgEErF   c           	         [        U5      nU" X5      nU R                  UR                  5      nU R                  [        R
                  [        X5      5      nU R                  [        R
                  S5      n[        [        R                  " S5      S5      n	U HG  n
UR                  X5      nUR                  US5      nUR                  XR                  US5      5      n	MI     UR                  S:X  a  SnOUR                  S:X  aQ  U/n[        USS 5       H'  nUR!                  UR#                  US   U5      5        M)     [%        [        U5      5      nOsUR                  S:X  a?  U/nUSS  H'  nUR!                  UR#                  US   U5      5        M)     [%        U5      nO$['        SR)                  UR                  5      5      eUR                  X5      nUR                  US5      nUR                  XR                  US5      5      n	UR+                  U	S	S
9   U R,                  R/                  U[0        S5        SSS5        UR                  nU R3                  U5      nU R                  [        R4                  U5      nU R7                  5       UU4n[        R8                  " [        R:                  5      n[        R<                  " [?        U5      5      n[A        UU[        R
                  [        R4                  5      nU RC                  U[D        UU5      nU RF                  RI                  UU5      nU RK                  [        R
                  5      n[L        RN                  " XUS9n[L        RN                  " XUS9n[Q        UURS                  UURU                  5       5      UUUUS9  U$ ! , (       d  f       GNw= f)zUtility function used for allocating a new array during LLVM code
generation (lowering).  Given a target context, builder, array
type, and a tuple or list of lowered dimension sizes, returns a
LLVM value pointing at a Numba runtime allocated array.
rH   r   ru   r   Nr\  r$  z3Don't know how to allocate array with layout '{0}'.Frr  )z[array is too big; `arr.size * arr.dtype.itemsize` is larger than the maximum possible size.r  r;  )+r   r   r   r   r   r   r   r   r   r  smul_with_overflowrl  r(  rs   rA  r;  rl   r   r   rT   r   r(  rt  ru  r   get_preferred_array_alignmentuint32rz  MemInfoPointervoidptrTypeRefr:   r$   r>  _call_allocatorr  meminfo_datar   r
   rm   r   rw  r=  )r   r>   r  r  r7  r  datatyper   arrlenoverflowr   arrlen_multr   dimension_sizeallocsize_multr  r   	align_valr   r  miparytypeclassargtypesr   r   r   shape_arraystrides_arrays                               rD   r?  r?    s%     F

"C$$W]]3H##EJJW0NOH !!%**a0F

1q)H00;&&{A6;;++K;
  ||q	3	*&vabz2NNN7;;wr{NCD 3)*	3	*$SbkNNN7;;wr{NCD *.!AHH ! 	!
 //AN%%na8I{{8%:%:>1%MNH	%	0 	))Z-	
 
1 MME55e<I  y9E##%y%8D


u}}
-C==g/LlEJJEH&&w4PG;;##GW5D##EJJ/F$$W@K&&wFCM3h.A.A.CD$($"$ JA 
1	0s    "N22
O	_allocatec                     S nU$ )zLImplements a Numba-only default target (cpu) classmethod on the array
type.
c                     [        X5      $ rX  )intrin_alloc)clsr  r   s      rD   r    _ol_array_allocate.<locals>.impl,  s    I--rF   ru   )r>  r  r   r   s       rD   _ol_array_allocater@  '  s    
.KrF   c                 $    U R                  X5      $ )z9Trampoline to call the intrinsic used for allocation
    )r:  )r  r   r   s      rD   r,  r,  1  s     T))rF   c                 n    S n[         R                  " [         R                  5      n[        XAU5      nXS4$ )z3Intrinsic to call into the allocator for Array
    c                 F    Uu  pEU R                   R                  XU5      nU$ rX  )r  meminfo_alloc_aligned)r   r>   r$   r  r  r   r   s          rD   r  intrin_alloc.<locals>.codegen;  s%    !++33GNrF   )r   r)  r*  r$   )r  r  r   r  r5  r]   s         rD   r=  r=  7  s1    
 

u}}
-C
CE
*C<rF   c           	         S n[        U[        R                  5      (       a%  SnU R                  XU[        R                  5      /nOB[        U[        R
                  5      (       d   eUR                  n[        R                  " XUS9n/ nU H&  nUR                  U" XUR                  U5      5        M(     U R                  U[        R                  S5      n	[        U5       HX  n
UR                  SXz   U	5      n[        R                  " X5         U R                  R!                  U["        S5        SSS5        MZ     U$ ! , (       d  f       Mm  = f)z3
Parse the shape argument to an array constructor.
c                    U R                  [        R                  5      nUR                  n[        R
                  " U5      n[        USUS-
  -  S-
  5      nUR                  U:  a  UR                  X65      nU$ UR                  U:  aq  UR                  SX75      n	UR                  U	SS9   U R                  R                  U[        S5        SSS5        UR                  U:  a  UR                  X65      nU$ UnW$ ! , (       d  f       N5= f)z0Cast src to intp only if value can be maintainedrH   >Frr  )z#Cannot safely convert value to intpN)r   r   r   rI   r   r  r   sextr&  r(  rt  ru  r   trunc)
r   r>   src_tr~  r   
intp_widthintp_irmaxvalr  	is_largers
             rD   safecast_intp#_parse_shape.<locals>.safecast_intpI  s    ''

3\\
**Z('Q*q.%8A$=?;;#,,s,C 
 [[J&++C=I59!!11Z< :
 {{Z'mmC1 
 
 :9s   ,"C==
DrH   r  r   r%  )znegative dimensions not allowedN)r   r   r   r   r   re  r   r
   r   rl   r:   get_constant_genericr9   r&  r  rt  ru  r   )r   r>   r[  r   rP  rs   passed_shapesr  r   r  r  is_negs               rD   _parse_shaperU  E  s   * "emm$$ gB

CD"eoo....xx,,WFFmGaffa@A  ''Q?DT{$$S&+t<  1--%I 21  M 21s   "E
E	c                 ^    UR                   S   nUS   nUR                  nU[        XXE5      4$ )zD
Parse the arguments of a np.empty(), np.zeros() or np.ones() call.
r   )r  r  rU  )r   r>   r]   r  arrshapetypearrshaper  s          rD   _parse_empty_argsrY  u  s5     88A;LAwHooGL<JJJrF   c                    UR                   S   n[        U[        R                  5      (       aJ  [	        U5      " XUS   S9n[
        R                  " XR                  UR                  S9nUR                  U4$ UR                  S4$ )zS
Parse the arguments of a np.empty_like(), np.zeros_like() or
np.ones_like() call.
r   r#  r  ru   )
r  r   r   r   r   r
   r   rh   rs   r  )r   r>   r]   r  arytyper  r  s          rD   r  r    so    
 hhqkG'5;;''!'$q'B%%gyyM&&""rF   c                 z    [        U[        R                  5      (       a  SU  S3n[        R                  " U5      eg )NzIf np.z0 dtype is a string it must be a string constant.)r   r   UnicodeTyper	   r   )fnamer   r   s      rD   _check_const_str_dtyper_    s:    %**++ugMN  %% ,rF   c                 8    UR                   nU" XU5      nS nXV4$ )Nc                 V    [        XX#5      u  pE[        XXE5      nUR                  5       $ rX  )rY  r?  r  rk  r>   r]   rl  r  r  r  s          rD   r  numpy_empty_nd.<locals>.codegen  s(    +ECHUW=}}rF   instance_type)ro  ty_shapety_dtypety_retty_refty_rettyr]   r  s          rD   numpy_empty_ndrj    s(    ))H
8|
4C <rF   c                   ^ [        SU5        U[        L dB  [        U[        R                  5      (       a  UR
                  [        L d  [        U5      (       a  [        R                  nO[        U5      n[        U 5      nUb'  Ub$  [        R                  " X#SS9m[        4U4S jjnU$ SU  SU S3n[        R                  " U5      e)NrW  r   r:  c                    > [        XT5      $ rX  )rj  )rh   r   r  s     rD   r   ol_np_empty.<locals>.impl  s    !%66rF   z.Cannot parse input types to function np.empty(r  r  )r_  floatr   r   Function
typing_keyr   doublety_parse_dtypety_parse_shaper   r	   r   )rh   r   nb_dtypers   r   r   r  s         @rD   ol_np_emptyru    s    7E*	E5>>	*	*u/?/?5/H<<!%(% D 0(cB# 	7>ugRwaP  %%rF   c                 8    UR                   nU" XU5      nS nXV4$ )Nc                 V    [        XX#5      u  pE[        XXE5      nUR                  5       $ rX  )r  r?  r  rb  s          rD   r  $numpy_empty_like_nd.<locals>.codegen  s(    0MUW=}}rF   rd  )ro  ty_prototyperg  rh  ri  r]   r  s          rD   numpy_empty_like_ndrz    s(    ))H
<<
8C <rF   c                   ^ [        SU5        [        U5      (       d  [        U5      nO.[        U [        R
                  5      (       a  U R                  nOU nUbg  [        U [        R
                  5      (       a/  U R                  S:w  a  U R                  OSnU R                  X#SS9mO8[        R
                  " USS5      mOSU  SU S	3n[        R                  " U5      eSU4S
 jjnU$ )Nr  r  r   F)r   rA  r  r   z3Cannot parse input types to function np.empty_like(r  r  c                    > [        XT5      $ rX  )rz  )rO  r   r  s     rD   r   ol_np_empty_like.<locals>.impl  s    "3u55rF   rX  )r_  r   rr  r   r   r   r   rA  r  r	   r   )rO  r   rt  rA  r   r   r  s         @rD   ol_np_empty_liker~    s    </u!%(	C	%	%99c5;;''#&::#4SZZ#FHH8UHKEKK!S1E  #uBugQ0  %%6KrF   c                 :    [         R                  " U5      nS nX#4$ )Nc                     [        UR                  S   5      " XUS   5      n[        R                  " XR                  UR                  UR                  UR                  5      S5        g r   )r   r  r
   r  r   r   r   r   )rk  r>   r]   rl  r  s        rD   r  (_zero_fill_array_method.<locals>.codegen  sI    !%efQi@w'++cllCJJ*O	rF   )r   r  )ro  r[   r]   r  s       rD   _zero_fill_array_methodr    s    
**T
C <rF   
_zero_fillc                     S nU$ )z?Adds a `._zero_fill` method to zero fill an array using memset.c                     [        U 5        g rX  )r  r  s    rD   r    ol_array_zero_fill.<locals>.impl  s
    %rF   ru   )r[   r   s     rD   ol_array_zero_fillr    s    &KrF   c                 2    [        SU5        [        4S jnU$ )Nr  c                 N    [         R                  " XS9nUR                  5         U$ NrU  )r  rW  r  )rh   r   rO  s      rD   r   ol_np_zeros.<locals>.impl  s    hhu*
rF   )r_  rn  rh   r   r   s      rD   ol_np_zerosr    s    7E*  KrF   c                 (    [        SU5        SS jnU$ )N
zeros_likec                 N    [         R                  " XS9nUR                  5         U$ r  )r  r  r  )rK  r   rO  s      rD   r   ol_np_zeros_like.<locals>.impl  s    mmA+
rF   rX  r_  r~  s      rD   ol_np_zeros_liker    s    </ KrF   c                 (    [        SU5        SS jnU$ )N	ones_likec                     [         R                  " XS9nUR                  n[        [	        U5      5       H  nSX4'   M	     U$ NrU  rH   r  r  r3  r9   r   )rK  r   rO  arr_flatr   s        rD   r   ol_np_ones_like.<locals>.impl	  s8    mmA+88X'CHM (
rF   rX  r  r~  s      rD   ol_np_ones_liker    s    ;. KrF   c                 l   ^ [        SU5        [        U5      (       d  [        U5      mOUmSU4S jjnU$ )Nfullc                    > [         R                  " U T5      nUR                  n[        [	        U5      5       H  nXU'   M	     U$ rX  r  rW  r3  r9   r   )rh   
fill_valuer   rO  r  r   rt  s         rD   r  impl_np_full.<locals>.full  s;    hhuh'88X'C&SM (
rF   rX  )r_  r   rr  )rh   r  r   r  rt  s       @rD   impl_np_fullr    s3    65)u!%( KrF   c                 (    [        SU5        SS jnU$ )Nr  c                     [         R                  " X5      nUR                  n[        [	        U5      5       H  nXU'   M	     U$ rX  r  )rK  r  r   rO  r  r   s         rD   r  $impl_np_full_like.<locals>.full_like'  s8    mmA%88X'C&SM (
rF   rX  r  )rK  r  r   r  s       rD   impl_np_full_liker  #  s    ;. rF   c                 (    [        SU5        SS jnU$ )Nonesc                     [         R                  " XS9nUR                  n[        [	        U5      5       H  nSX4'   M	     U$ r  r  )rh   r   rO  r  r   s        rD   r   ol_np_ones.<locals>.impl7  s8    hhu*88X'CHM (
rF   rX  r  r  s      rD   
ol_np_onesr  1  s     65) KrF   c                    ^ [        SU5        [        U5      (       d  [        U5      mO[        R                  mSU4S jjnU$ )Nidentityc                 h   > [         R                  " X 4T5      n[        U 5       H	  nSX#U4'   M     U$ r  )r  r  r9   )r[  r   rO  rp   rt  s       rD   r  "impl_np_identity.<locals>.identityH  s3    hhvx(qAC1I 
rF   rX  )r_  r   rr  r   rq  )r[  r   r  rt  s      @rD   impl_np_identityr  @  s7    :u-u!%(<<
 OrF   c                     g rX  ru   NMs     rD   _eye_none_handlerr  P  rs  rF   c                 T    [        U[        R                  5      (       a  S nU$ S nU$ )Nc                     U $ rX  ru   r  s     rD   r   $_eye_none_handler_impl.<locals>.implW      HrF   c                     U$ rX  ru   r  s     rD   r   r  Z  r  rF   )r   r   rS  )r  r  r   s      rD   _eye_none_handler_implr  T  s)    !U^^$$	
 K	KrF   c                 X  ^ Ub  [        U[        R                  5      (       a  [        R                  " [
        5      mO\[        U[        R                  [        R                  45      (       a  [        [        USU5      5      mO[        R                  " U5      mS S[
        4U4S jjnU$ )Nr   r   c                    > [        X5      n[        R                  " X4T5      nUS:  a*  [        XU-
  5      n[	        U5       H  nSXWXr-   4'   M     U$ [        X-   U5      n[	        U5       H  nSXWU-
  U4'   M     U$ r  )r  r  r  r  r9   )	r  r  r   r   _MrO  drp   r  s	           rD   r   numpy_eye.<locals>.implj  s    q$hhw#6AAvA1X !quH  
 AE2A1X !E1H 
rF   )
r   r   rS  r  r   rn  	DTypeSpecr  r   r  )r  r  r   r   r   r  s        @rD   	numpy_eyer  _  st     }
5%..99XXe_	EEOOU\\:	;	;geWe45XXe_!5  KrF   c                     [        U 5      (       d  [        R                  " S5      e[        U [        R
                  5      (       a-  U R                  S;  a  [        R                  " S5      eSS jnU$ g )N#The argument "v" must be array-like)rH   rx  zInput must be 1- or 2-d.c                 b   U R                   S:X  a  U R                  nUS   [        U5      -   n[        R                  " X34U R
                  5      nUS:  a   [        X1-
  5       H  nX   XEX-   4'   M     U$ [        X1-   5       H  nX   XEU-
  U4'   M     U$ U R                  u  pgUS:  a  Xa-   nUS:  a  Xq-
  n[        [        Xg5      S5      n[        R                  " X0R
                  5      nUS:  a  [        U5       H  nXX-   4   XE'   M     U$ [        U5       H  nXU-
  U4   XE'   M     U$ r  )
rs   rh   r7  r  r  r   r9   r  r  rW  )r   r   r   r[  r  rp   rowscolss           rD   	diag_implimpl_np_diag.<locals>.diag_impl  s,   vv{GGaD3q6Mhhvqww/6"15\()quH *
 
 #15\()E1H *
WW
q58Dq58DD+hhq''*6"1X!"ae8 &
 
 #1X!"q5!8 &
rF   r   )r   r	   r   r   r   r   rs   NumbaTypeError)r   r   r  s      rD   impl_np_diagr  y  s`    A  !FGG!U[[!!66''(BCC	6 ? "rF   c                 (  ^^ [        U [        R                  5      (       d  Sn[        R                  " U5      e[        U R
                  [        R                  5      (       d  Sn[        R                  " U5      e[        U 5      mST-  mUU4S jnU$ )Nz5The argument "dimensions" must be a tuple of integersr  c                    > [         R                  " T4U -   [         R                  S9nSnU  HH  n[         R                  " U[         R                  S9R	                  [        TX#5      5      nXAU'   US-  nMJ     U$ )NrU  r   rH   )r  rW  r  aranger  r0   )
dimensionsr  rp   r  r   r  rh   s        rD   r   numpy_indices.<locals>.impl  so    hhtj(9C))Crxx088eQ,C FFA  
rF   )r   r   r  r	   r   r   r   r   )r  r   r   r  rh   s      @@rD   numpy_indicesr    su    j%..11E  %%j&&66E  %%JA1HE
 KrF   c                     [        U 5      (       d  Sn[        R                  " U5      e[        U[        [
        R                  45      (       d  Sn[        R                  " U5      eSS jnU$ )Nr  z#The argument "k" must be an integerc                 f   [         R                  " U 5      n U R                  5       n [        U 5      n[	        U5      nX#-   n[         R
                  " XD4U R                  5      n[         R                  " SU* 5      n[         R                  " SU5      n[        U5       H  nX   XVU-   Xx-   4'   M     U$ r   )	r  r  r  r   r7  r  r   maximumr9   )	r   r   r   abs_kr[  r  rp   jts	            rD   r   numpy_diagflat.<locals>.impl  s    JJqMGGIFAIhhvqww'JJq1"JJq!qA !CAqu  
rF   r   )r   r	   r   r   r   r   r   )r   r   r   r   s       rD   numpy_diagflatr    s[    A3  %%a#u}}-..3  %% KrF   c                 ~   US;   d   eUS:X  a6  Sn[        SU 5       H#  nSU-  nUSU SSR                  U5       S	3-  nM%     O5S
n[        SU 5       H#  nSU-  nUSU SSR                  U5       S3-  nM%     [        R                  " U5      n[	        U[        5       5        [        5       SU 3   n[        U5      $ )N)r  r  r  zv
            def _getitem(a, idx, axis):
                if axis == 0:
                    return a[idx, ...]
        rH   ):z
                elif axis == z:
                    return a[r  z, idx, ...]
            z|
            def _setitem(a, idx, axis, vals):
                if axis == 0:
                    a[idx, ...] = vals
        z:
                    a[z, idx, ...] = vals
            rG  )r9   r  textwrapdedentexecglobalsr&   )rs   r  r  rp   lsts        rD   "generate_getitem_setitem_with_axisr    s    ))))y
 q$A1*C S !"iin- . B   q$A1*C S !yy~& ' B   
	BWY	Qtf:	BBrF   takec                   ^^^^^	 [         R                  " U5      (       a  [        U [        R                  5      (       a&  [        U[        R
                  5      (       a  SS jnU$ [        U [        R                  5      (       a8  [        U[        R                  5      (       a  UR                  S:H  mSU4S jjnU$ [        U [        R                  5      (       a7  [        U[        R                  [        R                  45      (       a  SS jnU$ g g [        U [        R                  5      (       aJ  [        U[        R
                  5      (       a+  SU R                  S-
  -  m	[        U	4S j5       mSU4S jjnU$ [        U [        R                  5      (       an  [        U[        R                  [        R                  [        R                  45      (       a/  U R                  n[        US	5      m[        US
5      mSUU4S jjnU$ g g )Nc                     XR                   S-
  :  d  XR                   * :  a  [        S5      eU R                  5       U   $ )NrH   Index out of bounds)r   
IndexErrorr  )rK  r   r   s      rD   	take_implnumpy_take.<locals>.take_impl   s8    ffqj)Ww->$%:;;wwy))rF   r$  c                   > [         R                  " UR                  U R                  S9nT	(       a  UR	                  5       nOUn[         R
                  " U5      nSnU R                  5       nU H;  nXR                  S-
  :  d  XR                  * :  a  [        S5      eXx   X6'   US-   nM=     UR                  UR                  5      $ )NrU  r   rH   r  )
r  rW  r   r   r  rO  r  r  r  rh   )
rK  r   r   r  walkeritrp   r3  r  F_orders
            rD   r  r  	  s    hhw||177;$\\^F$FYYv&wwyAFFQJ'1w;()>??!WCFAA	 
 {{7==11rF   c                 Z    [         R                  " U5      n[         R                  " X5      $ rX  )r  r   r  )rK  r   r   converts       rD   r  r    s    ((7+wwq**rF   r   rH   c                 R  > [        T5      nSnU[        U R                  5      :  a  U R                  U   S:X  d   U R                  5       e[        [        U R                  5      5       H*  nU R                  U   nXA:w  d  M  [	        X#U5      nUS-  nM,     U R                  U5      $ r  )r   r   rh   r9   r0   r  )r  r   rb  r  r   r   r  s         rD   _squeezenumpy_take.<locals>._squeeze'  s    Ahc!''l*qwwt}/AJ177JA QWW.CA{+CA6Q	 /
 yy~%rF   c                    > [         R                  " X4US9nU R                  S:X  a  US   $ US:  a  X R                  -  nT" X25      $ )Nr  rH   r   )r  r  rs   )rK  r   r   r  r  s       rD   r  r  3  sH    GGAz566Q; Q4K!8FFND((rF   r  r  c                 t  > UnUS:  a  X R                   -  nUS:  d  X R                   :  a  SU SU R                    3n[        U5      e[        U R                  U[	        U5      5      n[
        R                  " XPR                  S9n[        [	        U5      5       H  nT	" XU   U5      nT
" XgX(5        M     U$ )Nr   zaxis z) is out of bounds for array of dimension rU  )	rs   r   r0   rh   r   r  rW  r   r9   )rK  r   r   r   r   rh   r  rp   r  _getitem_setitems            rD   r  r  J  s    !8FFND!8tvv~"2$ '++,66(4C$S/)%aggtS\BhhuGG4s7|,A AJ5AST- - 
rF   rX  )r
   r   r   r   r   r   rA  r`  re  rs   r&   r  )
rK  r   r   r  rs   r  r  r  r  r  s
        @@@@@rD   
numpy_taker    s    4  a%%*Wemm*L*L* a%%*Wekk*J*Jnn+G2 a%%7UZZ$ABB+ 	 C & a%%*Wemm*L*L
#A
 	& 	&) a%%7U[[%**eoo$NOO66D9$	JH9$	JH   / P &rF   c                     U  Vs/ s H&  n[        U[        R                  5      (       a  M$  UPM(     nn[        S U 5       5      (       a  [        R                  nU$ [        S U 5       5      (       a  [        R
                  nU$ [        [        SS[        R                  " [        5      R                  -  -  5      nU Vs/ s H  n[        R                  " U5      PM     nn[        Xd/-   5      nU$ s  snf s  snf )Nc              3   V   #    U  H  n[        U[        R                  5      v   M!     g 7frX  ri  rZ  rK  s     rD   r\   _arange_dtype.<locals>.<genexpr>`  s     
8A:a''r^  c              3   V   #    U  H  n[        U[        R                  5      v   M!     g 7frX  )r   r   Floatr  s     rD   r\  r  b  s     8AZ5;;''r^  zint%sr  )r   r   rS  r_  
complex128r   r  r  r   r   r   	unliteralr  )r  rK  boundsr   NPY_TYr  unliteral_boundss          rD   _arange_dtyper  ]  s    CAZ5>>%BaFC

8
888  & L% 
88	8	8" L 1rxx}/E/E+E FG 9??1EOOA.?$y01L- D& @s   #C4C4 C9c          	      *  ^^^^	^
 [        U[        R                  5      (       a  UR                  n[        U[        R                  5      (       a  UR                  n[        U[        R                  5      (       a  UR                  nUc  [        R                  nUc  [        R                  nUc  [        R                  n[        U [        R
                  5      (       a  [        U[        R                  [        R
                  45      (       a^  [        U[        R                  [        R
                  45      (       a/  [        U[        R                  [        R                  45      (       d  g [        U[        R                  5      (       a  [        XU5      m	OUR                  m	[        XU4 Vs/ s H  n[        U[        R                  5      PM     sn5      m
[        U SS 5      m[        USS 5      m[        USS 5      mSUUUU	U
4S jjnU$ s  snf )Nr   c                  > Tb  TOU nTb  TOUnTb  TOUnUb  UOSnUc  SUpOXEpUS:X  a  [        S5      eX-
  U-  n
[        [        R                  " U
R                  5      5      nTSL a?  [        [        R                  " U
R
                  5      5      n[        [        X5      S5      nO[        US5      n[        R                  " UT5      nUn[        U5       H  nUUU-  -   UU'   M     U$ )NrH   r   zMaximum allowed size exceededT)r   r   mathceilrp  rr  r  r  r  rW  r9   )r<  r  r   r   	lit_startlit_stoplit_step_step_start_stopnitems_cnitems_rnitems_ir   rO  r   rp   start_value
step_value
stop_value
true_dtypeuse_complexs                    rD   r   np_arange.<locals>.impl  s    #.#:K	!+!7:T!+!7:T$0ayE%EA:<==Ne+tyy/0 $499X]]34HX0!4F1%Fhhvz*vAAI&CF 
rF   r!  )r   r   Optionalr:   r  r  rS  r  r  r   r_  rj  r  )r<  r  r   r   r  r   r  r  r  r  r  s         @@@@@rD   	np_aranger  w  s{   $''yy$''yy%((

|zz|zz}

uell++tennell;<<tennell;<<55>>5??"CDD%(("55
[[
!&d 35 31 "!U]]3 35 6K %$7K5J5J < KK5s   0$Hc                 6  ^ [        S X4 5       5      (       d  g [        U[        [        R                  45      (       d  Sn[
        R                  " U5      e[        S X4 5       5      (       a  [        R                  mO[        R                  mSU4S jjnU$ )Nc              3   V   #    U  H  n[        U[        R                  5      v   M!     g 7frX  )r   r   r  rk  s     rD   r\  !numpy_linspace.<locals>.<genexpr>  s     Fz#u||,,r^  rg  c              3   V   #    U  H  n[        U[        R                  5      v   M!     g 7frX  ri  rk  s     rD   r\  r    rm  r^  c                    > [         R                  " UT5      nU S-  n US-  nUS:X  a  U$ US-
  nUS:  a7  X-
  n[         R                  " XT5      n[        SU5       H  nXU-  -   X7'   M     OXS'   US:  a  XS'   U$ )Ng      ?r   rH   r\  )r  rW  divider9   )	r<  r  ra  rO  divdeltar   rp   r   s	           rD   r_   numpy_linspace.<locals>.linspace  s    hhsE" cz!8JAg7LE99U(D1c]d(+ # F7G
rF   rc  )
r  r   r   r   r   r	   r   r_  r  r   )r<  r  ra  r   r_  r   s        @rD   numpy_linspacer!    sx    FFFFcC/005  %%

Ce]
CCC  , OrF   c           
         UR                   S   n[        U5      " XUS   S9n[        R                  " XR                  5      nUR
                  n[        XXv5      nUR                  n	UR                  n
UR                  S;   d   eUR                  UR                  :X  a,  [        R                  " XXR                  UR                  SS9  O[        R                  " XR                  5      n[        R                  " XR                  5      nU R                  [        R                  5      n[        R                   " XU5       n[        R"                  " XU	XkUR                  U5      n[        R"                  " XU
XlUR                  U5      nUR%                  UR'                  U5      U5        SSS5        [)        XUR
                  UR+                  5       5      $ ! , (       d  f       N3= f)z
Array copy.
r   r#  rM  rH   r   N)r  r   r
   r   rh   r  r?  r   rA  
raw_memcpyr   r   r   r   r   r   r}  r@  r,  r?   r!   r  )r   r>   r]   r  r[  r  r  rettyper  ro  r  rq  r  r   r   rg  r  s                    rD   _array_copyr%    sx    hhqkG
W
gd1g
>C!!'995FooG
7
;CxxHI>>T!!!~~'7x<<q	2 **7KK@++G[[A''

3w77//(0607IG 0091718JH MM',,w/: 8 Gcoos}}OO 87s   A*G
G&c                     [        U[        R                  5      (       d   eUR                  S:X  a  SOSnUR	                  USS9nU" U5      nU[
        4$ )Nr$  r   F)rA  r  )r   r   r   rA  r  r%  )r  rK  rA  r  r]   s        rD   _array_copy_intrinsicr'    sP    a%%%%HHOSF
&&&
/C
a&CrF   z
array.copyc                     [        XX#5      $ rX  )r%  r4  s       rD   
array_copyr)    s    w33rF   c                     [        U 5      (       d  [        R                  " S5      e[        U [        R
                  5      (       a  S nU$ S nU$ )Nr  c                     [        U 5      $ rX  )r'  r  s    rD   
numpy_copy#impl_numpy_copy.<locals>.numpy_copy  s    (++rF   c                 .    [         R                  " U 5      $ rX  )r  r  r  s    rD   r,  r-     s    ::a= rF   )r   r	   r   r   r   r   )rK  r,  s     rD   impl_numpy_copyr/    sR    A   "1 2 	2 !U[[!!	, 	! rF   c           	      X   UR                   nUR                  S   nUR                  U:X  d   S5       eUR                  S:X  a  UR                  S:X  d   e[	        U5      " XUS   S9n[	        U5      " X5      nU R                  U[        R                  " [        R                  S5      S5      n	U R                  U[        R                  " [        R                  S5      UR                  45      n
[        XR                  XUR                  UR                  UR                  5        [        XXXR!                  5       5      $ UR                  UR                  :X  d   UR                  S:X  a  UR                  S;   a  [        XXSS   5      $ UR                  S:X  a  US;   d   eUS:X  a  ["        O[$        n['        UU UUUS   5      nUR)                  U5       u  pU   [        XUUS   5      nUR*                  nS	S	S	5        U   [-        XX#5      nUR*                  nS	S	S	5        S	S	S	5        UR/                  WR0                  5      nUR3                  UW5        UR3                  WW5        U$ [-        XX#5      $ ! , (       d  f       N= f! , (       d  f       Nt= f! , (       d  f       N}= f)
zX
Common logic for layout conversion function;
e.g. ascontiguousarray and asfortranarray
r   z return-type has incorrect layoutrH   r#  r  rM  r  r   N)r  r  rA  rs   r   rR  r   r  r   r
  r   r   r   r   r   r    r  r   r   r  re  blockr%  phir:   add_incoming)r   r>   r]   r  output_layoutr  r   r  r  rh   r   
check_funcr  thenorelseout_thenthen_blk
out_orelse
orelse_blkret_phis                       rD   _as_layout_arrayr=  &  s:   
 OOEHHQKE<<=(L*LL(zzQzzQQ@1,,U^^EJJ2D
 $$W%*^^EJJ%B&)ll_6 	sHHecll{{CJJ	0 5--/JJ
,,%,,
&

aELLD$8 5q'BB <<3 !D(((*73*>JJ.z/6/6/4/3Aw	8I
 +~0515a :H&}}H 
 !,Ws!IJ!(J  , kk(--0G  84  Z8N w;;! T
 V ,+s<   JI99
JJ
J9
J	J

J	J
J)c                    ^ [        T[        R                  5      (       d  [        R                  " T5      eUR                  TR                  [        UR                  S5      SS9nU" UT5      nUU4S j4$ )NrH   F)rA  rs   r  c                 .   > [        XX#TR                  S9$ )N)r4  )r=  r   )r  r  r   rK  r4  s       rD   r  ,_as_layout_array_intrinsic.<locals>.<lambda>s  s    #3	a-"="=$?rF   )	r   r   r%   r	   RequireLiteralValuer  r   r  rs   )r  rK  r4  r  r]   s     `  rD   _as_layout_array_intrinsicrB  g  su    mU%8%899((77 &&**^  C a
C ? ? ?rF   c                     [        U 5      (       d  [        R                  " S5      e[        U [        R
                  [        R                  45      (       a  S nU$ [        U [        R                  5      (       a  S nW$ )Nr  c                 V    [         R                  " [         R                  " U 5      5      $ rX  )r  ascontiguousarrayr   r  s    rD   r   %array_ascontiguousarray.<locals>.impl}  s    ''44rF   c                     [        U S5      $ Nr   rB  r  s    rD   r   rF        -a55rF   r   r	   r   r   r   r  r  r   rA  s     rD   array_ascontiguousarrayrL  w  sb    A  !FGG!ellEMM344	5
 K 
Au{{	#	#	6KrF   c                     [        U 5      (       d  [        R                  " S5      e[        U [        R
                  [        R                  45      (       a  S nU$ [        U [        R                  5      (       a  S nU$ g )Nr  c                 V    [         R                  " [         R                  " U 5      5      $ rX  )r  asfortranarrayr   r  s    rD   r   "array_asfortranarray.<locals>.impl  s    $$RXXa[11rF   c                     [        U S5      $ )Nr$  rI  r  s    rD   r   rP    rJ  rF   rK  rA  s     rD   array_asfortranarrayrR    sc    A  !FGG!ellEMM344	2	Au{{	#	#	6 
$rF   zarray.astypec           
      d   UR                   S   n[        U5      " XUS   S9n[        R                  " XR                  5      nUR
                  n[        XXv5      nUR                  n	UR                  n
[        R                  " XR                  5      n[        R                  " XR                  5      nU R                  [        R                  5      n[        R                  " XU5       n[        R                  " XU	XkUR                  U5      n[        R                  " XU
XlUR                  U5      n[        XXO5      nU R!                  UUUR"                  UR"                  5      n[%        XUUU5        S S S 5        ['        XUR
                  UR)                  5       5      $ ! , (       d  f       N3= fr	  )r  r   r
   r   rh   r  r?  r   r   r   r   r   r}  r@  rA  r   r   r   r   r!   r  )r   r>   r]   r  r[  r  r  r$  r  ro  r  rq  r  r   r   rg  r  items                     rD   array_astyperU    sT    hhqkG
W
gd1g
>C!!'995FooG
7
;CxxHI&&w<K''=L##EJJ/F			7F	3w++Gh,2,3NNGE ,,Wy-3-4^^WF 7<||GT7=='--H7WdH= 
4 Gcoos}}OO 
4	3s   )BF!!
F/c                 f    [        U[        R                  5      (       d   e[        U5      nS nX#4$ )Nc           
         UR                   u  n[        U5      nU" XUS   5      nUR                  nUR                  XvR                  5      n[        XU5      n	UR                  (       aW  UR                  S:X  aG  [        R                  " XR                  UR                  UR                  U5        U	R7                  5       $ [        R                  " XR                  5      n
[        R                  " XR                  5      nUR                  nU R                  [        R                   5      n[        R"                  " XSSS9n[        R$                  " XU5       n[        R&                  " XUR                  XX5      nUR)                  UU	R                  R*                  5      nUR-                  U5      nUR/                  U	R                  U/5      n[        R0                  " UUUU5        UR3                  UR5                  UU5      U5        S S S 5        U	R7                  5       $ ! , (       d  f       U	R7                  5       $ = f)Nr   r   byteptrT)namerQ   )r  r   r   r   r   r.   r  rA  r
   r#  r   r   rh   r   r   r   r   rY   r}  r@  rw  r:   r?   rB  r  r,  r  r  )r   r>   r]   r  r[  rN  rO  r   r  bstrrh   r   rA  r   byteidxr   rn   srcptrr   destptrs                       rD   r  )_array_tobytes_intrinsic.<locals>.codegen  s   xx2Gd1g.<<Xzz2#Gf=NNryyC/w		388SZZ'). ~~) (())<E**7KK@GYYF++EJJ7F))itG ""76:g//chh !diinn=ll7+!++dii#7wBgkk#x8'B ; ~~ ;: ~~s   B3H$$
I)r   r   r   r/   )r  r  r]   r  s       rD   _array_tobytes_intrinsicr_    s2    a%%%%
Q-C" F <rF   r  c                 L    [        U [        R                  5      (       a  S nU$ g )Nc                     [        U 5      $ rX  )r_  r  s    rD   r    impl_array_tobytes.<locals>.impl  s    +C00rF   rY  r  s     rD   impl_array_tobytesrc    s"    #u{{##	1 $rF   c                 :    UR                   nU" XX4U5      nS nXx4$ )Nc           
          UR                   S   nUS   nUS   nUR                  n[        U5      " XUS   S9n[        U5      n	U	" X5      n
U
R                  n[	        X5      n[        UR                  R                  U5      nUR                  UR                  UR                  5      nUR                  Xm5      nUR                  X5      nUR                  SU[        R
                  " UR                  S5      5      nSnUR                  USS9   U R                  R                  U[         U45        S S S 5        UR                  SU[        R
                  " UR                  S5      5      nUR#                  X5      n[$        R&                  " UU5      nUR                  USS9   S	nU R                  R                  U[         U45        S S S 5        UR)                  U5       u  nnU   UR*                  nUR-                  X5      nS S S 5        U   UR*                  nS S S 5        S S S 5        UR/                  UR                  5      nUR1                  WW5        UR1                  UW5        UR                  UU5      nUR3                  S
UU5      nUR                  USS9   SnU R                  R                  U[         U45        S S S 5        [$        R4                  " UU/5      n[$        R4                  " X/5      nUR7                  UR8                  U/5      nUR;                  UU R=                  UR?                  S5      5      5      n[A        U
UUUUURB                  URD                  S9  U
RG                  5       n [I        XUR                  U 5      $ ! , (       d  f       GNi= f! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GN/= f)Nr   rx  r  r#  r%  z=offset must be non-negative and no greater than buffer lengthFrr  z.buffer size must be a multiple of element sizerH  z%buffer is smaller than requested sizer   rM  )%r  r  r   r   r   r   r   r:   r   r   r*  r&  r   r(  rt  ru  r   sremr
   is_not_nullre  basic_blocksdivr2  r3  r)  rm   rB  r   rw  r   r   r   r   r   r  r    )!r   r>   r]   r  bufty	arg_count
arg_offsetr   r#  
out_ary_tyout_aryout_datamodelr   ll_itemsizer  ll_offset_sizenbytes_is_negativer   ll_count_is_negativeremis_incompatible
then_block
else_blockbb_if	num_wholebb_elsell_itemcountll_required_sizeis_too_largerh   r   r   r  s!                                    rD   r  np_frombuffer.<locals>.codegen  sZ   G	!W
Q@&
W.**/s||00(;SZZ6 Z=V4$00KK	*
 N__/_>--gzC6J ?  '22KK	* 
 ll6/!--gs;___U_;BC--gzC6J <
 __126Nz:++#LL=	  !-- 	 3 {{9>>2!!)U3!!)W5 #;;|[A,,S2BFK__\%_89C--gzC6J 9
 ""7\N;$$Wm<{{388j\2'(()?)?)GH
 	w "& +"{{!jj	* ! 3??CHHm ?> <;  	 32 98s`   #N$%N&"O(N8
OO
O!%O.
N#&
N58
O	O

O	O
O+.
O=rd  )	r  bufferr   r   r  r  r[  r]   r  s	            rD   np_frombufferr    s-    			B
VE5
1CNI` <rF   r\  c                 2  ^ [        SU5        [        U [        R                  5      (       a  U R                  S:w  a  SU  3n[
        R                  " U5      eU[        L dB  [        U[        R                  5      (       a  UR                  [        L d  [        U5      (       a  [        R                  nO[        U5      nUb'  [        R                  " USSU R                  (       + S9mOSU  SU S3n[
        R                  " U5      e[        S	S
4U4S jjnU$ )N
frombufferr   z+Argument "buffer" must be buffer-like. Got rH   )r   rs   rA  r  z3Cannot parse input types to function np.frombuffer(r  r  r\  r   c                    > [        XX#T5      $ rX  )r  )r  r   r   r  r  s       rD   r    impl_np_frombuffer.<locals>.implU  s    VE5AArF   )r_  r   r   r  rA  r	   r   rn  ro  rp  r   rq  rr  r   r  )r  r   r   r  r   rt  r   r  s          @rD   impl_np_frombufferr  >  s    </fell++v}}/C;F8D  %%u~~..53C3Cu3L<<!%((3)/%79  &xr%3  %% 1 B KrF   c                    ^ [        U5      (       a  [        SS 5      mSU4S jjnU$ [        U[        R                  5      (       a  [        SU5      mSU4S jjnU$ g )Nr   c                    > T" X5      $ rX  ru   rn   rh   r   intrinsic_cfarrays      rD   r   impl_carray.<locals>.impl`      $S00rF   c                    > T" X5      $ rX  ru   r  s      rD   r   r  f  r  rF   rX  r   get_cfarray_intrinsicr   r   r  rn   rh   r   r   r  s       @rD   impl_carrayr  [  R    51#t<	1	E5??	+	+1#u=	1 
,rF   c                    ^ [        U5      (       a  [        SS 5      mSU4S jjnU$ [        U[        R                  5      (       a  [        SU5      mSU4S jjnU$ g )Nr$  c                    > T" X5      $ rX  ru   r  s      rD   r   impl_farray.<locals>.implp  r  rF   c                    > T" X5      $ rX  ru   r  s      rD   r   r  v  r  rF   rX  r  r  s       @rD   impl_farrayr  k  r  rF   c                 *   ^ ^ [         UU 4S j5       nU$ )Nc                   > U[         R                  L a  S nOH[        U[         R                  5      (       a  UR                  nOSU S3n[
        R                  " U5      eT	c  Uc  Sn[
        R                  " U5      eUnOo[        T	[         R                  5      (       a4  T	R                  nUb$  XS:w  a  SU SU S3n[
        R                  " U5      eOST	 S3n[
        R                  " U5      e[        U5      nUc  SU S3n[
        R                  " U5      e[         R                  " XVT
5      n[        XqU5      nU[        4$ )Nz pointer argument expected, got ''z*explicit dtype required for void* argumentzmismatching dtype 'z' for pointer type 'zinvalid dtype spec 'zinvalid shape ')r   r*  r   CPointerr   r	   r  r  rs  r   r$   
np_cfarray)r  rn   rh   	ptr_dtyper   r   rs   r  r]   dtype_rA  s            rD   r  0get_cfarray_intrinsic.<locals>.intrinsic_cfarray|  s2   %--IU^^,,		I4SE;C'',,> B++C00E00LLE$);+E72Fse1M++C00(2C'',,e$<#E7!,C'',,E0E*JrF   r)   )rA  r  r  s   `` rD   r  r  {  s     > rF   c           
         UR                   SS u  pEUSS u  pgUR                  nUR                  S;   d   e[        U5      " X5      n	[	        X5      n
[
        R                  " U
5      n[        U[        R                  5      (       a  [
        R                  " X5      nOU4nU4n[        X\5       VVs/ s H&  u  pU R                  XU[        R                  5      PM(     nnnUn/ nUR                  S:X  a-  U H&  nUR                  U5        UR                  UU5      nM(     OE[!        U5       H&  nUR                  U5        UR                  UU5      nM(     UR#                  5         UR%                  UU R'                  UR(                  5      R+                  5       5      n[-        U	UUUUSS9  U	R/                  5       n[1        XUR                  U5      $ s  snnf )zF
numba.numpy_support.carray(...) and
numba.numpy_support.farray(...).
Nrx  rM  r$  r;  )r  r  rA  r   r   r
   r   r   r   re  r   r   r   r   rl   r   r;  r  rw  r   r   r=  r   r  r!   )r   r>   r]   r  rn  r.  rn   rh   r   rn  r   rp  r  r  r$  offr   r   r   r  s                       rD   r  r    s   
 XXbq\NEbqJCOOE<<41GG+H..*K'5??++%%g5*#&w#79#7-& ll765::>#7  9 CG||sANN3++c1%C  &!ANN3++c1%C " 	??3"00=HHJLD 7"' 


CGcoosCC99s   3-Gc                 B   [        U[        R                  5      (       a)  U R                  [        R                  [        U5      5      $ [        U[        R                  5      (       a7  U R                  [
        [        [        R                  U5      5      nU" X45      $  erX  )	r   r   re  r   r   r   r  rS   r$   )r   r>   seqtyseqr(  s        rD   _get_seq_sizer    sn    %))##EJJE
;;	E5>>	*	*''Yuzz5-JK((qrF   c                    ^ ^^ UR                   mT R                  [        R                  [	        TU[
        R                  5      5      mU UU4S jnU$ )zC
Return a getitem() implementation that doesn't incref its result.
c                 t   > T" X5      nTR                   (       a  TR                  R                  U TU5        U$ rX  )r
  r  decref)r>   r  r  r   r  r  s      rD   wrap$_get_borrowing_getitem.<locals>.wrap  s1    7)KKws3
rF   )r   rS   r  r  r$   r   r   )r   r  r  r  r  s   `  @@rD   _get_borrowing_getitemr    sC     KKE''(8(8(1%

(KML KrF   c           	        ^ ^^ T R                  [        R                  5      n[        US5      mUU U4S jn/ nX4p[	        U5       H/  n
U
S:  a
  U" X5      u  pUR                  [        T TX5      5        M1     [        U5      $ )z>
Compute the likely shape of a nested sequence (possibly 0d).
r   c                    > [        U [        R                  5      (       a'  [        U 5      S:X  a  gU S   TR	                  US5      4$ [        TU 5      nU R                  U" TUT45      4$ )Nr   NN)r   r   re  r   rl  r  r   )r  r  r  r>   r   r  s      rD   get_first_item.compute_sequence_shape.<locals>.get_first_item  sd    eU__--5zQ!Qx!6!6sA!>>>1'5AL;;WsDk BBBrF   )r   r   r   r   r9   rl   r  r   )r   r>   rs   r  r  r   r  r  innertyinnerrp   r  s   ``         @rD   compute_sequence_shaper    sy     ##EJJ/FFADC FU4[q5+G;NGmGWgEF 
 =rF   c                 >   ^ ^^^ UU 4S jmUUUU 4S jmT" X#U5        g)z7
Check the nested sequence matches the given *shapes*.
c                  H   > TR                   R                  T [        S5        g )N)zincompatible sequence shape)rt  ru  r   )r>   r   s   rD   _fail#check_sequence_shape.<locals>._fail  s    ))':*J	LrF   c                   > [        U5      S:X  a  g [        TTX5      nUS   nTR                  SX45      nTR                  USS9   T" 5         S S S 5        [        U5      S:X  a  g [	        U [
        R                  5      (       aY  [        TU 5      n[        R                  " TU5       nU R                  nU" TXR                  45      n	T" XUSS  5        S S S 5        g [	        U [
        R                  5      (       a=  [        [        U 5      5       H$  n
X
   nTR                  X5      n	T" XUSS  5        M&     g  U 5       e! , (       d  f       N= f! , (       d  f       g = f)Nr   rq  Frr  rH   )r   r  r&  r(  r   r   r  r  r
   r  r   r	  re  r9   rl  )r  r  r  r   expectedr  r  r  r  r  rp   r  r>   check_seq_sizer   s              rD   r  ,check_sequence_shape.<locals>.check_seq_size  s3   v;!Wgu:!9&&tT<__Xe_4G 5 v;!eU^^,,1'5AL""7D1T++$WsJJ.?@wvabz: 21
 u//3u:&(--c5wvabz: ' eO1) 54 21s   E(-E
E
E Nru   )r   r>   r  r  r  r  r  s   ``   @@rD   check_sequence_shaper    s    
L : 5v&rF   c                 P   ^ ^^^^^^^	 UUU UUU4S jm	UU	UU 4S jmT" XgTS5        g)z`
Assign a nested sequence contents to an array.  The shape must match
the sequence's structure.
c                    > [         R                  " TTTTT	TR                  U SS9nTR                  TX!TR                  5      n[        TTTX#5        g r}  )r
   r@  rA  r   r   r   )
r   rh  r   rn   rN  r>   r   r   r  r   s
       rD   assign_item-assign_sequence_to_array.<locals>.assign_item<  sM    ''$(-g%Qll7C<7GUC5rF   c                   > [        U5      S:X  a;  [        U [        R                  [        R                  45      (       a   eT" X0U5        g US   n[        U [        R                  5      (       ag  [        TU 5      n[        R                  " TU5       nU R                  nU" TXR                  45      nT" XxUSS  X6R                  4-   5        S S S 5        g [        U [        R                  5      (       aa  [        [        U 5      5       HH  n	X	   nTR                  X5      nTR                  [        R                  U	5      n
T" XxUSS  X:4-   5        MJ     g  U 5       e! , (       d  f       g = fr  )r   r   r   r  re  r  r
   r  r   r	  r9   rl  r   r   )r  r  r  r   r   r  r  r  r  rp   r	  assignr  r>   r   s              rD   r  (assign_sequence_to_array.<locals>.assignB  s1   v;!!%%..%//)JKKKK,ayeU^^,,1'5AL""7D1T++$WsJJ.?@wvabz7jj]3JK 21
 u//3u:&(--c5,,UZZ;wvabz7X3EF	 ' eO1 21s   ;E
E,ru   Nru   )
r   r>   r   r  r   rN  r  r  r  r  s
   ``````  @@rD   assign_sequence_to_arrayr  5  s%    6 6 2 5vr"rF   c                     [        X5      u  p4[        U5      (       a  UnO[        U5      nUc  g [        R                  " X#S5      $ rH  )r5   r   rr  r   r   )r  r  r   rs   	seq_dtypes        rD   np_array_typerr  ^  sA    ,Y?OD5u%=;;uC((rF   c                 N    [        SU5        [        XU5      nU" X5      nS nXE4$ )Nr   c           
      Z   UR                   nUR                  nUR                  S   nUS   n[        XXVU5      n[	        U5      U:X  d   e[        XXgU5        [        XXH5      n	[        XU	R                  UU	R                  XFU5        [        XUR                   U	R                  5       5      $ r   )r  rs   r  r  r   r  r?  r  r   r   r!   r  )
r   r>   r]   r  rN  rs   r  r  r  rO  s
             rD   r  np_array.<locals>.codegeno  s    zz1g'$sK6{d"""Wu6BWu= 388V!$eC	A  #// #1 	1rF   )r_  r  )r  objr   r  r]   r  s         rD   np_arrayr  i  s0    7E*

/C
c/C1" <rF   c                     [        SU5        [        U 5      (       d  [        R                  " S5      e[	        U5      (       d$  [        U5      c  Sn[        R                  " U5      eSS jnU$ )Nr   z(The argument "object" must be array-likez:The argument "dtype" must be a data-type if it is providedc                     [        X5      $ rX  )r  )r  r   s     rD   r   impl_np_array.<locals>.impl  s    &&rF   rX  )r_  r   r	   r   r   rr  )r  r   r   r   s       rD   impl_np_arrayr    sd    7E*F##   "1 2 	2u."7"?J  %%'KrF   c                    UR                  S5      nUR                  U5      nUR                  SXE5      nUR                  XqR                  XF5      U5      nUR	                  UR                  SXE5      UR                  SXF5      5      nUR                  USS9   SU-  n	U R                  R                  U[        U	45        S S S 5        U$ ! , (       d  f       U$ = f)Nr   r%  r  Frr  z%s(): axis out of bounds)	r:   r&  r  r  r(  r(  rt  ru  r  )
r   r>   r   rs   r   r  ll_ndimis_neg_axisaxis_out_of_boundsr   s
             rD   _normalize_axisr    s    99Q<DiioG %%c46K>>+{{4'A4HD !C,D$02 
+E	:(94))':vF 
; K	 
;	: Ks   (C


Cc           
      |   [        U5      US-
  :X  d   e[        R                  " [        R                  U5      n[        R
                  " X5      n[        R                  " S5      n[        US-
  5       Hy  n[        R                  " U5      n	UR                  SX5      n
X(   nUR                  U
UR                  X5      U	5      nUR                  U[        R                  " XSU5      5        M{     UR                  U[        R                  " XSU5      5        [        R                  " XR                  U5      5      $ )z
Compute shape with the new axis inserted
e.g. given original shape (2, 3, 4) and axis=2,
the returned new shape is (2, 3, 1, 4).
rH   r  r   r   r   r<  r
   r   rY   r9   r&  r  r  r,  rk   r   r?   )r   r>   
orig_shapers   r   ll_shtyr  rA  r  ll_dim
after_axisrI  r   s                rD   _insert_axis_in_shaper    s     z?dQh&&&ll7>>40G  2F
..
C TAX$((v<
_nnZ$[[5#% 	b'..w3GH  MM#w++GQEFf)=>>rF   c           
         [        U5      US-
  :X  d   e[        R                  " [        R                  U5      n[        R
                  " X5      n[        R                  " S5      n[        R                  " S5      n[        US-
  5       Hw  n	[        R                  " U	5      n
UR                  SX5      nUR                  UUR                  X5      U
5      nUR                  X)   [        R                  " XSU5      5        My     UR                  U[        R                  " XSU5      5        [        R                  " XR                  U5      5      $ )z<
Same as _insert_axis_in_shape(), but with a strides array.
rH   r   r  r  )r   r>   orig_stridesrs   r   r  r   rA  r  r  r  r  r   s                rD   _insert_axis_in_stridesr    s    |q(((ll7>>40G!!'3G
..
C>>!D TAX$((v<
nnZ$[[5#% 	l'**7QD	F  MM$,,Wq$GHg)>??rF   c           
         UR                   nUR                  nUR                  S   n[        U5      " XUS   S9n[        U5      " X5      n	[        R
                  " XR                  5      n
[        R
                  " XR                  5      n[        XXU5      n[        XXU5      n[        U	UR                  UUUR                  UR                  UR                  S9  U	R                  5       $ )z'
np.expand_dims() with the given axis.
r   r#  rM  )r  rs   r  r   r
   r   rh   r   r  r  r   r   r   r   r   r  )r   r>   r]   r  r   r  rs   rN  rO  r  r  r   
new_shapesnew_stridess                 rD   expand_dimsr    s     OOE::DHHQKE
U
GDG
<C
U
G
-C!!'995F""7KK8G&wtLJ)'G4PK3#&LL;;**& ==?rF   c                     UR                   S::  a  UR                  OSnUR                  UR                   S-   US9nU" X5      nS nXV4$ )NrH   r  r  c                     U R                  XS   UR                  S   [        R                  5      n[	        XSUR
                  R                  U5      n[        XX#U5      n[        XUR
                  U5      $ )NrH   znp.expand_dims)	r   r  r   r   r  r  rs   r  r    )r   r>   r]   r  r   r  s         rD   r  np_expand_dims.<locals>.codegen  se    ||G!Wchhqk5::Fw1A"33T; 'Ct< 3??CHHrF   )rs   rA  r  )r  rK  r   rA  r  r]   r  s          rD   np_expand_dimsr    sJ    1QXX#F
&&affqj&
0C
a,CI <rF   c                     [        U [        R                  5      (       d  SU  3n[        R                  " U5      e[        U[        R
                  5      (       d  SU 3n[        R                  " U5      eS nU$ )Nz)First argument "a" must be an array. Got z(Argument "axis" must be an integer. Got c                     [        X5      $ rX  )r  )rK  r   s     rD   r   !impl_np_expand_dims.<locals>.impl  s    a&&rF   )r   r   r   r	   r   r   )rK  r   r   r   s       rD   impl_np_expand_dimsr    sh    a%%9!=  %%dEMM**8?  %%'KrF   c                 4   ^ ^^ [         UU 4S j5       mU4S j$ )Nc           	      4  >^^ UmU Vs/ s H%  o"R                  [        UR                  T5      S9PM'     snmUUUU4S jn[        [	        T5      S:  a  [
        R                  " T5      OTS   [
        R                  R                  U5      5      U4$ s  snf )Nr  c                 D  > [        TT5      n[        R                  " XS   5      n[        UTT5       VVVs/ s H  u  pgnU" XXgU5      PM     n	nnn[	        U	5      S:  a  U R                  XR                  U	5      n
OU	S   n
[        XUR                  U
5      $ s  snnnf r  )_atleast_nd_transformr
   r   r   r   r
  r  r    )r   r>   r]   r  	transformarrsrO  rN  r  retsr  r  rU  minimumr  s              rD   r  *_atleast_nd.<locals>.impl.<locals>.codegen!  s    -gt<I''a9D .1vv-FH-F)E gEB-F  H 4y1}((//4H1g$WsLLHs   BrH   r   )	r  r  rs   r$   r   r   r  StarArgTuple
from_types)typingcontextr  r  r  r  r  rU  r  s       @@rD   r   _atleast_nd.<locals>.impl  s    CGH4C((CHHg 6(74H	M 	M FaV,VAY++66t<>?FG 	G Is   ,Bc                     > T" U 6 $ rX  ru   )r  r   s    rD   r  _atleast_nd.<locals>.<lambda>1  s	    trF   r  )r  rU  r   s   ``@rD   _atleast_ndr    s    G G( %$rF   c                 :   ^ ^ T [        T5      :X  d   eUU 4S jnU$ )zT
Return a callback successively inserting 1-sized dimensions at the
following axes.
c           	        > [        T
5       Ht  nUS-   nUR                  U:  d  M  [        R                  " T	U   5      nUR	                  UR                  S-   S9n[        X[        R                  " X5      U4U5      nUnMv     U$ )NrH   r  )r9   rs   r
   r   r  r  r   r$   )r   r>   rO  rN  r  rp   rs   r   newarrtyrU  min_ndims            rD   r  (_atleast_nd_transform.<locals>.transform;  s    xAq5DzzD ~~d1g. ::5::>::!'"("2"28"CcV"&( ! ! 
rF   )r   )r  rU  r  s   `` rD   r  r  4  s$    
 s4y    rF   c                  L    [        S U  5       5      (       a  [        SS/5      $ g )Nc              3   V   #    U  H  n[        U[        R                  5      v   M!     g 7frX  rY  rk  s     rD   r\   np_atleast_1d.<locals>.<genexpr>M       
84C:c5;;''4r^  rH   r   r  r  r  s    rD   np_atleast_1dr  K  s'    

84
8881qc"" 9rF   c                  N    [        S U  5       5      (       a  [        SSS/5      $ g )Nc              3   V   #    U  H  n[        U[        R                  5      v   M!     g 7frX  rY  rk  s     rD   r\   np_atleast_2d.<locals>.<genexpr>S  r  r^  rx  r   r  r  s    rD   np_atleast_2dr
  Q  s)    

84
8881q!f%% 9rF   c                  N    [        S U  5       5      (       a  [        S/ SQ5      $ g )Nc              3   V   #    U  H  n[        U[        R                  5      v   M!     g 7frX  rY  rk  s     rD   r\   np_atleast_3d.<locals>.<genexpr>Y  r  r^  r  )r   r   rx  r  r  s    rD   np_atleast_3dr  W  s%    

84
8881i(( 9rF   c	                 p   [        U5      [        U5      s=:X  a   [        U5      s=:X  a  [        U5      :X  d   e   e[        R                  " S5      n	[        XXx5      n
[        R                  " XR
                  5      n/ nU H  nU	n[        [        X5      5       H`  u  nu  nnUR                  SUR                  U5      U5      nUR                  UU5      nUR                  UUR                  UU5      U5      nMb     UR                  U5        M     U
R                  n[        X4UXl5       H  u  nnnnnUR                  n[        R                  " X[        R                  UR                   S9nU n[        R"                  " XUUUUR                   U5      n[%        XUU5      nU R'                  UUUR(                  UR(                  5      n[        R"                  " XUXUR                   U5      n[+        XUUU5        SSS5        [        R,                  " UUU5      nM     U
$ ! , (       d  f       N,= f)z*
Concatenate arrays along the given axis.
r   r&  )orderN)r   r
   r   r?  r   r   r   r   r&  r:   r   r  r  rl   r   r}  rA  r@  r   r   r   r   r  )r   r>   r   r  r  
arr_shapesarr_stridesr  
ret_shapesr  r  ret_stridescopy_offsetsarr_shr  r  r   r,  is_axisaddendret_datarN  rO  arr_starr_datar}  r   rg  r   r  s                                 rD   _do_concatenater  ]  s    v;#d)Js:J#k:JJJJJJ>>!D 5
=C&&w<K L#,S-E#FC$))$		#EG[[v.F^^G$+KK$?$*,F $G 	F#  xxH.1&
2=/M*sFFF88 %%gw~~,1LL:	 '//(0605gGG GeW=C,,wU[[%++FC0081;16wHH wX>  &&w&A+/M. J Ys   4BH''
H5	c                    UR                   n[        X#5       VVs/ s H  u  px[        U5      " XUS9PM     nnn[        XSXe5      nU V	s/ s H#  n	[        R
                  " XR                  5      PM%     n
n	U V	s/ s H#  n	[        R
                  " XR                  5      PM%     nn	U
S    Vs/ s H  n[        R                  " X5      PM     nn[        U5       GHE  nUR                  SUR                  U5      U5      nX   nUR                  U5      nU
SS   Vs/ s H  oU   PM	     nnUR                  U5       u  nnU   [        R                  " UR                   UU/-   5      nUR#                  UU5        S S S 5        U   [        R$                  nU H&  nUR'                  UUR                  SUU5      5      nM(     UR)                  UR+                  U5      SS9   U R,                  R/                  U[0        SU-  45        S S S 5        S S S 5        S S S 5        GMH     U Vs/ s H  oR                  U5      PM     nn[3        XUX#XXM5	      n[5        XUUR7                  5       5      $ s  snnf s  sn	f s  sn	f s  snf s  snf ! , (       d  f       GN= f! , (       d  f       N= f! , (       d  f       N= f! , (       d  f       GM  = fs  snf )	Nr#  np.concatenater   r&  rH   Frr  z<np.concatenate(): input sizes over dimension %d do not match)rs   r   r   r  r
   r   rh   r   r  r9   r&  r:   r?   re  r  r  r  r,  r  r[  r(  r  rt  ru  r   r  r!   r  )r   r>   r  r  r  r   rs   r*  rK  rO  r  r  rI  r  r  r  ret_shape_ptrret_shother_shapeson_axison_other_dimis_okr  s                          rD   _np_concatenater%    s   ::D f+-+ sOGA6+ 	 - 7-=tJD GKKds'&&w		:dJKIMN#7''=KN 'qM+)b ++G8)  + T{%%dDIIcNDA"m,*4QR.9.B3.9__W%)@'<%%KK F8+- b-0	  ((&B#LL)0)<)<T2v)NPE ' __W\\%%8_G%%5557:; => H  &% 0 .88Zr,,r"ZJ8
'D 
-C GeS]]_EEY- LN
+ :  HG  &%$ 9sx   I/*I5;*I:. I?J>J=8J	<
J=AJ,"&J	J,J=)K	
JJ=
J)%J,,
J:6J==
K	c                 
   UR                   n[        R                  " S5      n[        R                  " S5      n[        R                  " [        U5      5      n	[	        X#5       V
Vs/ s H  u  p[        U
5      " XUS9PM     nn
n[        XSXe5      n[        R                  " XS   R                  5      nUSS   H  n[        R                  n[	        [        R                  " XR                  5      U5       Hq  u  nnUR                  XR                  SUU5      5      nUR                  UR                  U5      SS9   U R                  R                  U[         S5        S S S 5        Ms     M     U Vs/ s H#  n[        R                  " XR"                  5      PM%     nn[$        R&                  " [        R                  U5      n[        R(                  " UU5      n[        R(                  " UU5      n[+        US-
  5       H  n[        R                  " U5      nUR                  S	UU5      nUU   nUR-                  UUR/                  UU5      U5      nUR1                  U[        R2                  " UUSU5      5        UR1                  U[        R2                  " UUSU5      5        M     UR1                  U[        R2                  " UUSU5      5        UR1                  U	[        R2                  " UUSU5      5        [        R                  " XR5                  U5      5      nU/[        U5      -  n[        R                  " XR5                  U5      5      n[+        [        U5      5       Vs/ s H  n[        R(                  " UU5      PM     nn[+        US-
  5       H  n[        R                  " U5      nUR                  S	UU5      nUR-                  UUR/                  UU5      U5      n[+        [        U5      5       H5  nUR1                  UU   U   [        R2                  " UUU   SU5      5        M7     M     [+        [        U5      5       H/  nUR1                  U[        R2                  " UUU   SU5      5        M1     U Vs/ s H(  n[        R                  " XR5                  U5      5      PM*     nn[7        XUX#UUUU5	      n[9        XUUR;                  5       5      $ s  snn
f ! , (       d  f       GM  = fs  snf s  snf s  snf )
Nr   rH   r#  np.stackr&  Frr  )z5np.stack(): all input arrays must have the same shaper  )rs   r
   r   r   r   r   r  r   rh   r  r[  r&  r(  r  rt  ru  r   r   r   r<  rY   r9   r  r  r,  rk   r?   r  r!   r  )r   r>   r  r  r  r   rs   r  rA  
ll_narraysr*  rK  r  rO  r$  rI  orig_shr  r  input_shapesr  r  r  r  r   rp   input_stridesrJ  r  s                                rD   	_np_stackr,    s_   ::D>>!D
..
CD	*J f+-+ sOGA6+ 	 - 7ZDD %%gAw}}=JABx  w33GYYG)+KBLL(;(;D"g(NOEe!4UC!!11ZNP DC+  KOO$3G((++>$LO
 ll7>>40G&&w8L$$Wg6J TAX$((vt<
_nnZ$[[5#% 	b'..waMNb'..w
AsKL  MM#w++G\1dKLMM*g2273=34379 :
 ''l1KLL >CI-L%%g||J/GHJ $CI.0. ((':.  0 TAX$((vt<
nnZ$[[5#% s4y!AMM,q/#.!..wa8H!/245 "  3t9dG00-:JA157 	8 
  -., ))'<<3CD,  . 'D m-C GeS]]_EE_- DC
 PB0*.s$   &S%>"S+4*S>,!T/T+
S;c                     Ub   [        U[        R                  5      (       d  g [        U SU5      u  p4US:X  a  Sn[        R
                  " U5      e[        U5      n[        R                  " X4U5      $ )Nr  r   z.zero-dimensional arrays cannot be concatenated)r   r   r   r6   r	   r  r7   r   )r  r  r   r   rs   r   rA  s          rD   np_concatenate_typerr.  %  sk    
4 ? ? 	 &i&6@KEqy>##C(()&1F;;uF++rF   c                 x    [        XU5      n[        U[        R                  5      (       d   eU" X5      nS nXE4$ )Nc           
          U R                  XS   UR                  S   [        R                  5      n[	        X[        UR                  S   5      [        R                  " XS   5      UR                  U5      $ r  )	r   r  r   r   r%  r   r
   r   r  r   r>   r]   r  r   s        rD   r  np_concatenate.<locals>.codegen=  s_    ||G!Wchhqk5::Fw#CHHQK0&33G!WE"#	% 	%rF   )r.  r   r   r   )r  r  r   r  r]   r  s         rD   np_concatenater3  7  s>    
y$
7Cc5;;''''
f
C% <rF   c                 P    [        U [        R                  5      (       a  SS jnU$ g )Nc                     [        X5      $ rX  )r3  r  r   s     rD   r   !impl_np_concatenate.<locals>.implK  s    !&//rF   r   r   r   re  r  r   r   s      rD   impl_np_concatenater:  H  s"    &%//**	0 +rF   c                     U H;  nUR                   S:  d  UR                   S:  d  M%  Sn[        R                  " U5      e   g)NrH   rx  z7np.column_stack() is only defined on 1-d and 2-d arrays)rs   r	   r  )r   r   r  rK  r   s        rD   _column_stack_dimsr<  P  s<    66A:!KC'',,  rF   c                     [        U SU[        S9u  p#[        U5      n[        R                  " X#U5      nU" U5      nS nXg4$ )Nznp.column_stack)dim_chooserc                 :   [        UR                  S   5      n[        R                  " XS   5      n/ n/ nU R	                  [
        R                  S5      n[        XE5       H  u  pU	R                  S:X  a$  UR                  U	5        UR                  U
5        M9  U	R                  S:X  d   eU	R                  SS9n[        R                  " X5      n[        XX4U5      nUR                  U5        UR                  U5        M     [        XXgUR                  U5      $ )Nr   rH   rx  r  )r   r  r
   r   r   r   r   r   rs   rl   r  r   r$   r  r%  r  )r   r>   r]   r  orig_arrtys	orig_arrsr  r  r   rN  rO  r2  
expand_signewarrs                 rD   r   np_column_stack.<locals>.codegenb  s    388A;'((q':	##EJJ2k5JEzzQe$C  zzQ&


*#--e;
$Wz64Pe$F# 6 w"6 	6rF   )r6   r<  r7   r   r   )r  rb  r   rs   rA  r  r]   r  s           rD   np_column_stackrE  Y  sM    %i&72DFKE *#.F
++e6
*C
c(C64 <rF   c                 L    [        U [        R                  5      (       a  S nU$ g )Nc                     [        U 5      $ rX  )rE  rb  s    rD   r   impl_column_stack.<locals>.impl  s    "3''rF   r8  rb  r   s     rD   impl_column_stackrK    s"    #u''	( (rF   c           
          [        X[        UR                  S   5      [        R                  " XS   5      UR
                  U5      $ )z'
np.stack() with the given axis value.
r   )r,  r   r  r
   r   r  r1  s        rD   _np_stack_commonrM    s?     W#((1+&))'7;__	 rF   c                     [        U SU5      u  p4[        S U 5       5      (       a  SOSn[        R                  " X4S-   U5      nU" X5      nS nXx4$ )Nr'  c              3   >   #    U  H  oR                   S :H  v   M     g7f)r$  N)rA  r  s     rD   r\  "np_stack_common.<locals>.<genexpr>  s     8ACs   r$  r   rH   c                 ~    U R                  XS   UR                  S   [        R                  5      n[	        XX#U5      $ r  )r   r  r   r   rM  r1  s        rD   r   np_stack_common.<locals>.codegen  s3    ||G!Wchhqk5::F#TBBrF   )r6   r  r   r   )	r  r  r   r   rs   rA  r  r]   r  s	            rD   np_stack_commonrS    s\     &i&0&:KE8888ScF
++eAXv
.C
f
CC <rF   c                 P    [        U [        R                  5      (       a  SS jnU$ g )Nc                     [        X5      $ rX  )rS  r6  s     rD   r   impl_np_stack.<locals>.impl  s    "600rF   r   r8  r9  s      rD   impl_np_stackrW    s"    &%//**	1 +rF   c                 |    [        XU5      u  pE[        XS5      n[        U5      n[        R                  " XEU5      nU$ rX  )r6   r  r7   r   r   )r  r   r  ndim_minr   rs   rA  r  s           rD   NdStack_typerrZ    s9    %iFCKEtD)&1F
++e6
*CJrF   c                 :    [        U SUS5      nU" U5      nS nX44$ )Nz	np.hstackrH   c                    ^ UR                   S   nUS   R                  nUS:X  a-  U R                  [        R                  S5      m[        XX#T5      $ US:X  a  SOSmU4S jnU R                  XX#5      $ )Nr   rH   c                 .   > [         R                  " U TS9$ r  r  r6  s    rD   np_hstack_impl3_np_hstack.<locals>.codegen.<locals>.np_hstack_impl  s    ~~f488rF   r  rs   r   r   r   rM  r>  )r   r>   r]   r  ra  rs   r^  r   s          @rD   r  _np_hstack.<locals>.codegen  sr    Qx}}19''

A6D#GcFF
 	1qD9 ++GSOOrF   rZ  r  rb  r  r]   r  s        rD   
_np_hstackrd    s+    
	;Q
7C
c(CP& <rF   c                 L    [        U [        R                  5      (       a  S nU$ g )Nc                     [        U 5      $ rX  )rd  rH  s    rD   r   impl_np_hstack.<locals>.impl      c?"rF   r8  rJ  s     rD   impl_np_hstackri    "    #u''	# (rF   c                 :    [        U SUS5      nU" U5      nS nX44$ )Nz	np.vstackrx  c                     UR                   S   nUS   R                  nUS:X  a  S nO6US:X  a-  U R                  [        R                  S5      n[        XX#U5      $ S nU R                  XX#5      $ )Nr   c                 X    [         R                  " [         R                  " U 5      S5      $ r  )r  r  hstackr  s    rD   np_vstack_impl3_np_vstack.<locals>.codegen.<locals>.np_vstack_impl  s    ~~bii&7;;rF   rH   c                 ,    [         R                  " U SS9$ )Nr   r  r  ro  s    rD   rp  rq        ~~f155rF   r`  )r   r>   r]   r  ra  rs   rp  r   s           rD   r  _np_vstack.<locals>.codegen  sp    Qx}}19< QY''

A6D#GcFF6 ''KKrF   rb  rc  s        rD   
_np_vstackru    s+    
	;Q
7C
c(CL& <rF   c                 L    [        U [        R                  5      (       a  S nU$ g )Nc                     [        U 5      $ rX  )ru  rH  s    rD   r   impl_np_vstack.<locals>.impl  rh  rF   r8  rJ  s     rD   impl_np_vstackry    rj  rF   c                 :    [        U SUS5      nU" U5      nS nX44$ )Nz	np.dstackr  c                    UR                   S   nUR                  nUS   R                  nUS:X  a  S nU R                  XX#5      $ US:X  a  U R	                  [
        R                  S5      nUR                  UR                  S-
  S9n	[        R                  " U	/UR                   Q76 n
[        XXU5      nU R	                  [
        R                  S5      n[        R                  " XY5      n[        XX4U5      $ US:X  a-  U R	                  [
        R                  S5      n[        XX#U5      $ S nU R                  XX#5      $ )Nr   c                 P    [         R                  " U 5      R                  SSS5      $ )NrH   r\  )r  rn  r  ro  s    rD   rp  3_np_dstack.<locals>.codegen.<locals>.np_vstack_impl  s     yy(00Ar::rF   rH   r  rx  c                 ,    [         R                  " U SS9$ )Nrx  r  r  ro  s    rD   rp  r}    rs  rF   )r  r  rs   r>  r   r   r   r  r   r$   rM  r  )r   r>   r]   r  ra  r  rs   rp  r   stack_retty	stack_sig	stack_retrB  s                rD   r  _np_dstack.<locals>.codegen  s$   Qx}}19; ++GSOOQY''

A6D**%**q.*9K((@sxx@I(9)-/I ''

A6D))%=Jw\4PPQY''

A6D#GcFF6 ++GSOOrF   rb  rc  s        rD   
_np_dstackr    s,    
	;Q
7C
c(C PD <rF   c                 L    [        U [        R                  5      (       a  S nU$ g )Nc                     [        U 5      $ rX  )r  rH  s    rD   r   impl_np_dstack.<locals>.impl*  rh  rF   r8  rJ  s     rD   impl_np_dstackr  '  rj  rF   fillc                     S nU$ )Nc                     XS S & g rX  ru   )rO  r   s     rD   	fill_implarr_fill.<locals>.fill_impl2  s    ArF   ru   )rO  r   r  s      rD   arr_fillr  /  s     rF   dotc                     S nU$ )Nc                 .    [         R                  " X5      $ rX  )r  r  )rO  others     rD   dot_implarray_dot.<locals>.dot_impl;  s    vvc!!rF   ru   )rO  r  r  s      rD   	array_dotr  9  s    " OrF   c                 ^    [        U 5      (       d  [        R                  " SU -  5      eS nU$ )NzCannot np.fliplr on %s typec                 ~    [         R                  " U 5      nUR                  S:  a  [        S5      eUS S 2S S S2S4   $ )Nrx  r  r\  .r  r  rs   r   r  r  s     rD   r   np_flip_lr.<locals>.implG  s=    JJqM 66A:455TrT3rF   r@  r  r   s     rD   
np_flip_lrr  A  s2     A  !>!BCC  KrF   c                 ^    [        U 5      (       d  [        R                  " SU -  5      eS nU$ )NzCannot np.flipud on %s typec                 x    [         R                  " U 5      nUR                  S:  a  [        S5      eUS S S2S4   $ )NrH   zInput must be >= 1-d.r\  .r  r  s     rD   r   np_flip_ud.<locals>.implX  s:    JJqM 66A:4552s|rF   r@  r  s     rD   
np_flip_udr  R  s2     A  !>!BCC KrF   c                   ^^ [        U[        R                  5      (       d  [        R                  " U5      e[        UR                  5      m[        R                  " [        R                  TS9mT" U5      nUU4S jnX#4$ )zTCreates a tuple of slices for np.flip indexing like
`(slice(None, None, -1),) * sz` r,  c                    > S n[         R                  T/n[        R                  " T/UQ76 nU R	                  [         R                  5      nU R                  T5      nU" T5      U/n	U R                  XXi5      n
U
$ )Nc           
      \    Un[        U 5       H  n[        X#[        S S S5      5      nM     U$ )Nr\  )r9   r0   rH  )lengthempty_tupler  rp   s       rD   r   6_build_flip_slice_tuple.<locals>.codegen.<locals>.impln  s/    C6]#CE$b,AB #JrF   )r   r   r   r$   r   get_constant_undefr>  )r   r>   r$   r  r   inner_argtypes	inner_sigll_idx_typer  
inner_argsr  r   
tuple_types              rD   r  (_build_flip_slice_tuple.<locals>.codegenm  sw    	  **j1$$ZA.A	,,UZZ800<!$'5
&&wiL
rF   )	r   r   r  r	   rA  r   r   r  slice3_type)ro  szr]   r  r   r  s       @@rD   _build_flip_slice_tupler  c  sg     b%..//((,,r De&7&7tDJ
R.C" <rF   c                 |    [        U [        R                  5      (       d  [        R                  " SU -  5      eS nU$ )NzCannot np.flip on %s typec                 4    [        U R                  5      nX   $ rX  )r  rs   )r  sls     rD   r   np_flip.<locals>.impl  s    $QVV,urF   )r   r   r   r	   r   r  s     rD   np_flipr    s8     a%%  !<q!@AA KrF   c                    [        U [        R                  [        R                  [        R                  45      (       a  SS jnU$ [        U[        R
                  5      (       a  SS jnU$ [        U[        R                  5      (       a:  [        UR                  R                  [        R
                  5      (       a  SS jnU$ [        U[        R                  5      (       a)  [        S UR                   5       5      (       a  SS jnU$ g g )Nc                 V    [         R                  " [         R                  " U 5      UUS9$ r  )r  array_splitr  r  indices_or_sectionsr   s      rD   r   np_array_split.<locals>.impl  s$    >>

3# rF   c                     [        U R                  U   U5      u  p4[        R                  " [        R                  " US-   /U-  U/X-
  S-
  -  -   5      5      n[        R
                  " XUS9$ )NrH   r  )divmodrh   r  cumsumr   r  )r  r  r   r  rt  r   s         rD   r   r    sj    CIIdO-@AFAiiQ#*01456! G >>#T::rF   c                    [        U R                  5      n[        SSU R                  U5      n/ nSnU H-  n[        X2[	        XV5      5      nUR                  X   5        UnM/     UR                  U [        X2[	        WS 5      5         5        U$ Nznp.splitr   r   )r1   rs   r   r0   rH  rl   r  r  r   	slice_tupr  prevrH  r   s           rD   r   r    s    .sxx8I!*fchhEDCD*#IU45EF

38$ + JJs=%T:JKLMJrF   c              3   V   #    U  H  n[        U[        R                  5      v   M!     g 7frX  r   r   r   )rZ  r  s     rD   r\  !np_array_split.<locals>.<genexpr>  s      P6O
1emm,,6Or^  c                 0   [        U R                  5      n[        SSU R                  U5      n/ nSn[        U5       H-  n[	        X2[        XV5      5      nUR                  X   5        UnM/     UR                  U [	        X2[        WS 5      5         5        U$ r  )r1   rs   r   r   r0   rH  rl   r  s           rD   r   r    s    .sxx8I!*fchhEDCD%&9:#IU45EF

38$ ; JJs=%T:JKLMJrF   r   )r   r   r  ListTyper`  r   IterableTypeiterator_typer)  r  r  r  r  r   r   s       rD   np_array_splitr    s    #

CDD	 %u}}55	;  	&(:(:;;--88MM
 


	  	&44P6I6O6OPPP
	  Q 	5rF   c                     [        U [        R                  [        R                  [        R                  45      (       a  SS jnU$ [        U[        R
                  5      (       a  SS jnU$ [        XUS9$ )Nc                 T    [         R                  " [         R                  " U 5      XS9$ r  )r  splitr  r  s      rD   r   np_split.<locals>.impl  s    88BJJsO-@LLrF   c                     [        U R                  U   U5      u  p4US:w  a  [        S5      e[        R                  " XUS9$ )Nr   z0array split does not result in an equal divisionr  )r  rh   r   r  r  )r  r  r   rG  rt  s        rD   r   r    sH    CIIdO-@AFAax F  >>t rF   r  r   )r   r   r  r  r`  r   r  r  s       rD   np_splitr    s^     #

CDD	M %u}}55	  cTBBrF   c                 D   [        U [        R                  5      (       d  Sn[        R                  " U5      e[        U[        R
                  [        R                  [        R                  [        R                  45      (       d  Sn[        R                  " U5      eS nU$ )N#The argument "ary" must be an array:The argument "indices_or_sections" must be int or 1d-arrayc                 b    U R                   S:  a  [        S5      e[        R                  " XSS9$ )Nrx  z3vsplit only works on arrays of 2 or more dimensionsr   r  rs   r   r  r  r  r  s     rD   r   numpy_vsplit.<locals>.impl  s2    88a< ? A Axxq99rF   r   r   r   r	   r   r   r`  r  r  r  r   r   s       rD   numpy_vsplitr    |    c5;;''3  %%)EMM5;;,1JJ,H I IK  %%: KrF   c                 D   [        U [        R                  5      (       d  Sn[        R                  " U5      e[        U[        R
                  [        R                  [        R                  [        R                  45      (       d  Sn[        R                  " U5      eS nU$ )Nr  r  c                     U R                   S:X  a  [        S5      eU R                   S:  a  [        R                  " XSS9$ [        R                  " XSS9$ )Nr   z3hsplit only works on arrays of 1 or more dimensionsrH   r  r  r  s     rD   r   numpy_hsplit.<locals>.impl  sN    88q= ? A A88a<88C1==xxq99rF   r  r  s       rD   numpy_hsplitr    s|    c5;;''3  %%)EMM5;;,1JJ,H I IK  %%: KrF   c                 D   [        U [        R                  5      (       d  Sn[        R                  " U5      e[        U[        R
                  [        R                  [        R                  [        R                  45      (       d  Sn[        R                  " U5      eS nU$ )Nr  r  c                 b    U R                   S:  a  [        S5      e[        R                  " XSS9$ )Nr  z3dsplit only works on arrays of 3 or more dimensionsrx  r  r  r  s     rD   r   numpy_dsplit.<locals>.impl  s0    88a< * + +xxq99rF   r  r  s       rD   numpy_dsplitr    r  rF   c                 
    X:  $ )z/
Trivial comparison function between two keys.
ru   r'  s     rD   
default_ltr  -  s     5LrF   c                    XR                   U4n [        U   $ ! [         a^    U S:X  a#  [        R                  " UUSS9nUR
                  nO'U S:X  a!  [        R                  " UUS9nUR                  nW[        U'   Us $ f = f)z.
Get a sort implementation of the given kind.
r+   T)lt
is_argsortis_np_arrayr,   )r  r  )	rv   _sortsKeyErrorr+   make_jit_quicksortrun_quicksortr,   make_jit_mergesortrun_mergesort)r  lt_implr  keyrL  r  s         rD   get_sort_funcr  4  s       *
,Cc{ ;//% "D %%D[ //%'D %%Dss    A%B Bc                     [        U [        R                  5      (       a  [        $ [        U [        R                  5      (       a  [
        $ [        $ rX  )r   r   r  r   rj  r   r  rU  s    rD   lt_implementationr  L  s6    %%%	E5==	)	)rF   z
array.sortc                    ^ UR                   S   n[        S[        UR                  5      S9mU4S jnU R	                  XX#5      $ )Nr   r+   )r  r  c                    > T" U 5        g rX  ru   rO  	sort_funcs    rD   array_sort_impl#array_sort.<locals>.array_sort_impl\  s
    #rF   )r  r  r  r   r>  )r   r>   r]   r  r[  r  r  s         @rD   
array_sortr  U  sC    hhqkG;&7&FHI ##GcHHrF   c                 X    [        U 5      (       d  [        R                  " S5      eS nU$ )NzArgument "a" must be array-likec                 F    U R                  5       nUR                  5         U$ rX  )r  rL  )rK  r  s     rD   np_sort_impl"impl_np_sort.<locals>.np_sort_impli  s    ffh

rF   r@  )rK  r  s     rD   impl_np_sortr	  c  s2    A   "1 2 	2 rF   zarray.argsortc                    ^	 UR                   u  pE[        UR                  [        UR                  5      SS9m	U	4S jnUR                  UR                   S S S9nUS S nU R                  XXx5      $ )NT)r  r  r  c                    > T" U 5      $ rX  ru   r  s    rD   array_argsort_impl)array_argsort.<locals>.array_argsort_imply  s    ~rF   rH   r  )r  r  r   r  r   replacer>  )
r   r>   r]   r  r[  r  r	  innersig	innerargsr  s
            @rD   array_argsortr		  p  su     HHMG4#5#5&7&F)-/I {{!{-HRaI##G$,9 9rF   c                 ^    UR                   UR                   :w  d  UR                  S:X  d   eU$ )Nr  )r  rA  )r   r>   r  r  r   s        rD   array_to_arrayr	    s*     >>T\\)T[[C-???JrF   c                 r    S n[        X25      nU R                  XXd/5      n[        XUR                  U5      $ )Nc                 $    U R                  S5      $ r   )r  r  s    rD   r   array0d_to_scalar.<locals>.impl  s    vvayrF   )r$   r>  r"   r  r   r>   r  r  r   r   r]   r  s           rD   array0d_to_scalarr	    s:     D
!C

"
"7#u
=CgEErF   c                 r    S n[        X25      nU R                  XXd/5      n[        XUR                  U5      $ )Nc                     [        U S   5      $ r  )r  r  s    rD   r    array_to_unichrseq.<locals>.impl  s    1R5zrF   )r$   r>  r    r  r	  s           rD   array_to_unichrseqr	    s:     D
!C

"
"7#u
=CWsDDrF   c                     [         e)zJ
An intrinsic returning a derived array with the given shape and strides.
r   )rK  rh   r   s      rD   reshape_uncheckedr	    r  rF   c                    ^ S mU4S jnU$ )Nc                 h    [        U [        R                  5      =(       a    [        S U  5       5      $ )Nc              3   V   #    U  H  n[        U[        R                  5      v   M!     g 7frX  r  r  s     rD   r\  >type_reshape_unchecked.<locals>.check_shape.<locals>.<genexpr>  s     @%QJq%--00%r^  )r   r   re  r  rh   s    rD   r  +type_reshape_unchecked.<locals>.check_shape  s*    5%//2 A@%@@	BrF   c                    > [        U [        R                  5      (       d  g T" U5      (       a  T" U5      (       d  g [        U5      [        U5      :w  a  g U R	                  [        U5      SS9$ )Nr  r  )r   r   r   r   r  )rK  rh   r   r  s      rD   typer%type_reshape_unchecked.<locals>.typer  sY    !U[[))5!!W)=)=u:W%vv3u:cv22rF   ru   )r   r	  r  s     @rD   type_reshape_uncheckedr 	    s    B3 LrF   c           	      x   UR                   S   nUR                  n[        U5      " XUS   5      n[        U5      " X5      n[        R                  " XS   5      n[        R                  " XS   5      n	[        UUR                  UU	UR                  UR                  S9  UR                  5       n
[        XXZ5      $ )Nr   rH   rx  r;  )r  r  r   r
   r   r   r   r   r   r  r    )r   r>   r]   r  r   r  r  r  rh   r   r  s              rD   impl_shape_uncheckedr"	    s    HHQKEOOE
U
Gd1g
6C
U
G
-C  q'2E""7G4G3"LL;; --/CWu::rF   c                    ^^ US [         R                  4;   a  [        S 5       mO[        S 5       mUS [         R                  4;   a  [        R                  " S5      e[        S 5       mSUU4S jjnU$ )Nc                     U R                   $ rX  r	  r  rh   s     rD   r  as_strided.<locals>.get_shape  s    77NrF   c                     U$ rX  ru   r%	  s     rD   r  r&	    s    LrF   z,as_strided() strides argument cannot be Nonec                     U$ rX  ru   )r  r   s     rD   get_stridesas_strided.<locals>.get_strides  s    NrF   c                 :   > [        U T" X5      T" X5      5      n U $ rX  )r	  )r  rh   r   r  r)	  s      rD   as_strided_impl#as_strided.<locals>.as_strided_impl  s     a1!4k!6MNrF   r  )r   r  r&   r	   r   )r  rh   r   r,	  r  r)	  s       @@rD   
as_stridedr.	    s    uzz""		 
	 
	 
	 4$$
   !OPP		 
	  rF   c                   ^^^^ [        U[        R                  5      (       aO  [        [	        U R
                  S-   5      5      m[        [	        U R
                  S-   5      5      m[        S 5       mO[        U[        R                  5      (       a  [        UR                  [        R                  5      (       aa  [        [	        U R
                  [        U5      -   5      5      m[        [	        U R
                  [        U5      -   5      5      m[        S 5       mO[        R                  " S5      e[        U5      (       a  [        S 5       mO[        U[        R                  5      (       a  [        S 5       mOk[        U[        R                  5      (       a6  [        UR                  [        R                  5      (       a  [        S 5       mO[        R                  " S5      eS
UUUU4S	 jjnU$ )NrH   c                     U 4$ rX  ru   window_shapes    rD   get_window_shape-sliding_window_view.<locals>.get_window_shape   s
     ?"rF   c                     U $ rX  ru   r1	  s    rD   r3	  r4	  	  s    rF   z4window_shape must be an integer or tuple of integersc                 *    [        [        U5      5      $ rX  )r   r9   r2	  r   rs   s      rD   get_axis%sliding_window_view.<locals>.get_axis  s    d$$rF   c                     [        SSX!5      /$ Nsliding_window_viewr   r   r7	  s      rD   r8	  r9	    s     4fdI rF   c           	      H    U Vs/ s H  n[        SSX#5      PM     sn$ s  snf r;	  r=	  )r2	  r   rs   rK  s       rD   r8	  r9	  !  s3     "#! ##8&$J!# # #s   z2axis must be None, an integer or tuple of integersc                 H  > T" U5      nT
" XU R                   5      n[        U5      [        U5      :w  a  [        S5      eTnTn[        U R                   5       H5  n[	        X5U R
                  U   5      n[	        XEU R                  U   5      nM7     U R                   n[        X!5       Hi  u  pgUS:  a  [        S5      eX6   U:  a  [        S5      eX6   U-
  S-   n[	        X6U5      n[	        X5U5      n[	        XEU R                  U   5      nUS-  nMk     [        XU5      n	U	$ )Nz2Must provide matching length window_shape and axisr   z-`window_shape` cannot contain negative valuesz4window_shape cannot be larger than input array shaperH   )	rs   r   r   r9   r0   rh   r   r   r	  )r  r2	  r   	out_shapeout_stridesrp   r   r  trimmedr  r8	  r3	  shape_bufferstride_buffers             rD   sliding_window_view_impl5sliding_window_view.<locals>.sliding_window_view_impl+  s.   '5AFF3|D	)D 
 !	#qvvA%iAGGAJ?I'		!EK  FF4.GBQw C  }s" J   mc)A-G%iW=I%iC8I'		"FKFA /$ !{;rF   rX  )r   r   r   r   r9   rs   r&   r  r   r   r	   r   r   )r  r2	  r   rE	  r8	  r3	  rC	  rD	  s       @@@@rD   r<	  r<	    s    ,..U166A:./eAFFQJ/0		# 
	# \5>>
2
2|))5==99U166C,=#=>?eAFFS->$>?@		  
	    B
 	

 4		% 
	% 
D%--	(	(		 
	
 T5>>
*
*tzz5==11		# 
	#
   @
 	
% %N $#rF   c                 L    [        U [        R                  5      (       a  S nU$ g )Nc                     U R                   S:X  a  [        S:  a  g[        S5      eU R                   S:X  a  [        U R	                  S5      5      $ [        S5      e)Nr   )rx  rx  FziThe truth value of an empty array is ambiguous. Use `array.size > 0` to check that an array is not empty.rH   z[The truth value of an array with more than one element is ambiguous. Use a.any() or a.all())r   r   r   rf  r  r  s    rD   r   ol_bool.<locals>.implX  s_    xx1} 6) $ 'J L L QCHHQK((  #- / /rF   rY  r  s     rD   ol_boolrJ	  U  s$    #u{{##	/  $rF   c                   ^^ [        U[        [        R                  45      (       d  [        R
                  " S5      e[        U[        [        R                  45      (       d  [        R
                  " S5      e[        U [        R                  5      (       d  [        R
                  " S5      eU R                  m[        [        T5      5      mUU4S jnU$ )Nz.The second argument "axis1" must be an integerz-The third argument "axis2" must be an integer'The first argument "a" must be an arrayc                    > [        SSTU5      n[        SSTU5      n[        TX5      n[        X2U5      n[        R                  " X5      $ )Nznp.swapaxesaxis1axis2)r   r0   r  rS  )rK  rN	  rO	  
axes_tuple	axes_listrs   s       rD   r   numpy_swapaxes.<locals>.implx  sJ    }gtUC}gtUC"9e;
":e<
||A**rF   )
r   r   r   r   r	   r   r   rs   r   r9   )rK  rN	  rO	  r   rQ	  rs   s       @@rD   numpy_swapaxesrS	  i  s    ec5==122   "+ , 	,ec5==122   "+ , 	,a%%  !JKK 66DeDk"I+ KrF   c                   ^^ [        U [        R                  5      (       d  [        R                  " S5      e[        U[        R
                  5      (       d^  [        U[        R                  5      (       a)  [        UR                  [        R
                  5      (       d  [        R                  " S5      e[        U[        R
                  5      (       d^  [        U[        R                  5      (       a)  [        UR                  [        R
                  5      (       d  [        R                  " S5      eU R                  mSU R                  -  mUU4S jnU$ )NrL	  zGThe second argument "source" must be an integer or sequence of integerszKThe third argument "destination" must be an integer or sequence of integersr  c                   > [        SST
U5      n[        SST
U5      n[        U5      [        U5      :w  a  [        S5      e[        U R                  5       Vs/ s H  o3U;  d  M
  UPM     nn[        [        X!5      5       H  u  pVUR                  XV5        M     Tn[        U5       H  u  p[        XxU	5      nM     U R                  U5      $ s  snf )Nznp.moveaxissourcedestinationzL`source` and `destination` arguments must have the same number of parameters)r   r   r   r9   rs   r  r   r  r   r0   rS  )rK  rV	  rW	  r[  
order_listr  r~  r  rp   ors   
order_inits             rD   r   numpy_moveaxis.<locals>.impl  s    %mXtVL*=$
 v;#k**0 
 "'qvvBA6/a
BK 89IDd( : j)DA!%A.E * {{5!! Cs   	C%C)	r   r   r   r	   r   r   r  r   rs   )rK  rV	  rW	  r   rs   rZ	  s       @@rD   numpy_moveaxisr\	    s    a%%  !JKK65==))vu~~..6<<77   &
 	

 	;..{ENN33;,,emm<<   &
 	

 66DJ", KrF   c                 >   [        SSU R                  U5      n[        U R                  5      nSXb'   [	        [        XaR                  5      5       H8  u  nu  pUS:X  a  U	n
OU	S:X  a  Un
OX:w  a  [        S5      eUn
[        XWU
5      nM:     [        XRU R                  U   5      n[        R                  " X5      n [        R                  " X5      nUn[        U5      S:  a4  [        [        U5      5       H  n[        XU R                  U   5      nM     Un[        U5      S:  a:  [        [        U5      5       H"  n[        XU R                  US-   U-      5      nM$     UR                  U   n[        R                  " X4-   U-   U R                  5      n[        S S S 5      4n[        R                  " U5       H^  n[        R                  " U5       HA  nU UU-   U-      nUUU-   U-      nUUU-   U-      n[        U5       H  nUUU      UU'   M     MC     M`     U$ )Nznp.take_along_axisr   rH   z*`arr` and `indices` dimensions don't matchr   )r   rs   r   rh   r   r   r   r0   r  r  r   r9   rW  r   rH  r  )rO  r   r   Ni_origNk_origindices_broadcast_shape	arr_shaperp   d1d2new_valarr_broadcast_shapeNiNkJr  np_s_iikka_1d
indices_1dout_1dr  s                          rD   _take_along_axis_implro	    s    .$GD SYYIIO Y!>?8B7G1WGx @  G"/##
 @ (syy //#
3Coog?G	B
7|as2wArciil3B  	B
7|as2wArciiq1&=>B   	dA
((29r>399
-C4t$&Ejjn**R.BrEzB'D eb1Jeb)F1X A/q	 	 !  JrF   c                   ^^^ [        U [        R                  5      (       d  [        R                  " S5      e[        U[        R                  5      (       d  [        R                  " S5      e[        UR
                  [        R                  5      (       d  [        R                  " S5      e[        U5      (       a  SnOU R                  nX1R                  :w  a  [        R                  " S5      e[        [        UR                  5      5      m[        U5      (       a  U4S jnU$ [        US5        [        U[        R                  5      (       d  [        R                  " S5      eUR                  nUS	:  a  U R                  U-   nUS	:  d  X R                  :  a  [        R                  " S
5      e[        [        U5      5      m[        [        US-   U R                  5      5      mUUU4S jnU$ )Nz)The first argument "arr" must be an arrayz.The second argument "indices" must be an arrayz'The indices array must contain integersrH   z;`indices` and `arr` must have the same number of dimensionsc                 @   > [        U R                  5       USSST5      $ )Nr   ru   )ro	  r  )rO  r   r   r`	  s      rD   take_along_axis_impl1arr_take_along_axis.<locals>.take_along_axis_impl
  s%    (B)@B BrF   r   zaxis must be a literal valuer   zaxis is out of boundsc                 "   > [        XUTTT5      $ rX  )ro	  )rO  r   r   rf	  rg	  r`	  s      rD   rr	  rs	    s    (tR)@B BrF   )r   r   r   r	   r   r   r   r   rs   r   r9   r   r  r  r   )rO  r   r   arr_ndimrr	  rf	  rg	  r`	  s        @@@rD   arr_take_along_axisrv	    s   c5;;''  !LMMgu{{++  <> 	>gmmU]]33  !JKK488<<  I
 	
 $E',,$784	B(  ! 	v&$ 4 455(()GHH!!!888d?D!8txx'(()@AA5;5388,-	B  rF   c                    [        U [        R                  5      (       a  [        U [        R                  5      (       a  S	S jnU$ [        U [        R                  5      (       a  S	S jnU$ [        U [        R
                  5      (       a  S	S jnU$ [        R                  " S5      e[        U 5      (       a  [        U R                  [        R                  5      (       a  S	S jnU$ [        U R                  [        R                  5      (       a  S	S jnU$ [        U R                  [        R
                  5      (       a  S	S jnU$ [        R                  " S5      e[        R                  " S5      e)
Nc                     U $ rX  ru   r  r  nanposinfneginfs        rD   r   nan_to_num_impl.<locals>.impl&      rF   c                 l   Ub  UO([         R                  " [        U 5      5      R                  nUb  UO([         R                  " [        U 5      5      R                  n[         R
                  " U 5      (       a  U$ [         R                  " U 5      (       a  U$ [         R                  " U 5      (       a  U$ U $ rX  )r  finfor:   r  r  rJ  isneginfisposinf)r  r  rz	  r{	  r|	  min_infmax_infs          rD   r   r}	  *  s     ) $q'*..  ) $q'*..  88A;;J[[^^"N[[^^"NrF   c                     [         R                  " U R                  X#US9n[         R                  " U R                  X#US9n[	        XV5      $ )N)rz	  r{	  r|	  )r  
nan_to_numrp  rr  complex)r  r  rz	  r{	  r|	  r  r  s          rD   r   r}	  >  s8    MM!&&cPMM!&&cPq}$rF   z4Only Integer, Float, and Complex values are acceptedc                     U $ rX  ru   ry	  s        rD   r   r}	  J  r~	  rF   c                 N   Ub  UO)[         R                  " U R                  5      R                  nUb  UO)[         R                  " U R                  5      R                  n[         R
                  " U 5      nU(       a  [         R                  " U5      OUnUR                  n	[        UR                  5       Hl  n
[         R                  " X   5      (       a  X)U
'   M&  [         R                  " X   5      (       a  XYU
'   MI  [         R                  " X   5      (       d  Mh  XiU
'   Mn     U$ rX  )r  r	  r   r  r  r  r  r3  r9   r   rJ  r	  r	  )r  r  rz	  r{	  r|	  r	  r	  x_outputoutput_flatrp   s              rD   r   r}	  M  s     ) !''*..  ) !''*..  ZZ](,"$kkv{{+Axx//),A[^44)0A[^44)0A , rF   c                     [         R                  " U 5      nU(       a  [         R                  " U5      OUn[         R                  " UR                  SUUUS9  [         R                  " UR
                  SUUUS9  U$ )NF)r  rz	  r{	  r|	  )r  r  r  r	  rp  rr  )r  r  rz	  r{	  r|	  r	  r	  s          rD   r   r}	  f  sg    ZZ](,"KK!! KK!! rF   z4The first argument must be a scalar or an array-likeTg        NN)
r   r   r  r   r  rj  r	   r   r   r   )r  r  rz	  r{	  r|	  r   s         rD   nan_to_num_implr	  !  s5   !U\\""a''t Ko 5;;''l KG 5==))%D K{ $$F  
!		aggu}}--l Ki --f K7 //4 K $$F     ". / 	/rF   rX  rc  r  r!  r   )Fr  r	  (  r  r  r  r  r  llvmliter   llvmlite.irr   numpyr  numbar   r   
numba.corer   r   r	   r
   r   numba.np.numpy_supportr   r   r   r   r   r   r   r   r   r   r   r   r   numba.core.imputilsr   r   r   r   r   r   r   r    r!   r"   r#   numba.core.typingr$   numba.core.typesr%   numba.core.extendingr&   r'   r(   r)   r*   
numba.miscr+   r,   numba.cpythonr-   numba.cpython.charseqr.   r/   numba.cpython.unsafe.tupler0   r1   r2   numba.core.typing.npydeclr3   rr  r4   rs  r5   r6   r7   rE   rJ   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r   ArrayIteratorBORROWEDr2  rK  r  rQ  r  r   r9  rS  rU  re  rc  r  Anyrj  r   ro  r   rv  r{  r  r}  r  r  r  r  r  r  r`  rK  rR  rW  rY  ra  r  r  r  r  r  r  r  r  r  r  r  broadcast_shapesr  r  r  r  r  r  rg  r1  r5  r8  rL  VarArgrO  rS  rY  r3  rt  re  	geomspacer~  rot90r  r  r  r  r  r  r  resizer  rl   r  r  r  r  r  r  r  r  r  r"  r<  rh   rB  r   rF  uniquerR  rc  ra  rV  rh  rp  rr  r  r  r  r  
MemoryViewr  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  DTypeNumberClassr  r  r  r  r  r  r  r  r  r  r  r  r   Bytesr$  is_r,  r1  r7  r<  rH  rJ  r  r  r5  r  r  r  r
  r  r  r9  r  r  r  r  r  r  r  r  rO  r  NumpyNdIterTyper   eqr$  r?  r@  r,  r=  rU  rY  r  r_  rj  rW  rn  ru  rz  r  r~  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  eyer  diagr  r   r  diagflatr  r  r  r  r  r  r  r_  r!  r%  r'  r)  r  r/  r=  rB  rE  rL  rO  rR  rU  r_  rc  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r  r  r  r  r  r  r  r  r  
atleast_1dr  
atleast_2dr
  
atleast_3dr  r  r%  r,  r.  r3  r  r:  r<  rE  column_stackrK  rM  rS  stackrW  rZ  rd  rn  ri  ru  vstackry  	row_stackr  dstackr  r  r  r  r  r  r  r  flipr  r  r  r  r  vsplitr  hsplitr  dsplitr  r  r  r  r  r  rL  r	  argsortr		  r	  UnicodeCharSeqr  rj  r  NPTimedelta
NPDatetimer	  r	  r	  type_callabler 	  r"	  libstride_tricksr.	  r<	  rf  rJ	  r  rS	  moveaxisr\	  ro	  take_along_axisrv	  r	  r	  ru   rF   rD   <module>r	     sn  
         * @ @; ; ; P O* * * * ( *A A + ! B L 5E E#69x(-M	

  BJH& 
 
. , 
 

,  ,^ y%,,' (.;* z5../w - ! 0-6  $A4H ;* xu}}=xu?xu~~>E ? @ >E" xu?E @E0 xuyy%))D%6 E%6P sELL!F "F |U[[)8 *8 6?EKK;) <)(/"f /"d/-G /-dW >:-' :-zN-' N-bB-7 B-JL6 L^(GV xu{{;; <;&'TH
:$z"J!. 4  ,  " 5 5>- 
"//'& '&T 3 3  
"

% %P 
"

6 6r 

"95
 6
 

"51 2*U%v&  %++.; /;
  %++u?3E @3El  %++u||EII/FGF HF
 
",,  u{{C 9 !9& 
"++  
",,I IX 
"(( 4!H;< U__==E >=E@ U\\%))-DE> F>
 6bjj 
 bjj  
"))+ +\ 
")) 2 }ekk* +, rxx%G &G , - 
 
   
"''v vr f% &{| 
"((  
"''  
"))  
")))1 )1X  " 5;;1 2  	 

9-( .(V |U[[%//:$E ;$ET u{{G$: %:
 u{{G$u): * %: u{{I&u+: , ': u{{F#u(: ) $:
 u{{F#: $: u{{J'u,: - (: u{{H%u*: + &: u.: /:
 u0: 1:
 u0: 1:
 u,: -: u{{H%	9 &	9 u  &): *: Eu~~.Eu}}-; . /;4 u{{G$8 %8 u.u0	: 1 /	: u0
: 1
:  u{{F#Q $Q u{{F#Q $Q 4Mn f%k* + &%
 ekk6 ": . ekk6 ": . !2!2EII>( ?(. u{{#4; $4;n e.A.ABO CO u||$$= %$=N u||$D %D: u/B/BCA DA u/C/CDE EE u/B/BEIIN	% O	% u/C/CUYYO
% P
%" ; ; 3 3 9 9 x||U[[%++6
G 7
G  EKK, -9> IM6:#D '+OEP
>BVr u{{F#P $P z5../w E ! 0E x!4!4emmDE EE x!4!4emmyy%% sE''( ) r~~u{{+E ,E" z5556w C ! 7C xemm45rzz5<<67
E 8 6
E x)rzz5??+E , *E* z5112w 7 ! 37 ryy%))$> %>& z5001w 7 ! 27 x{{EKK5F 6FL^ ekk;u= >* 
 
-`K#&   
"((" & &*   
"-- 0   l+ , 
"(("   
"--  
",,
 
 
"''   
",,
 
 
"''  
"++ 	 %& ' BFF1E  2 
"''# #L 
"** 6 
"++ 4  F 
"''f%^ & ^B4 
"))@ @F 
"++$ $N"PJ   |U[[)4 *4 
"'' ><B ? ? 
"


  
 
"

  ~u{{EOO<~u{{E,?,?@P A =P: ' 'T i( ) T Tn 
"--%*"Q  8 
&  
& !H1Dh"<&'R&#R)  2 
"(( &?:@:8    
".. %2. 
"--# #
 
"--& &
 
"--) )
:z/FdVFr,$    
"..  " "J 
"//    
"((   4 
"))   4 
"))  FR\\>* & &R 
"))  5;;/ 0 5;;. / 
"))   
"))    : 
"''
 
 
"..; ;| 
"((C C4 
")) & 
")) * 
")) , 
0 |U[[)
I *
I 
"''	 	 U-@-@Arzz5;;(;(;<9 = B9& EKK% & EKK--.EKK%EKK'EKK'EKK'EKK**+EKK))*F + , ( ( ( & /F EKK--.E /E *+ ,"  %++uP; Q;* BFF((334 58 BFF((<<=[$ >[$| 
$ & 
"++ 0 
"++3 3l 8 8v 
"

(  ( V 
"--^ ^rF   