+
    :if                    $   R t ^ RIt^ RIt^ RIHt ^ RIt^ RIt^ RIH	t	H
t
HtHt ^ RIHt ^ RIHtHtHt ^ RIHtHtHt ^ RIHtHtHt ^RIHtHtHt ^ R	IH t! ]PD                  ! ^4      t#]#PI                  4       t%]%t&]PD                  ! ^ 4      t']'PI                  4       t(]PR                  t)])PI                  4       t*]PV                  t,]PV                  t-]P\                  R
]P^                  R]P`                  R]Pb                  R/t2RcR lt3R t4R t5R t6 ! R R4      t7 ! R R4      t8]Pr                  R 4       t:R t;R t<R t=R t>R t?R t@R tAR tBR tCRdR  ltD]! ]P                  4      R! 4       tF]! ]P                  4      R" 4       tHR# tI]! ]P                  4      R$ 4       tJR% tKR& tLR' tMR( tN]! ]P                  4      R) 4       tO]P                  ! R*]P                  ! 4       4      tR]R+ 4       tSReR, ltTR- tUR. tV]! ]V4      R/ 4       tW]R0 4       tX]R1 4       tY]! ]P                  P                  4      R2 4       t\]R3 4       t]ReR4 lt^]! ]P                  P                  4      R5 4       t`]! ]P                  P                  4      R6 4       tb]! ]P                  P                  4      R7 4       td]! ]P                  P                  4      R8 4       tf]! ]P                  P                  4      R9 4       th]! ]P                  P                  4      RfR: l4       tj]! ]P                  P                  4      R; 4       tlR< tm]! ]m4      R= 4       tnR> to]! ]o4      R? 4       tpR@ tq]! ]q4      RA 4       trRB ts]! ]s4      RC 4       ttRD tu]! ]u4      RE 4       tvRF tw]! ]w4      RG 4       tx]! ]P                  P                  4      RgRH l4       tzRI t{]! ]{4      RJ 4       t|]! ]P                  P                  4      RK 4       t~]! ]P                  P                  4      RhRL l4       tRM t]! ]P                  EP                  4      RN 4       t]! ]P                  EP                  4      RO 4       tRP t]! ]4      RQ 4       tRR t]! ]4      RS 4       tRT t]! ]P                  EP                  4      RiRU l4       t]! ]P                  EP                  4      RiRV l4       t]RW 4       t]! ]P                  EP                   4      RiRX l4       t]! ]P                  EP$                  4      RY 4       t]! ]EP(                  4      RjRZ l4       tReR[ lt]R\ 4       t]R] 4       tR^ t]! ]EP4                  4      RiR_ l4       tR` tRa t]! ]EP<                  4      Rb 4       tR# )kz.
Implementation of linear algebra operations.
N)ir)lower_builtinimpl_ret_borrowedimpl_ret_new_refimpl_ret_untracked)	signature)	intrinsicoverloadregister_jitable)typescgutilsconfig)TypingErrorNumbaTypeErrorNumbaPerformanceWarning)
make_array_empty_nd_impl
array_copy)numpy_supportsdczc                 X    \         P                  V 4      pVf   \        RV: R24      hV# )Nzunsupported dtype for z())_blas_kindsgetr   )dtype	func_namekinds   && M/var/www/html/photoedit/myenv/lib/python3.14/site-packages/numba/np/linalg.pyget_blas_kindr    0   s(    ??5!D|YHIIK    c                  D     ^ RI p R#   \         d    \        R4      hi ; i    Nz*scipy 0.16+ is required for linear algebra)scipy.linalg.cython_blasImportErrorscipys    r   ensure_blasr)   7   s(    H' HFGGH    c                  D     ^ RI p R#   \         d    \        R4      hi ; ir#   )scipy.linalg.cython_lapackr&   r'   s    r   ensure_lapackr-   >   s(    H) HFGGHr*   c                 R    V P                  WV4      p\        P                  ! W4      # N)get_constant_genericr   alloca_once_value)contextbuildertyvalconsts   &&&& r   make_constant_slotr7   E   s%    ((c:E$$W44r!   c                   J   a  ] tR t^Jt o RtR t]R 4       t]R 4       tRt	V t
R# )_BLASzA
Functions to return type signatures for wrapped
BLAS functions.
c                    \        4        R # r/   )r)   selfs   &r   __init___BLAS.__init__P   s    r!   c           	     "   \        VR V4      p\        P                  ! \        P                  \        P                  \        P
                  ! V4      \        P                  \        P
                  ! V4      4      p\        P                  ! RV4      # )underlying_floatnumba_xxnrm2getattrr   intccharintpCPointerExternalFunctionclsr   rtypesigs   &&  r   rA   _BLAS.numba_xxnrm2S   s`    159jj..	0 %%nc::r!   c                :   \         P                  ! \         P                  \         P                  \         P                  \         P                  \         P                  \         P                  \         P                  ! V4      \         P                  ! V4      \         P                  \         P                  ! V4      \         P                  \         P                  ! V4      \         P                  ! V4      \         P                  4      p\         P
                  ! R V4      # )numba_xxgemmr   rD   rE   rF   rG   rH   rJ   r   rL   s   && r   rO   _BLAS.numba_xxgemm^   s    jjJJJJJJJJJJJJNN5!NN5!JJNN5!JJNN5!NN5!JJ
  %%nc::r!    N)__name__
__module____qualname____firstlineno____doc__r=   classmethodrA   rO   __static_attributes____classdictcell____classdict__s   @r   r9   r9   J   s7     
 ; ; ; ;r!   r9   c                      a  ] tR t^st o RtR t]R 4       t]R 4       t]R 4       t	]R 4       t
]R 4       t]R 4       t]R	 4       t]R
 4       t]R 4       t]R 4       t]R 4       tRtV tR# )_LAPACKzC
Functions to return type signatures for wrapped
LAPACK functions.
c                    \        4        R # r/   )r-   r;   s   &r   r=   _LAPACK.__init__y   s    r!   c           
     .   \         P                  ! \         P                  \         P                  \         P                  \         P                  ! V4      \         P                  \         P                  ! \
        4      4      p\         P                  ! R V4      # )numba_xxgetrfr   rD   rE   rF   rG   F_INT_nbtyperH   rQ   s   && r   rc   _LAPACK.numba_xxgetrf|   sX    jj.5 %%os;;r!   c           	        \         P                  ! \         P                  \         P                  \         P                  ! V4      \         P                  \         P                  ! \
        4      4      p\         P                  ! R V4      # )numba_ez_xxgetrird   rQ   s   && r   rh   _LAPACK.numba_ez_xxgetri   sR    jj.5	 %%&8#>>r!   c                   \         P                  ! \         P                  \         P                  \         P                  \         P                  \         P                  ! V4      \         P                  \         P                  ! V4      \         P                  ! V4      \         P                  ! V4      \         P                  \         P                  ! V4      \         P                  4      p\         P
                  ! R V4      # )numba_ez_rgeevrP   rQ   s   && r   rk   _LAPACK.numba_ez_rgeev   s    jj..... %%&6<<r!   c                   \         P                  ! \         P                  \         P                  \         P                  \         P                  \         P                  ! V4      \         P                  \         P                  ! V4      \         P                  ! V4      \         P                  \         P                  ! V4      \         P                  4      p\         P
                  ! R V4      # )numba_ez_cgeevrP   rQ   s   && r   rn   _LAPACK.numba_ez_cgeev   s    jj.... %%&6<<r!   c                ^   \        VR V4      p\        P                  ! \        P                  \        P                  \        P                  \        P                  \        P
                  ! V4      \        P                  \        P
                  ! V4      4      p\        P                  ! RV4      # )r@   numba_ez_xxxevdrB   )rJ   r   wtyperL   s   &&  r   rq   _LAPACK.numba_ez_xxxevd   so    159jj.. %%&7==r!   c                    \         P                  ! \         P                  \         P                  \         P                  \         P                  ! V4      \         P                  4      p\         P
                  ! R V4      # )numba_xxpotrfrP   rQ   s   && r   ru   _LAPACK.numba_xxpotrf   sL    jj.	 %%os;;r!   c                   \        VR V4      p\        P                  ! \        P                  \        P                  \        P                  \        P                  \        P
                  ! V4      \        P                  \        P
                  ! V4      \        P
                  ! V4      \        P                  \        P
                  ! V4      \        P                  4      p\        P                  ! RV4      # )r@   numba_ez_gesddrB   )rJ   r   styperL   s   &&  r   rx   _LAPACK.numba_ez_gesdd   s    159jjJJJJJJJJNN5!JJNN5!NN5!JJNN5!JJ
 %%&6<<r!   c           
     &   \         P                  ! \         P                  \         P                  \         P                  \         P                  ! V4      \         P                  \         P                  ! V4      4      p\         P
                  ! R V4      # )numba_ez_geqrfrP   rQ   s   && r   r|   _LAPACK.numba_ez_geqrf   sZ    jjJJJJJJNN5!JJNN5!
 %%&6<<r!   c                D   \         P                  ! \         P                  \         P                  \         P                  \         P                  \         P                  ! V4      \         P                  \         P                  ! V4      4      p\         P
                  ! R V4      # )numba_ez_xxgqrrP   rQ   s   && r   r   _LAPACK.numba_ez_xxgqr   sa    jjJJJJJJJJNN5!JJNN5!
 %%&6<<r!   c                
   \        VR V4      p\        P                  ! \        P                  \        P                  \        P                  \        P                  \        P
                  ! V4      \        P                  \        P
                  ! V4      \        P                  \        P
                  ! V4      \        P                  \        P
                  ! \        P                  4      4      p\        P                  ! RV4      # )r@   numba_ez_gelsd)rC   r   rD   rE   rF   rG   float64rH   rI   s   &&  r   r   _LAPACK.numba_ez_gelsd   s    159jjJJJJJJJJNN5!JJNN5!JJNN5!MMNN5::&
 %%&6<<r!   c                v   \         P                  ! \         P                  \         P                  \         P                  \         P                  ! V4      \         P                  \         P                  ! \
        4      \         P                  ! V4      \         P                  4      p\         P                  ! R V4      # )numba_xgesvrd   rQ   s   && r   r   _LAPACK.numba_xgesv  sl    jjJJJJJJNN5!JJNN<(NN5!JJ	
 %%mS99r!   rS   N)rT   rU   rV   rW   rX   r=   rY   rc   rh   rk   rn   rq   ru   rx   r|   r   r   r   rZ   r[   r\   s   @r   r_   r_   s   s     
 < < ? ? = =  = = 
> 
> < < = =$ 	= 	= 
= 
= = =" : :r!   r_   c              #    "   . p. p. p\        VP                  V4       F  w  rx\        V\        P                  4      '       d   VP
                  R9   d   YxrM<VP                  RR7      p	\        W4      p\        WW34      p
VP                  W34       VP                  V	4       VP                  V
4       K  	  \        VP                  .VO5!  \        V4      3x  V F!  w  rxV P                  P                  WV4       K#  	  R# 5i)zs
Ensure that all array arguments are contiguous, if necessary by
copying them.
A new (sig, args) tuple is yielded.
CFClayoutN)zipargs
isinstancer   Arrayr   copyr   r   appendreturn_typetuplenrtdecref)r2   r3   rL   r   newtysnewargscopiesr4   r5   newtynewvalcopysigs   &&&&        r   make_contiguousr     s      FGFsxx&"ekk**bii4.?6GG3G'E*G'6BFMM5/*ev ' COO
-f
-uW~
==7, s   DDc                   a RoV3R lpV P                  W\        \        P                  \        P                  4      V34       R# )z&
Check whether *n* fits in a C `int`.
c                 ,   < V S8  d   \        R 4      hR# )z$array size too large to fit in C intN)OverflowError)n_maxints   &r   implcheck_c_int.<locals>.impl5  s    w; FGG r!   Ni)compile_internalr   r   nonerF   )r2   r3   r   r   r   s   &&& @r   check_c_intr   /  s9     GH W&uzz5::>Fr!   c                   VP                  \        P                  ! W4      RR7      ;_uu_ 4        V P                  V4      pVP	                  4        VP                  R4       RRR4       R#   + '       g   i     R# ; i)zO
Check the integer error return from one of the BLAS wrappers in
_helperlib.c.
Flikelyz#BLAS wrapper returned with an errorNif_thenr   is_not_nullget_python_api
gil_ensurefatal_errorr2   r3   respyapis   &&& r   check_blas_returnr   =  s]    
 
,,W:5	I	I&&w/?@	 
J	I	I	I   3A--A>	c                   VP                  \        P                  ! W4      RR7      ;_uu_ 4        V P                  V4      pVP	                  4        VP                  R4       RRR4       R#   + '       g   i     R# ; i)zQ
Check the integer error return from one of the LAPACK wrappers in
_helperlib.c.
Fr   z%LAPACK wrapper returned with an errorNr   r   s   &&& r   check_lapack_returnr   I  s]    
 
,,W:5	I	I&&w/AB	 
J	I	I	Ir   c                >   \         P                  ! \         P                  ! ^ 4      \        \        \        \
        \
        \
        .4      p\        P                  ! VP                  VR4      p	\        V4      p
\         P                  ! \        \        V
4      4      p\         P                  ! \        \        V4      4      pVP                  WW$VP                  V\
        4      VP                  V\
        4      VP                  V\
        4      34      p\        WV4       R# )zI
Call the BLAS vector * vector product function for the given arguments.
numba_xxdotN)r   FunctionTypeIntTypell_charintp_t	ll_void_pr   get_or_insert_functionmoduler    Constantordintcallbitcastr   )r2   r3   	conjugater   r   a_datab_dataout_datafntyfnr   kind_valr   s   &&&&&&&&     r   
call_xxdotr   U  s    
 ??2::b>#Wf%y)D 
	'	'm	LBD{{7CI.HGS^4I
,,ri#OOFI>#OOFI>#OOHi@B CC g,r!   c                   \         P                  ! \         P                  ! ^ 4      \        \        \        \        \
        \
        \        \
        \
        \
        .
4      p\        P                  ! VP                  VR4      p	VP                  p
\        WV
R4      p\        WV
R4      pVP                  R8X  d   Vw  rV^ ,          pMVw  rV^,          p\        V
4      p\         P                  ! \        \        V4      4      p\         P                  ! \        V'       d   \        R4      M
\        R4      4      pVP                  V	VVWVP!                  V\
        4      VP!                  V\
        4      VVP!                  V\
        4      VP!                  V\
        4      VP!                  V\
        4      3
4      p\#        WV4       R# )zI
Call the BLAS matrix * vector product function for the given arguments.
numba_xxgemv      ?        Ftr   N)r   r   r   r   r   r   r   r   r   r   r7   r   r    r   r   r   r   r   )r2   r3   do_transm_typem_shapesm_datav_datar   r   r   r   alphabetamr   ldar   r   transr   s   &&&&&&&&            r   call_xxgemvr   k  sO   
 ??2::b>#W"F%y&%y)D 
	'	'n	MBLLEw<Egs;D}}qkqkD{{7CI.HKKXS3s8DE
,,rHeQ#OOE9=#OOFI>#OOFI>#OOD)<#OOHi@B CC g,r!   c                  aaa!a" \         P                  ! \         P                  ! ^ 4      \        \        \        \        \        \        \
        \
        \        \
        \        \
        \
        \        .4      p\        P                  ! SP                  VR4      pVw  rVw  ppVP                  p\        V SVR4      p\        V SVR4      p\         P                  ! \        \        R4      4      o"\         P                  ! \        \        R4      4      o!VV!VV"3R lpV! WVV4      w  pppV! W#V4      w  pppV! SW4      w  ppp\        V4      p\         P                  ! \        \        V4      4      pSP                  VVVVVWSP                  V\
        4      VVVVSP                  V\
        4      VV34      p \!        V SV 4       R# )zI
Call the BLAS matrix * matrix product function for the given arguments.
rO   r   r   r   r   c                    < V P                   SP                   8X  d   SMSV P                   R 8X  d
   V^,          MV^ ,          SP                  V\        4      3# )r   )r   r   r   )r4   shapesdatar3   notransout_typer   s   &&&r   get_array_param$call_xxgemm.<locals>.get_array_param  sI     yyHOO3Gc)F1IvayOOD),
 	
r!   N)r   r   r   r   r   r   r   r   r   r   r7   r   r   r    r   r   r   )#r2   r3   x_typex_shapesx_datay_typey_shapesy_datar   
out_shapesr   r   r   r   k_kr   r   r   r   r   transar   data_atransbldbdata_b_ldcdata_cr   r   r   r   r   s#   &f&&&&&&f&&                      @@r   call_xxgemmr     sw    ??2::b>##W"FF%y&%vy%vD 
	'	'n	MBDAEBLLEw<Egws;DKKS*Ekk'3s8,G
 
 *&FCFC)&FCFC$XzDNAsFD{{7CI.H
,,rHffa#OOE9=vs"Cy)I"C) *C gw,r!   c                Z    R pV P                  WW#4      p\        WVP                  V4      # )z
np.dot(matrix, matrix)
c                     V P                   w  r#VP                   w  rEV^ 8X  d#   \        P                  ! W%3V P                  4      # \        P                  ! W%3V P                  4      p\        P
                  ! WV4      # r$   shapenpzerosr   emptydot)abr   r   r   r   outs   &&     r   dot_impldot_2_mm.<locals>.dot_impl  s]    ww688QFAGG,,hhvqww'vvaC  r!   r   r   r   r2   r3   rL   r   r  r   s   &&&&  r   dot_2_mmr	    .    ! 
"
"7c
@CGcoosCCr!   c                Z    R pV P                  WW#4      p\        WVP                  V4      # )z
np.dot(vector, matrix)
c                     V P                   w  pVP                   w  r4V^ 8X  d#   \        P                  ! V3V P                  4      # \        P                  ! V3V P                  4      p\        P
                  ! WV4      # r   r   )r  r  r   _mr   r  s   &&    r   r  dot_2_vm.<locals>.dot_impl  s]    WW688QE177++hhuagg&vvaC  r!   r  r  s   &&&&  r   dot_2_vmr    r
  r!   c                Z    R pV P                  WW#4      p\        WVP                  V4      # )z
np.dot(matrix, vector)
c                     V P                   w  r#VP                   w  pV^ 8X  d#   \        P                  ! V3V P                  4      # \        P                  ! V3V P                  4      p\        P
                  ! WV4      # r   r   )r  r  r   r   _nr  s   &&    r   r  dot_2_mv.<locals>.dot_impl  s]    wwgg688QE177++hhuagg&vvaC  r!   r  r  s   &&&&  r   dot_2_mvr    r
  r!   c           
        VP                   w  rVVP                  p\        V4      ! WV^ ,          4      p\        V4      ! WV^,          4      p	\        P                  ! WP
                  4      w  p
R pV P                  W\        \        P                  .VP                   O5!  V4       \        WV
4       \        P                  ! WP                  V4      4      p\        WWGWP                  V	P                  V4       VP                  V4      # )z0
np.dot(vector, vector)
np.vdot(vector, vector)
c                 `    V P                   w  pVP                   w  pW#8w  d   \        R 4      hR# )z;incompatible array sizes for np.dot(a, b) (vector * vector)Nr   
ValueError)r  r  r   r   s   &&  r   
check_argsdot_2_vv.<locals>.check_args  s4    WWWW6 1 2 2 r!   )r   r   r   r   unpack_tupler   r   r   r   r   r   alloca_onceget_value_typer   r   load)r2   r3   rL   r   r   atybtyr   r  r  r   r  r  s   &&&&&        r   dot_2_vvr!    s    
 xxHCOOE3$q'2A3$q'2A			gww	/BA2 W&uzz=CHH=tE!$


g'='=e'D
ECw1ffaffcJ<<r!   c                    \        RW4      # )z
np.dot(a, b)
znp.dot()
dot_2_implr  r  s   &&r   dot_2r&    s    
 j!''r!   c                    \        RW4      # )z
a @ b
z'@'r#  r%  s   &&r   matmul_2r(    s    
 eQ""r!   c                 B  a a \        V\        P                  4      '       d}   \        V\        P                  4      '       d[   \        V 3R  l4       oVP                  R9  g   VP                  R9  d$   \
        P                  ! S : RW3: 2\        4       V3R l# R# R# )c                   <a VP                   VP                   3oV3R  lpVP                  VP                  8w  d   \        RS,          4      hSR8X  d$   \        P                  ! VP                  ^R4      pMWSR8X  g   SR8X  d$   \        P                  ! VP                  ^R4      pM&SR8X  d   VP                  pM\        RS,          4      h\        WAV4      V3# )c                 l  < \        4        \        WW#4      ;_uu_ 4       w  r#SR8X  d   \        WW#4      uuRRR4       # SR8X  d   \        WW#4      uuRRR4       # SR8X  d   \	        WW#4      uuRRR4       # SR8X  d   \        WW#4      uuRRR4       # \        R4      h  + '       g   i     R# ; i)   Nunreachabler,  r,  r,     r0  r,  r0  r0  )r)   r   r	  r  r  r!  AssertionErrorr2   r3   rL   r   ndimss   &&&&r   _dot2_codegen0dot_2_impl.<locals>._impl.<locals>._dot2_codegen#  s    $WsAA[c'#D BA &'#D	 BA
 &'#D BA &'#D BA -];; BAAs#   B" B"B":B"B""B3	z)%s arguments must all have the same dtyper   z*%s: inputs must have compatible dimensionsr.  r/  r1  r2  )ndimr   r   r   r   r   )typingcontextr  r  r6  r   r5  names   &&&  @r   _impldot_2_impl.<locals>._impl  s    VVQVV$E< ww!''!!?$FH H #kk!''1c:&EVO#kk!''1c:&gg! $037#8 9 9[Q/>>r!   r   z+ is faster on contiguous arrays, called on c                    < S! W4      # r/   rS   )r  r  r;  s   &&r   <lambda>dot_2_impl.<locals>.<lambda>F  s	    E!Kr!   Nr   r   r   r   r   warningswarnr   )r:  r  r  r;  s   f&&@r   r$  r$    s}    !U[[!!jEKK&@&@		? 
	?B 8841884#7MM1&#$;= ('Q 'A!r!   c                4  a \        V \        P                  4      '       dw   \        V\        P                  4      '       dU   \        R 4       oV P                  R9  g   VP                  R9  d!   \
        P                  ! RW3: 2\        4       V3R l# R# R# )z
np.vdot(a, b)
c                     R  pVP                   ^8w  g   VP                   ^8w  d   \        R4      hVP                  VP                  8w  d   \        R4      h\        VP                  W4      V3# )c           
          \        4        \        WW#4      ;_uu_ 4       w  r#\        WW#R R7      uuRRR4       #   + '       g   i     R# ; i)T)r   N)r)   r   r!  )r2   r3   rL   r   s   &&&&r   codegen$vdot.<locals>._impl.<locals>.codegenQ  s5    $WsAA##Gc4P BAAAs	   :A	z&np.vdot() only supported on 1-D arraysz0np.vdot() arguments must all have the same dtype)r8  r   r   r   )r9  leftrightrF  s   &&& r   r;  vdot.<locals>._implO  sc    Q yyA~q!"JKKzzU[[(!FH HTZZ5w>>r!   r   4np.vdot() is faster on contiguous arrays, called on c                    < S! W4      # r/   rS   rH  rI  r;  s   &&r   r>  vdot.<locals>.<lambda>e  s
    5#5r!   Nr@  rM  s   &&@r   vdotrO  I  s{    
 $$$E5;;)G)G		? 
	?  ;;d"ell$&>MM=#$;= 65/ *H$r!   c                     V P                   w  pVP                   w  rEW48w  d   \        R 4      hVP                   V38w  d   \        R4      hR# )z;incompatible array sizes for np.dot(a, b) (vector * matrix)zFincompatible output array size for np.dot(a, b, out) (vector * matrix)Nr  )r  r  r  r   r  r   s   &&&   r   dot_3_vm_check_argsrQ  h  sV    	
BAGGEBw : ; 	;
yyQD ? @ 	@ r!   c                     V P                   w  r4VP                   w  pWT8w  d   \        R 4      hVP                   V38w  d   \        R4      hR# )z;incompatible array sizes for np.dot(a, b) (matrix * vector)zFincompatible output array size for np.dot(a, b, out) (matrix * vector)Nr  )r  r  r  r   r  r   s   &&&   r   dot_3_mv_check_argsrS  s  sV    GGEA	
BAw - . 	.
yyQD ? @ 	@ r!   c                T   VP                   w  rEpWbP                  8X  g   Q hVP                  p\        V4      ! WV^ ,          4      p\        V4      ! WV^,          4      p	\        V4      ! WV^,          4      p
\        P
                  ! WP                  4      p\        P
                  ! WP                  4      p\        P
                  ! WP                  4      pVP                  VP                  8  dE   TpTpV^ ,          pV^,          pVP                  R8H  pV	P                  VP                  pp\        pMCTpTpV^ ,          pV^ ,          pVP                  R8H  pVP                  V	P                  pp\        pV P                  VV\        \        P                  .VP                   O5!  V4       V F  p\!        WV4       K  	  V P#                  \        P$                  ^ 4      pVP'                  RVV4      pVP'                  RVV4      pVP)                  VV4      pVP+                  VRR7      ;_uu_ 4       w  ppV;_uu_ 4        \        P,                  ! WP                  VP/                  V
P0                  V
P2                  4      ^ 4       RRR4       V;_uu_ 4        \5        WVWVVV
P                  4       RRR4       RRR4       \7        WVP                  V
P9                  4       4      #   + '       g   i     Lj; i  + '       g   i     LP; i  + '       g   i     L[; i)z9
np.dot(vector, matrix, out)
np.dot(matrix, vector, out)
r   r   ==Fr   N)r   r   r   r   r   r  r   r8  r   r   rQ  rS  r   r   r   r   r   get_constantrF   icmp_signedor_if_elsememsetmulitemsizenitemsr   r   	_getvalue)r2   r3   rL   r   xtyytyouttyr   xyr  r   r   r   mtyr   v_shaper   r   r   r   r  r5   zero
both_emptymatrix_emptyis_emptyr   nonemptys   &&&&                         r   dot_3_vmrk  ~  sw   
 hhOCeOO###IIE3$q'2A3$q'2A
U
Gd1g
6C##GWW5H##GWW5H%%gyy9J
xx#(( 1+qk::$(
 1+qk::$(
Wj&uzz=CHH=tEGc*  

A.D$$T7D9J&&tS$7L{{:|4H	%	0	04EUHUNN7HH";;s||SZZ@!E  X(C6* 	 
1 Ws ]]_. . U X	 
1	0s=   :LAK1	L!L	<L1L<LLLL'	c                `
   VP                   w  rEpWbP                  8X  g   Q hVP                  p\        V4      ! WV^ ,          4      p\        V4      ! WV^,          4      p	\        V4      ! WV^,          4      p
\        P
                  ! WP                  4      p\        P
                  ! WP                  4      p\        P
                  ! WP                  4      pVw  rVw  ppVP                  R8X  g   Q hR pV P                  VV\        \        P                  .VP                   O5!  V4       \        WV4       \        WV4       \        WV4       VP                  pV	P                  pV
P                  pV P                  \        P                  ^ 4      pVP!                  RVV4      pVP!                  RVV4      pVP!                  RVV4      pVP#                  VVP#                  VV4      4      pVP%                  VRR7      ;_uu_ 4       w  ppV;_uu_ 4        \        P&                  ! WP                  VP)                  V
P*                  V
P,                  4      ^ 4       RRR4       T;_uu_ 4        V P                  \        P                  ^4      pVP!                  RVV4      pVP!                  RVV4      pVP%                  V4      ;_uu_ 4       w  p p!T ;_uu_ 4        VP%                  V4      ;_uu_ 4       w  p"p#V";_uu_ 4        \/        WRVVVVV4       RRR4       V#;_uu_ 4        VP                  VP                  8H  p$\1        WV$WKVVV4       RRR4       RRR4       RRR4       T!;_uu_ 4        VP%                  V4      ;_uu_ 4       w  p%p&V%;_uu_ 4        VP                  VP                  8g  p$\1        WV$W\VVV4       RRR4       V&;_uu_ 4        \3        WWKVW\VWmV4       RRR4       RRR4       RRR4       RRR4       RRR4       RRR4       \5        WVP                  V
P7                  4       4      #   + '       g   i     EL; i  + '       g   i     ELF; i  + '       g   i     EL; i  + '       g   i     EL*; i  + '       g   i     EL6; i  + '       g   i     L; i  + '       g   i     L; i  + '       g   i     L; i  + '       g   i     L; i  + '       g   i     L; i  + '       g   i     EL; i  + '       g   i     EL; i)z
np.dot(matrix, matrix, out)
r   c                     V P                   w  r4VP                   w  rVWE8w  d   \        R 4      hVP                   W638w  d   \        R4      hR# )z;incompatible array sizes for np.dot(a, b) (matrix * matrix)zFincompatible output array size for np.dot(a, b, out) (matrix * matrix)Nr  )r  r  r  r   r   r   r   s   &&&    r   r  dot_3_mm.<locals>.check_args  sW    ww7 1 2 299 C D D r!   rU  Fr   N)r   r   r   r   r   r  r   r   r   r   r   r   r   r   rV  rF   rW  rX  rY  rZ  r[  r\  r]  r   r   r   r   r^  )'r2   r3   rL   r   r_  r`  ra  r   rb  rc  r  r   r   r   r   r   r   r   r  r   r   r   rf  rg  x_emptyy_emptyri  r   rj  oneis_left_vecis_right_vecr_vecr_matv_vm_vr   v_mm_ms'   &&&&                                   r   dot_3_mmrz    s    hhOCeOO###IIE3$q'2A3$q'2A
U
Gd1g
6C##GWW5H##GWW5H%%gyy9JDAEB <<3D Wj&uzz=CHH=tE !$!$!$VVFVVFxxH 

A.D$$T1d3J!!$40G!!$40G{{:w{{7G'DEH	%	0	04EUHUNN7HH";;s||SZZ@!E  X &&uzz15C!--dAs;K"..tQ<L...5%U 55#s S&w'(&&(D ! !S'*zzU\\'AH'((+vvxQ ! 6  U 55#s S'*zzU\\'AH'((+vvxQ !
 !S'(+v(+v(-8E ! 6  / 	 
1L Ws ]]_. .K UU !SS !SS 655 UU !S
 !S 65 U /. XX	 
1	0	0s  TAQ	"T4A T	S5"R<R
QR.*Q-R R(S5:S"S"*R)SR<0S8S" S5T	TQ	TQ*$	R-Q>8	RR	RR& 	S5)R94S<SSSS""S2-S55T T	T	TT-	c                  a \        V \        P                  4      '       d   \        V\        P                  4      '       d   \        V\        P                  4      '       df   \        R 4       oV P                  R9  g#   VP                  R9  g   VP                  R9  d!   \
        P                  ! RW3: 2\        4       V3R l# R# R# R# )z
np.dot(a, b, out)
c                     R  pVP                   VP                   8w  g   VP                   VP                   8w  d   \        R4      h\        W1W#4      V3# )c                 D   \        4        \        WW#4      ;_uu_ 4       w  pp\        R  VP                  R,           4       4      pV^08X  d   \	        WW#4      uuRRR4       # V^^08X  d   \        WW#4      uuRRR4       # \        R4      h  + '       g   i     R# ; i)c              3   8   "   T F  qP                   x  K  	  R # 5ir/   r8  ).0rb  s   & r   	<genexpr>8dot_3.<locals>._impl.<locals>.codegen.<locals>.<genexpr>  s     =1s   :Nr,  NNr-  )r)   r   setr   rz  rk  r3  r4  s   &&&& r   rF  %dot_3.<locals>._impl.<locals>.codegen  s    $WsAA FLcFJ===E|'#D	 BA
 1a&'#D BA -];; BAAs   :B$BBB	z/np.dot() arguments must all have the same dtype)r   r   r   )r9  r  r  r  rF  s   &&&& r   r;  dot_3.<locals>._impl  sN    < ww!''!QWW		%9!EG G SQ,g55r!   r   rK  c                    < S! WV4      # r/   rS   r  r  r  r;  s   &&&r   r>  dot_3.<locals>.<lambda>1  s    qS!1r!   Nr@  r  s   &&&@r   dot_3r    s    
 	1ekk""z!U[['A'AsEKK((		6 
	6& 8841884#73::<MM646 217 ) (B"r!   numba_fatal_errorc                     \         P                  ! V 4       FL  p\         P                  ! VP                  4       4      '       d   K/  \         P                  P                  R 4      h	  R# )z$Array must not contain infs or NaNs.N)r   nditerisfiniteitemlinalgLinAlgError)r  vs   & r   _check_finite_matrixr  7  sC    YYq\{{1668$$))''68 8 r!   c                    V'       d   R MRpW13p\        V \        P                  4      '       d   V P                  p \        V \        P                  4      '       g   RV,          p\        VRR7      hV P                  ^8X  g   RV,          p\        VRR7      h\        V P                  \        P                  \        P                  34      '       g   RV,          p\        VRR7      hR# )	np.linalgr   z&%s.%s() only supported for array typesFhighlightingz%%s.%s() only supported on 2-D arrays.3%s.%s() only supported on float and complex arrays.N)
r   r   Optionaltyper   r   r8  r   FloatComplex)r  r   	la_prefixprefixinterpmsgs   &&&   r   _check_linalg_matrixr  ?  s     &[4F F!U^^$$FFa%%6?#E2266Q;5>#E22aggU]];<<(*01#E22 =r!   c                     V^ ,          P                   pVR,           F*  pVP                   V8w  g   K  RV ,          p\        VRR7      h	  R# )r$   :r0  NNzAnp.linalg.%s() only supports inputs that have homogeneous dtypes.Fr  N)r   r   )r   r   t0r   r  s   &*   r   _check_homogeneous_typesr  T  sB    	qB2YY77b=UXaaCc66 r!   c                      R # r/   rS   rS   r!   r   _copy_to_fortran_orderr  \  s    r!   c                 T   aa V P                   R 8H  oV P                   R8H  oVV3R lpV# )r   Ac                 J  < S'       d   \         P                  ! V 4      pV# S'       dd   V P                  P                  pV'       d-   \         P                  ! V P                  4      P                  pV# \         P
                  ! V 4      p V# \         P
                  ! V 4      pV# r/   )r   r   flagsf_contiguousTasfortranarray)r  acpyflag_fA_layoutF_layouts   &  r   r   &ol_copy_to_fortran_order.<locals>.implf  s    771:D  WW))F wwqss|~~ 	 ((+  $$Q'Dr!   r   )r  r   r  r  s   & @@r   ol_copy_to_fortran_orderr  `  s+     xx3Hxx3H& Kr!   c                     V ^ 8w  d<   V ^ 8  d   \        4        Q hV ^ 8  d    \        P                  P                  R4      hR# R# )r$   z(Matrix is singular to machine precision.N)fatal_error_funcr   r  r  rs   &r   _inv_err_handlerr  |  sF    Avq51q5))'':< < 	 r!   c                    V ^ ,          # )zFpass a list of variables to be preserved through dead code eliminationrS   r  s   &r   _dummy_liveness_funcr    s     Q4Kr!   c                   aaa \        4        \        V R 4       \        4       P                  V P                  4      o\        4       P                  V P                  4      o\        \        V P                  R 4      4      oVVV3R lpV# )invc                   < V P                   R,          pV P                   R,          V8w  d"   Rp\        P                  P                  V4      h\	        V 4       \        V 4      pV^ 8X  d   V# \        P                  ! V\        R7      pS! SWVP                  WP                  4      p\        V4       S! SWP                  WP                  4      p\        V4       \        VP                  VP                  .4       V# r0  .Last 2 dimensions of the array must be square.r   )r   r   r  r  r  r  r   F_INT_nptypectypesr  r  size)	r  r   r  r  ipivr  r   rc   numba_xxgetris	   &     r   inv_implinv_impl.<locals>.inv_impl  s    GGBK772;!BC))'',,Q%a(6Kxx.$dkk1kkB$;;;;? 	dii34r!   )r-   r  r_   rc   r   rh   r   r    )r  r  r   rc   r  s   & @@@r   r  r    s_    OE"I++AGG4MI..qww7M}QWWe,-D2 Or!   c                 b    V ^ 8w  d(   V ^ 8  d   \        4        Q hV ^ 8  d   \        R4      hR# R# )r$   z&Internal algorithm failed to converge.N)r  r  r  s   &r   %_handle_err_maybe_convergence_problemr    s8    Avq51q5EFF 	 r!   c                 f   V'       d   R MRpW13p\        V \        P                  4      '       g   \        RV,          4      hV P                  ^8:  g   \        RV,          4      h\        V P
                  \        P                  \        P                  34      '       g   \        RV,          4      hR# )r  r   z'%s.%s() only supported for array types +%s.%s() only supported on 1 and 2-D arrays r  N)r   r   r   r   r8  r   r  r  r  r   r  r  r  s   &&&  r   _check_linalg_1_or_2d_matrixr    s     &[4F Fa%%C"# $ 	$66Q;G"# $ 	$aggU]];<< 68>? @ 	@ =r!   c                    aaa \        4        \        V R 4       \        4       P                  V P                  4      o\        \        V P                  R 4      4      o\        R4      o\        R4      pVVV3R lpV# )choleskyULc                   < V P                   R,          pV P                   R,          V8w  d"   Rp\        P                  P                  V4      hV P	                  4       pV^ 8X  d   V# S! SSWP
                  V4      pV^ 8w  d:   V^ 8  d   \        4        Q hV^ 8  d    \        P                  P                  R4      h\        V4       F  p^ VRV1V3&   K  	  V# )r0  r  z Matrix is not positive definite.Nr  r  )r   r   r  r  r   r  r  range)	r  r   r  r  r  colUPr   ru   s	   &     r   cho_implcho_impl.<locals>.cho_impl  s    GGBK772;!BC))'',, ffh6J $Azz1561u "q1uii++68 8 8CCc	N 
r!   )r-   r  r_   ru   r   r   r    )r  LOr  r  r   ru   s   &  @@@r   r  r    s[    OJ'I++AGG4M}QWWj12D	SB	SB< Or!   c                   aaaaa \        4        \        V R 4       \        4       P                  V P                  4      o\        4       P                  V P                  4      o\        \        V P                  R 4      4      o\        R4      o\        R4      oVVVV3R lpVVVV3R lp\        V P                  \        P                  P                  4      '       d   V# V# )eigNVc                  < V P                   R,          pV P                   R,          V8w  d"   Rp\        P                  P                  V4      h\	        V 4       \        V 4      p^pTp\        P                  ! WP                  R7      p\        P                  ! WP                  R7      p\        P                  ! W3V P                  R7      p\        P                  ! W3V P                  R7      p	V^ 8X  d   WiP                  3# S! SSSVVP                  VVP                  VP                  VP                  VV	P                  V4      p
\        V
4       \        P                  ! V4      '       d   \        R4      h\        VP                  VP                  V	P                  VP                  VP                  .4       WiP                  3# )z'
eig() implementation for real arrays.
r  r  z.eig() argument must not cause a domain change.r  r  )r   r   r  r  r  r  r   r   r  r  r  anyr  r  r  r  r   r  r  ldvlldvrwrwivlvrr  JOBVLJOBVRr   rk   s   &          r   real_eig_impleig_impl.<locals>.real_eig_impl
  s\    GGBK772;!BC))'',,Q%a(XXaww'XXaww'XXqiqww/XXqiqww/6:4!! KKIIIIII II " 	.a0 66"::@B B
 	dii"''277BGGLMDDzr!   c                  < V P                   R,          pV P                   R,          V8w  d"   Rp\        P                  P                  V4      h\	        V 4       \        V 4      p^pTp\        P                  ! WP                  R7      p\        P                  ! W3V P                  R7      p\        P                  ! W3V P                  R7      pV^ 8X  d   WhP                  3# S! SS
SVVP                  VVP                  VP                  VVP                  V4      p	\        V	4       \        VP                  VP                  VP                  VP                  .4       WhP                  3# )z*
eig() implementation for complex arrays.
r  r  r  r  )r   r   r  r  r  r  r   r   r  r  r  r  r  r  r   r  r  r  r  wr  r  r  r  r  r   rn   s   &         r   cmplx_eig_impl eig_impl.<locals>.cmplx_eig_implB  s    GGBK772;!BC))'',,Q%a(HHQgg&XXqiqww/XXqiqww/6tt94!! KKHHII II 
" 	.a0 	dii"''166BC44yr!   r-   r  r_   rk   r   rn   r   r    r   r   scalarsr  )r  r  r  r  r  r   rn   rk   s   &  @@@@@r   eig_implr    s    OE"Y--agg6NY--agg6N}QWWe,-DHEHE6 6p& &P !''5==0011r!   c                   aaaaa \        4        \        V R 4       \        4       P                  V P                  4      o\        4       P                  V P                  4      o\        \        V P                  R 4      4      o\        R4      o\        R4      oVVVV3R lpVVVV3R lp\        V P                  \        P                  P                  4      '       d   V# V# )eigvalsr  c                d  < V P                   R,          pV P                   R,          V8w  d"   Rp\        P                  P                  V4      h\	        V 4       \        V 4      p^p^p\        P                  ! WP                  R7      pV^ 8X  d   V# \        P                  ! WP                  R7      p\        P                  ! ^V P                  R7      p\        P                  ! ^V P                  R7      p	S! SSSVVP                  VVP                  VP                  VP                  VV	P                  V4      p
\        V
4       \        P                  ! V4      '       d   \        R4      h\        VP                  VP                  V	P                  VP                  VP                  .4       V# )z+
eigvals() implementation for real arrays.
r  r  z2eigvals() argument must not cause a domain change.r  r  )r   r   r  r  r  r  r   r   r  r  r  r  r  r  r  s   &          r   real_eigvals_impl'eigvals_impl.<locals>.real_eigvals_impl}  sL    GGBK772;!BC))'',,Q%a(XXaww'6IXXaww' XXq)XXq)4!! KKIIIIII II " 	.a0 66"::DF F
 	dii"''277BGGLM	r!   c                  < V P                   R,          pV P                   R,          V8w  d"   Rp\        P                  P                  V4      h\	        V 4       \        V 4      p^p^p\        P                  ! WP                  R7      pV^ 8X  d   V# \        P                  ! ^V P                  R7      p\        P                  ! ^V P                  R7      pS! SS
SVVP                  VVP                  VP                  VVP                  V4      p	\        V	4       \        VP                  VP                  VP                  VP                  .4       V# )z.
eigvals() implementation for complex arrays.
r  r  r  r  )r   r   r  r  r  r  r   r   r  r  r  r  r  s   &         r   cmplx_eigvals_impl(eigvals_impl.<locals>.cmplx_eigvals_impl  s
    GGBK772;!BC))'',,Q%a(HHQgg&6HXXq)XXq)4!! KKHHII II 
" 	.a0 	dii"''166BCr!   r  )r  r  r  r  r  r   rn   rk   s   &  @@@@@r   eigvals_implr  o  s    OI&Y--agg6NY--agg6N}QWWi01DHEHE9 9v' 'R !''5==0011!!  r!   c                 n  aaaaa \        4        \        V R 4       \        V P                  RV P                  4      p\        P
                  ! V4      o\        4       P                  V P                  4      o\        \        V P                  R 4      4      o\        R4      o\        R4      oVVVVV3R lpV# )eighr@   r  r  c           	        < V P                   R,          pV P                   R,          V8w  d"   Rp\        P                  P                  V4      h\	        V 4       \        V 4      p\        P                  ! VS
R7      pV^ 8X  d   WC3# S	! SSSVVP                  VVP                  4      p\        V4       \        VP                  VP                  .4       WC3# r  r   r   r  r  r  r  r   r  r  r  r  r  r   r  r  r  r  JOBZUPLOr   rq   w_dtypes   &     r   	eigh_impleigh_impl.<locals>.eigh_impl  s    GGBK772;!BC))'',,Q%a(HHQg&69D   KKHH 	.a0 	dii01yr!   
r-   r  rC   r   
np_supportas_dtyper_   rq   r   r    )r  w_typer  r  r  r   rq   r  s   &  @@@@@r   r  r    s    OF# QWW0!'':F!!&)Gi//8O}QWWf-.Ds8Ds8D < r!   c                 n  aaaaa \        4        \        V R 4       \        V P                  RV P                  4      p\        P
                  ! V4      o\        4       P                  V P                  4      o\        \        V P                  R 4      4      o\        R4      o\        R4      oVVVVV3R lpV# )eigvalshr@   r  r  c           	        < V P                   R,          pV P                   R,          V8w  d"   Rp\        P                  P                  V4      h\	        V 4       \        V 4      p\        P                  ! VS
R7      pV^ 8X  d   V# S	! SSSVVP                  VVP                  4      p\        V4       \        VP                  VP                  .4       V# r  r   r  s   &     r   eigvalsh_impl$eigvalsh_impl.<locals>.eigvalsh_impl(  s    GGBK772;!BC))'',,Q%a(HHQg&6HD   KKHH 	.a0 	dii01r!   r  )r  r
  r  r  r  r   rq   r  s   &  @@@@@r   r  r    s    OJ' QWW0!'':F!!&)Gi//8O}QWWj12Ds8Ds8D < r!   c                 r  aaaaa \        4        \        V R 4       \        V P                  RV P                  4      p\        P
                  ! V4      o\        4       P                  V P                  4      o\        \        V P                  R 4      4      o\        R4      o\        R4      oRVVVVV3R llpV# )svdr@   r  Sc                   < V P                   R,          pV P                   R,          pV^ 8X  g   V^ 8X  d    \        P                  P                  R4      h\	        V 4       \        V 4      pTp\        W24      pV'       d   SpTpTp	MSpTpTp	\        P                  ! W3V P                  R7      p
\        P                  ! VSR7      p\        P                  ! W)3V P                  R7      pS! SVVVVP                  VVP                  V
P                  VVP                  V	4      p\        V4       \        VP                  VP                  V
P                  VP                  .4       V
P                  WP                  3# )r0  Arrays cannot be emptyr  r  r  )r   r   r  r  r  r  minr   r   r  r  r  r  r  )r  full_matricesr   r   r  lduminmnr  ucolldvtur   vtr  JOBZ_AJOBZ_Sr   rx   s_dtypes   &&            r   svd_implsvd_impl.<locals>.svd_implY  s7   GGBKGGBK6Q!V))''(@AAQ%a(A	DDDDDDHHd[0HHU'*XXqiqww/KKHHHHII
 	.a0 	dii!&&!&&ABQ~r!   r0  )
r-   r  rC   r   r  r	  r_   rx   r   r    )	r  r  s_typer   r  r  r   rx   r  s	   &&  @@@@@r   r   r   H  s    OE" QWW0!'':F!!&)GY--agg6N}QWWe,-DXFXF, ,\ Or!   c                   aaa \        4        \        V R 4       \        4       P                  V P                  4      o\        4       P                  V P                  4      o\        \        V P                  R 4      4      oVVV3R lpV# )qrc           	        < V P                   R,          pV P                   R,          pV^ 8X  g   V^ 8X  d    \        P                  P                  R4      h\	        V 4       \        V 4      pTp\        W!4      p\        P                  ! WPP                  R7      pS! SVVVP                  VVP                  4      pV^ 8  d   \        4        Q h\        P                  ! W3V P                  R7      P                  p\        V4       F*  p	\        V	^,           4       F  p
W:V	3,          WV	3&   K  	  K,  	  \        WQ4       F#  p	\        V4       F  p
W:V	3,          WV	3&   K  	  K%  	  S! SVVVVP                  VVP                  4      p\        V4       \        VP                   VP                   .4       VRRV13,          V3# )r0  r  r  NNNNr  r  )r   r   r  r  r  r  r  r   r   r  r  r   r  r  r  r  r  )r  r   r   qr   r  tauretr  ijr   r|   r   s   &          r   qr_implqr_impl.<locals>.qr_impl  s   GGBKGGBK6Q!V))''(@AAQ #1%A	hhgg.HHJJ
 71 HHaZqww/11 uA1q5\qD'Q$ " 
 uA5\qD'Q$ " ! HHJJ
 	.c2 	chh/0!VeV)a  r!   )r-   r  r_   r|   r   r   r   r    )r  r-  r   r|   r   s   & @@@r   r-  r-    sb    OD! Y--agg6NY--agg6N}QWWd+,D7!r Nr!   c                    \         h)z3
Correctly copy 'b' into the 'bcpy' scratch space.
NotImplementedErrorbcpyr  nrhss   &&&r   _system_copy_in_br5    
     r!   c                 8    VP                   ^8X  d   R pV# R pV# )r0  c                 8    WR VP                   R,          1^ 3&   R # )Nr  r   r2  s   &&&r   	oneD_impl)_system_copy_in_b_impl.<locals>.oneD_impl  s    $%!''"+q!r!   c                 <    WR VP                   R,          1R V13&   R # )Nr  r9  r2  s   &&&r   	twoD_impl)_system_copy_in_b_impl.<locals>.twoD_impl  s    ()!''"+uu$%r!   r  )r3  r  r4  r:  r=  s   &&&  r   _system_copy_in_b_implr?    s#    vv{	&	*r!   c                    \         h)zC
Compute the number of right hand sides in the system of equations
r0  r  s   &r   _system_compute_nrhsrB    r6  r!   c                 8    V P                   ^8X  d   R pV# R pV# )r0  c                     ^# r"  rS   rA  s   &r   r:  ,_system_compute_nrhs_impl.<locals>.oneD_impl  s    r!   c                 (    V P                   R,          # r0  r  r9  rA  s   &r   r=  ,_system_compute_nrhs_impl.<locals>.twoD_impl  s    772;r!   r  )r  r:  r=  s   &  r   _system_compute_nrhs_implrI    s#    vv{		r!   c                    \         h)z<
Check that AX=B style system input is dimensionally valid.
r0  r%  s   &&r   !_system_check_dimensionally_validrK    r6  r!   c                 <    VP                   pV^8X  d   R pV# R pV# )r0  c                     V P                   R,          pVP                   R,          pW#8w  d    \        P                  P                  R4      hR# )r,  <Incompatible array sizes, system is not dimensionally valid.Nr  r  r   r   r  r  r  r  ambms   &&  r   r:  9_system_check_dimensionally_valid_impl.<locals>.oneD_impl  B    BBxii++RT T r!   c                     V P                   R,          pVP                   R,          pW#8w  d    \        P                  P                  R4      hR# )r,  rN  Nr  rO  rP  s   &&  r   r=  9_system_check_dimensionally_valid_impl.<locals>.twoD_impl  rT  r!   r  r  r  r8  r:  r=  s   &&   r   &_system_check_dimensionally_valid_implrX    s.    66Dqy	T 	T r!   c                    \         h)z2
Check that AX=B style system input is not empty.
r0  r%  s   &&r   _system_check_non_emptyrZ    r6  r!   c                 <    VP                   pV^8X  d   R pV# R pV# )r0  c                     V P                   R,          pV P                   R,          pVP                   R,          pV^ 8X  g   V^ 8X  g   V^ 8X  d    \        P                  P                  R4      hR# r,  r  Nr  r  rO  )r  r  rQ  anrR  s   &&   r   r:  /_system_check_non_empty_impl.<locals>.oneD_impl(  sW    BBBQw"'R1Wii++,DEE &-r!   c                    V P                   R,          pV P                   R,          pVP                   R,          pVP                   R,          pV^ 8X  g   V^ 8X  g   V^ 8X  g   V^ 8X  d    \        P                  P                  R4      hR# r]  rO  )r  r  rQ  r^  rR  bns   &&    r   r=  /_system_check_non_empty_impl.<locals>.twoD_impl0  sj    BBBBQw"'R1Waii++,DEE 18r!   r  rW  s   &&   r   _system_check_non_empty_implrc  $  s.    66Dqy	F 	F r!   c                    \         h)z2
Compute the residual from the 'b' scratch space.
r0  )r  r   r4  s   &&&r   _lstsq_residualre  :  r6  r!   c                 V  a V P                   pV P                  p\        P                  ! \	        VR V4      4      oV^8X  d1   \        V\        P                  4      '       d	   V3R lpV# V3R lpV# V^8X  g   Q h\        V\        P                  4      '       d	   V3R lpV# V3R lpV# )r@   c                    < \         P                  ! RSR7      p\         P                  ! \         P                  ! WR1^ 3,          4      ^,          4      V^ &   V# r0  r  Nr"  )r   r   sumabsr  r   r4  r   
real_dtypes   &&& r   
cmplx_impl(_lstsq_residual_impl.<locals>.cmplx_implI  s@    hht:6qQx 0! 34A
r!   c                    < \         P                  ! RSR7      p\         P                  ! WR1^ 3,          ^,          4      V^ &   V# rh  )r   r   ri  rk  s   &&& r   	real_impl'_lstsq_residual_impl.<locals>.real_implO  s6    hht:6"a%!,A
r!   c                    < \         P                  ! VSR 7      p\        V4       F@  p\         P                  ! \         P                  ! WR1V3,          4      ^,          4      W4&   KB  	  V# r  N)r   r   r  ri  rj  r  r   r4  r   r   rl  s   &&&  r   rm  rn  W  sL    hhZ8tAVVBFF1RU8$4a$78CF %
r!   c                    < \         P                  ! VSR 7      p\        V4       F,  p\         P                  ! WR1V3,          ^,          4      W4&   K.  	  V# rs  )r   r   r  ri  rt  s   &&&  r   rp  rq  ^  sB    hhZ8tAVVAb!eHaK0CF %
r!   )r8  r   r  r	  rC   r   r   r  )r  r   r4  r8  r   rm  rp  rl  s   &&&    @r   _lstsq_residual_implrv  A  s    66DGGE$$WU4F%NOJqyeemm--  qyyeemm--
 
 r!   c                    \         h)z~
Extract 'x' (the lstsq solution) from the 'bcpy' scratch space.
Note 'b' is only used to check the system input dimension...
r0  r  r3  r   s   &&&r   _lstsq_solutionry  f  
    
 r!   c                 8    V P                   ^8X  d   R pV# R pV# )r0  c                 <    VP                   P                  4       R V # r/   r  ravelrx  s   &&&r   r:  '_lstsq_solution_impl.<locals>.oneD_implq  s    66<<>"1%%r!   c                 8    VR V1R3,          P                  4       # )Nr'  r   rx  s   &&&r   r=  '_lstsq_solution_impl.<locals>.twoD_implu  s    A;##%%r!   r  )r  r3  r   r:  r=  s   &&&  r   _lstsq_solution_implr  n  s#    vv{	&	&r!   c                   aaaa	 \        4        \        V R 4       \        VR 4       \        R W4       \        P
                  ! V P                  4      oV P                  p\        VRV4      p\        P
                  ! V4      o	\        4       P                  V P                  4      o\        \        VR 4      4      oRVVVV	3R llpV# )lstsqr@   c                 l  < V P                   R,          pV P                   R,          p\        V4      p\        V 4       \        V4       \        W4       \	        W4       \        WC4      p\        WC4      p\        V 4      p\        P                  ! WW3SR7      P                  p	\        WV4       \        P                  ! VSR7      p
\        P                  ! ^\        P                  R7      pS! SVVVVP                  VV	P                  VV
P                  VVP                  4      p\        V4       V^ ,          pW8  g   WC8:  d   \        P                  ! ^ SR7      pM\        WV4      p\!        WV4      p\#        VP$                  V	P$                  V
P$                  VP$                  .4       WWRV 3# )r0  r  Nr  r  )r   rB  r  rZ  rK  r  maxr  r   r   r  r5  int32r  r  re  ry  r  r  )r  r  rcondr   r   r4  r  maxmnr  r3  r   rank_ptrr  rankr   rb  r   np_dtr   rl  s   &&&             r   
lstsq_impllstsq_impl.<locals>.lstsq_impl  sp   GGBKGGBK#A& 	QQ 	 % 	*!/A	A	 &a( xxU355$4( HHU*-88ARXX.KKKKHHOO
 	.a0 { 8qv((Aj1C "$40C AQ' 	diiAFFHMMJKi((r!   g      )r-   r  r  r  r  r	  r   rC   r_   r   r   r    )
r  r  r  nb_dtr_typer  r   r  r   rl  s
   &&&   @@@@r   r  r  z  s    OG$ !G,Wa+(EGGE U.6F$$V,J Y--agg6N}UG,-D=) =)~ r!   c                    \         h)zx
Extract 'x' (the solution) from the 'bcpy' scratch space.
Note 'b' is only used to check the system input dimension...
r0  r  r3  s   &&r   _solve_compute_returnr    rz  r!   c                 8    V P                   ^8X  d   R pV# R pV# )r0  c                 6    VP                   P                  4       # r/   r}  r  s   &&r   r:  -_solve_compute_return_impl.<locals>.oneD_impl  s    66<<>!r!   c                     V# r/   rS   r  s   &&r   r=  -_solve_compute_return_impl.<locals>.twoD_impl  s    Kr!   r  )r  r3  r:  r=  s   &&  r   _solve_compute_return_implr    s#    vv{	"	r!   c                 @  aaa \        4        \        V R 4       \        VR 4       \        R W4       \        P
                  ! V P                  4      oV P                  p\        4       P                  V P                  4      o\        \        VR 4      4      oVVV3R lpV# )solvec           
      0  < V P                   R,          p\        V4      p\        V 4       \        V4       \        W4       \	        V 4      p\
        P                  ! W23S	R7      P                  pV^ 8X  d   \        W4      # \        WQV4       \
        P                  ! V\        R7      pS
! SVVVP                  VVP                  VP                  V4      p\        V4       \        VP                  VP                  VP                  .4       \        W4      # )r0  r  r  )r   rB  r  rK  r  r   r   r  r  r5  r  r  r  r  r  )r  r  r   r4  r  r3  r  r  r   r  r   s   &&      r   
solve_implsolve_impl.<locals>.solve_impl  s    GGBK#A& 	QQ 	*!/ &a( xx	/116(11 	$4( xx.KKKKKK	
 	 	diiDII>?$Q--r!   )r-   r  r  r  r  r	  r   r_   r   r   r    )r  r  r  r  r   r  r   s   &&  @@@r   r  r    sz    OG$ G,Wa+(EGGE )''0K}UG,-D'.R r!   c           
        aaaaa	a
aaa \        4        \        V R 4       \        V P                  RV P                  4      p\        P
                  ! V4      o\        4       P                  V P                  4      o	\        4       P                  V P                  4      o
\        \        V P                  R 4      4      o\        R4      o\        R4      o\        R4      o\        P
                  ! V P                  4      p\        P                  ! R.VR7      o\        P                  ! R.VR7      oRVVVVV	V
VVV3	R llpV# )	pinvr@   r  r   r   r  r   c                   <	 V P                   R,          pV P                   R,          p\        V 4       \        V 4      pV^ 8X  g   V^ 8X  d>   VP                  P	                  4       P                  V P                   4      P                  # \        W24      p\        P                  ! WS3V P                  R7      p\        P                  ! VSR7      p\        P                  ! W%3V P                  R7      pS! SSVVVP                  VVP                  VP                  VVP                  V4      p	\        V	4       V^ ,          V,          p
^ p\        V4       F%  pW|,          V
8  g   K  RW|,          ,          W|&   TpK'  	  V^,          pW28  dA   \        V4       F0  p\        V4       F  pWV3,          W~,          ,          WV3&   K   	  K2  	  MA\        V4       F2  pW},          p\        V4       F  pWmV3,          V,          WmV3&   K  	  K4  	  S! SSSVVVSP                  VP                  VVP                  VSP                  VP                  V4      p	\        VP                  VP                  VP                  VP                  SP                  SP                  .4       VP                  P	                  4       P                  V P                   4      P                  # )r0  r  r   r  r  )r   r  r  r  r~  reshaper  r   r   r   r  r  r  r  r  )r  r  r   r   r  r  r  r   r  r  cut_atcut_idxr   r+  r,  s_localJOBTRANSATRANSBr   rx   rO   rq  r  rf  s   &&              r   	pinv_implpinv_impl.<locals>.pinv_implD  sN   N GGBKGGBKQ%a(6Q!V66<<>))!''2444A	HHeZqww/HHU'*XXqj0KKHHHHII
 	.a0 1uAtf}ADy  	1 61XwA!Q$x!$B!tH ( 
 7^$uA1g/AdG & $ JJIIHHKKKK
0 	dii!&&!&&#((II 	vv||~%%agg.000r!   gV瞯<)r-   r  rC   r   r  r	  r_   rx   r9   rO   r   r    r   array)r  r  r#  dtr  r  r  r  r   rx   rO   rq  r  rf  s   &&   @@@@@@@@@r   r  r  *  s    OF# QWW0!'':F!!&)GY--agg6N7''0L}QWWf-.D
c(C XFXF 
		QWW	%B88RD#D
((B4r
"CE1 E1N r!   c                    \        V P                  \        P                  4      '       d   \        R 4       pV# \        R 4       pV# )z
Walks the diag of a LUP decomposed matrix
uses that det(A) = prod(diag(lup(A)))
and also that log(a)+log(b) = log(a*b)
The return sign is adjusted based on the values found
such that the log(value) stays in the real domain.
c                     VR ,           pRp\        V 4       FU  p\        P                  ! WV3,          4      pW1WU3,          V,          ,          pV\        P                  ! V4      ,           pKW  	  W43# )y                r   )r  r   rj  log)r   r  sgncsgnaccr   absels   &&&    r   cmplx_diag_walker3_get_slogdet_diag_walker.<locals>.cmplx_diag_walker  sa     9DC1XqAww/BFF5M)  ;r!   c                     R p\        V 4       F7  pWV3,          pVR 8  d   V) pV) pV\        P                  ! V4      ,           pK9  	  VR ,           V3# r   )r  r   r  )r   r  r  r  r   r  s   &&&   r   real_diag_walker2_get_slogdet_diag_walker.<locals>.real_diag_walker  sX     C1XdGr6$CABFF1Io  "Hc?"r!   )r   r   r   r  r
   )r  r  r  s   &  r   _get_slogdet_diag_walkerr    sM     !''5==))		 
	 ! 	
	# 

	#  r!   c                 Z  aaaaa \        4        \        V R 4       \        4       P                  V P                  4      o\        \        V P                  R 4      4      o\        V 4      oV P	                  ^4      o\        V P                  RV P                  4      ! ^ 4      oVVVVV3R lpV# )slogdetr@   c                 Z  < V P                   R,          pV P                   R,          V8w  d"   Rp\        P                  P                  V4      hV^ 8X  d   SS	3# \	        V 4       \        V 4      p\        P                  ! V\        R7      pS! SWVP                  WP                  4      pV^ 8  d   R\        P                  ) 3# \        V4       ^p\        V4       F  pWdV,          V^,           8g  ,           pK  	  V^,          pV^ 8X  d   Rp\        VP                  .4       S
! WV4      # )r0  r  r  r   r  r  )r   r   r  r  r  r  r   r  r  infr  r  r  r  )r  r   r  r  r  r  r  r   ONEZEROdiag_walkerr   rc   s   &       r   slogdet_impl"slogdet_impl.<locals>.slogdet_impl  s   GGBK772;!BC))'',,6;Q%a(xx.$dkk1kkBq5=  qAaQU+,C  Ag!8C 	dii[)1C((r!   )	r-   r  r_   rc   r   r   r    r  rC   )r  r  r  r  r  r   rc   s   & @@@@@r   r  r    s    OI&I++AGG4M}QWWi01D*1-K
''!*C177.8;D') ')R r!   c                 8    \        4        \        V R 4       R pV# )detc                 ~    \         P                  P                  V 4      w  rV\         P                  ! V4      ,          # r/   )r   r  r  exp)r  r  r  s   &  r   det_impldet_impl.<locals>.det_impl4  s+    **1-RVVG_$$r!   r-   r  )r  r  s   & r   r  r  -  s     OE"% Or!   c                    \         h)z!
Compute singular values of *a*.
r0  r  s   &r   _compute_singular_valuesr  ;  r6  r!   c                  aaaaaa	 \        4       P                  V P                  4      o\        \	        V P                  R4      4      o\        R4      o\        V P                  RV P                  4      p\        P                  ! V4      o\        P                  ! V P                  4      p\        P                  ! RVR7      o\        P                  ! RVR7      o	VVVVVV	3R lpV# )z6
Returns a function to compute singular values of `a`
r  r  r@   r  c                $  < V P                   R,          pV P                   R,          pV^ 8X  g   V^ 8X  d    \        P                  P                  R4      h\	        V 4       Tp\        W!4      p^p^p\        V 4      p\        P                  ! VSR7      pS! SS
VVVP                  VVP                  SP                  VSP                  V4      p	\        V	4       \        VP                  SP                  SP                  VP                  .4       V# )z
Computes singular values.
r  r  r  r  )r   r   r  r  r  r  r  r   r  r  r  r  )r  r   r   r  r  r  r  r  r   r  JOBZ_Nr   np_ret_typerx   r  r  s   &         r   sv_function2_compute_singular_values_impl.<locals>.sv_functionW  s     GGBKGGBK6Q!V))''(@AAQA	 %a(
 HHU+.KKHHHHII
 	.a0 	dii!&&!&&ABr!   r2  )
r_   rx   r   r   r    rC   r  r	  r   r   )
r  nb_ret_typenp_dtyper  r  r   r  rx   r  r  s
   &   @@@@@@r   _compute_singular_values_implr  B  s    
 Y--agg6N}QWWe,-D XF!''#5qww?K%%k2K""177+H 	x(A	&	)B- -^ r!   c                    \         h)z&
Compute the L2-norm of 1D-array *a*.
r0  r  s   &r   _oneD_norm_2r    r6  r!   c                   aaa \        V P                  R V P                  4      p\        P                  ! V4      o\	        4       P                  V P                  4      o\        \        V P                  R4      4      oVVV3R lpV# )r@   normc                 ^  < \        V 4      p\        P                  ! RSR7      p\        V P                  ^ ,          V P
                  ,          4      pS! SVV P                  VVP                  4      pV^ 8  d   \        4        Q h\        VP                  V P                  .4       V^ ,          # )r0  r  r"  )
lenr   r   r   stridesr\  r  r  r  r  )r  r   r*  jmpr  r   r  xxnrm2s   &    r   r   _oneD_norm_2_impl.<locals>.impl  s     Fhht;/!))A,+,HHJJ
 q51
 	chh/01vr!   )rC   r   r  r	  r9   rA   r   r    )r  r  r   r   r  r  s   &  @@@r   _oneD_norm_2_implr    sa    !''#5qww?K%%k2KW!!!''*F}QWWf-.D0 Kr!   c                   a	a
 \        V P                  R V P                  4      p\        P                  ! V4      p\        P                  ! V P                  4      p\	        4       P                  V P                  4      p\        \        V P                  R4      4      pV P                  ^8X  d&   VR\        P                  39   d   RR lpV# RR lpV# V P                  ^8X  d   VR\        P                  39   dS   V P                  R8X  d   \        R 4       o	M*V P                  R8X  d   \        R 4       o	M\        R	 4       o	RV	3R
 llpV# \        P                  ! VP                  4      P                   o
RV
3R llpV# Q h)r@   r  Nc                     \        V 4      # r/   )r  rb  r   s   &&r   r:  !_get_norm_impl.<locals>.oneD_impl  s    #A&r!   c                    \        V 4      pV^ 8X  d   R# V^8X  d   \        V 4      # V\        P                  8X  dC   \	        V ^ ,          4      p\        ^V4       F  p\	        W,          4      pWS8  g   K  TpK   	  V# V\        P                  ) 8X  dC   \	        V ^ ,          4      p\        ^V4       F  p\	        W,          4      pWS8  g   K  TpK   	  V# V^ 8X  d/   Rp\        V4       F  pW,          R8w  g   K  VR,          pK  	  V# V^8X  d/   Rp\        V4       F  pV\	        W,          4      ,          pK  	  V# Rp\        V4       F"  pV\	        W,          4      V,          ,          pK$  	  VRV,          ,          # )r$   r   r   )r  r  r   r  rj  r  )rb  r   r   r*  r   r5   s   &&    r   r:  r    sM   F 6 !8'?*BFF]ad)C"1a[!!$i9"%C ) JRVVG^ad)C"1a[!!$i9"%C ) JAXC"1X42:2IC & JAXC"1Xs14y( &J C"1Xs14y#~- &c?*r!   r   c                     V # r/   rS   rb  s   &r   array_prepare%_get_norm_impl.<locals>.array_prepare	  s    Hr!   r   c                     V P                   # r/   )r  r  s   &r   r  r  	  s     33Jr!   c                 "    V P                  4       # r/   r  r  s   &r   r  r   	  s    668Or!   c                 r   < V P                   pV^ 8X  d   R# S! V 4      p\        VP                  V4      4      # )r$   r   )r  r  r  )rb  r   r   x_cr  s   &&  r   r=  !_get_norm_impl.<locals>.twoD_impl&	  s3    FF6#A&#CKKN33r!   c                   < V P                   R,          pV P                   R,          pV P                  ^ 8X  d   R# V\        P                  8X  dO   Rp\	        V4       F;  pRp\	        V4       F  pV\        WV3,          4      ,          pK  	  Wd8  g   K9  TpK=  	  V# V\        P                  ) 8X  dO   S	p\	        V4       F;  pRp\	        V4       F  pV\        WV3,          4      ,          pK  	  Wh8  g   K9  TpK=  	  V# V^8X  dO   Rp\	        V4       F;  pRp\	        V4       F  pV\        WV3,          4      ,          pK  	  Wd8  g   K9  TpK=  	  V# VR8X  dO   S	p\	        V4       F;  pRp\	        V4       F  pV\        WV3,          4      ,          pK  	  Wh8  g   K9  TpK=  	  V# V^8X  d   \        V 4      ^ ,          # VR8X  d   \        V 4      R,          # \        R4      h)r0  r   z Invalid norm order for matrices.r  r  )r   r  r   r  r  rj  r  r  )
rb  r   r   r   
global_maxiitmpjj
global_minmax_vals
   &&       r   r=  r  1	  s   GGBKGGBK 66Q;"&&= "$J#Ah "'(B3qRy>1C #++),J ' &%RVVG^ ")J#Ah "'(B3qRy>1C #++),J ' &%AX "$J#Ah "'(B3qRy>1C #++),J ' &%BY ")J#Ah "'(B3qRy>1C #++),J ' &% AX3A6q99BY3A6r:: %%GHHr!   r/   )rC   r   r  r	  r9   rA   r   r    r8  r   r   r   r
   r   finfor  r  )rb  ord_flagr  r  r  r  r   r:  r=  r  r  s   &&       @@r   _get_norm_implr    sT    !''#5qww?K%%k2K""177+HW!!!''*F}QWWf-.Dvv{ ejj))'x s8+r 	
1 ejj)) xx3! "S! " "$ "$
4` O hh{//044GDIJ qr!   c                 D    \        4        \        V R 4       \        W4      # )r  )r-   r  r  r  s   &&r   	norm_implr  {	  s    O F+!!!r!   c                 <    \        4        \        V R 4       RR lpV# )condc                    V^8X  g   VR8X  g   Vfc   \        V 4      pV^8X  g   Vf'   \        P                  ! V^ ,          VR,          4      pM\        P                  ! VR,          V^ ,          4      pMd\        P                  P	                  W4      p\        P                  P	                  \        P                  P                  V 4      V4      pWE,          p\        P                  ! V4      '       d   \        P                  # V# )r,  r  r  )r  r   divider  r  r  isnanr  )rb  pr   r  norm_x
norm_inv_xs   &&    r   r   cond_impl.<locals>.impl	  s    & 6Q"W	(+AAvIIadAbE*IIaeQqT*YY^^A)F		a(8!<J#A 88A;;66MHr!   r/   r  )rb  r  r   s   && r   	cond_implr  	  s    OF##H Kr!   c                r    ^ p\        \        V 4      4       F  pW,          V8  d   V^,           pK   V# 	  V# )zB
Gets rank from singular values with cut-off at a given tolerance
r  r  )svr   r  r   s   &&  r   _get_rank_from_singular_valuesr  	  s<    
 D3r7^519!8DK 
 Kr!   c                R   a \        4        \        V R4       R oV3R lpV! W4      # )aL  
Computes rank for matrices and vectors.
The only issue that may arise is that because numpy uses double
precision lapack calls whereas numba uses type specific lapack
calls, some singular values may differ and therefore counting the
number of them above a tolerance may lead to different counts,
and therefore rank, in some cases.
matrix_rankc                   a VR \         P                  39   db   \        V P                  RV P                  4      p\        P
                  ! V4      p\        P                  ! V4      P                  oRV3R llpV# RR lpV# )Nr@   c                    < \        V 4      pV P                  ^ ,          pV P                  ^,          p\        W44      pV^ ,          V,          S,          p\        W&4      # r   )r  r   r  r  )r  tolr   r  r   lr   eps_vals   &&     r   _2d_tol_none_implImatrix_rank_impl.<locals>._2d_matrix_rank_impl.<locals>._2d_tol_none_impl	  sM    ,Q/GGAJGGAJIaD1Hw&5a;;r!   c                 .    \        V 4      p\        W!4      # r/   )r  r  )r  r  r   s   && r   _2d_tol_not_none_implMmatrix_rank_impl.<locals>._2d_matrix_rank_impl.<locals>._2d_tol_not_none_impl	  s    ,Q/5a==r!   r/   )	r   r   rC   r   r  r	  r   r  eps)r  r  nb_typenp_typer  r  r  s   &&    @r   _2d_matrix_rank_impl.matrix_rank_impl.<locals>._2d_matrix_rank_impl	  sk     4$$agg'9177CG ))'2Ghhw'++G< %$> )(r!   c                 Z   < V P                   pV^8X  d   RR lpV# V^8X  d	   S! W4      # Q h)r0  c                 \    \        \        V 4      4       F  pW,          R 8w  g   K   ^# 	  ^ # r  r	  )r  r  r   s   && r   _1d_matrix_rank_implMmatrix_rank_impl.<locals>._get_matrix_rank_impl.<locals>._1d_matrix_rank_impl	  s%    s1vAtrz  ' r!   r/   r  )r  r  r8  r  r  s   &&  r   _get_matrix_rank_impl/matrix_rank_impl.<locals>._get_matrix_rank_impl	  s7    vv19
 ('QY'//1r!   )r-   r  )r  r  r!  r  s   && @r   matrix_rank_implr#  	  s+     O M2).4 !((r!   c                   a \        V R4       \        P                  ! V P                  4      o\	        VRV4      p\        V\        P                  4      '       g   \        R4      hV3R lpV# )zD
Computes matrix power. Only integer powers are supported in numpy.
matrix_powerr   zExponent must be an integer.c                 r  < V^ 8X  dN   \         P                  ! V P                  S
R7      p\        V P                  ^ ,          4       F	  pRW#V3&   K  	  V# V P                  R,          V P                  R,          rTWE8w  d   \	        R4      hV^ 8X  d   V P                  4       # V^ 8  d;   \         P                  P                  V 4      P                  4       pVR8X  d   V# V) pMV^8X  d   V P                  4       # T pV^8  dR   V^8X  d   \         P                  ! W"4      # V^8X  d,   \         P                  ! \         P                  ! W"4      V4      # R# TpTpTpRp	V^ 8w  dT   V^,          '       d$   V	'       d   TpRp	M\         P                  ! W4      p\         P                  ! Wf4      pV^,	          pKZ  V# )	r$   r  r   zinput must be a square arrayTFNr  r  )	r   r   r   r  r  r   r  r  r  )r  r   r  r   rQ  r^  r  r  r*  flagr  s   &&        r   matrix_power_impl,matrix_power_impl.<locals>.matrix_power_impl
  ss   6 1A1771:&Q$ 'HaggbkB8;<< 7668O q5		a %%'ABwAAvvvxAq5Avvva|#AvvvbffQlA..  CC C D(77!$ ffS.ffS&QhJr!   )	r  r  r	  r   rC   r   r   Integerr   )r  r   ntr(  r  s   &&  @r   r(  r(  
  s\     N+""177+H	GQ	Bb%--((;<<=~ r!   c                    \        V RRR7       \        V\        \        P                  34      '       g   \        RV,          4      hRR lpV# )z!
Computes the trace of an array.
traceFr  z!integer argument expected, got %sc                 F   V P                   w  r#TpV^ 8  d	   W$,           pV^ 8  d	   W4,
          p\        \        W#4      ^ 4      p^ pV^ 8  d,   \        V4       F  pW`WtV,           3,          ,          pK  	  V# \        V4       F  pW`Wt,
          V3,          ,          pK  	  V# r   )r   r  r  r  )r  offsetrowscolsr   r   r*  r+  s   &&      r   matrix_trace_impl,matrix_trace_impl.<locals>.matrix_trace_impl]
  s    WW
q58Dq58DD#61XE{" 
 
 1X{" 
r!   r   )r  r   r   r   r*  r   )r  r0  r3  s   && r   r3  r3  R
  sD     Gu5fsEMM233@6IJJ" r!   c                     V'       d   R MRpW13p\        V \        P                  4      '       d(   V P                  ^8:  g   \	        RV,          RR7      hR# R# )r  r   r  Fr  N)r   r   r   r8  r   r  s   &&&  r   _check_scalar_or_lt_2d_matr6  q
  sT    %[4F F!U[[!!vv{K &'5:< <  "r!   c                 ,   \         P                  ! V 4      p\         P                  ! V4      p\         P                  ! VP                  4       P	                  VP
                  ^34      VP                  4       P	                  ^VP
                  34      4      # r"  r   asarraymultiplyr~  r  r  r  r  r  aabbs   &&&  r   outer_impl_noner>  {
  sd    	AB	AB;;rxxz))277A,7
**Arww<8: :r!   c                 2   \         P                  ! V 4      p\         P                  ! V4      p\         P                  ! VP                  4       P	                  VP
                  ^34      VP                  4       P	                  ^VP
                  34      V4       V# r"  r8  r;  s   &&&  r   outer_impl_arrr@  
  si    	AB	ABKK
""BGGQ<0
""Arww<0 Jr!   c                 H    VR \         P                  39   d   \        # \        # r/   )r   r   r>  r@  )r  r  r  s   &&&r   _get_outer_implrB  
  s    
tUZZ  r!   c                 h   a \        V R RR7       \        VR RR7       \        WV4      oRV3R llpV# )outerFr.  c                    < S! WV4      # r/   rS   )r  r  r  r   s   &&&r   
outer_implouter_impl.<locals>.outer_impl
  s    A#r!   r/   )r6  rB  )r  r  r  rF  r   s   &&& @r   rF  rF  
  s6     q'U;q'U;1%D r!   c                 "   \        V \        P                  4      '       dc   V P                  R9  d%   \	        RP                  V P                  4      4      hV P                  ^8X  d   \        R 4       pV# \        R 4       pV# \        R 4       pV# )r   z^np.linalg.kron only supports 'C' or 'F' layout input arrays. Received an input of layout '{}'.c                 p    V P                   R,          pV P                   R,          pV P                  W!4      # )r0  r  r  r   r  )rb  xnxms   &  r   	nrm_shape(_kron_normaliser_impl.<locals>.nrm_shape
  s+    WWR[WWR[yy((r!   c                 L    V P                   R,          pV P                  ^V4      # rG  rJ  )rb  rK  s   & r   rM  rN  
  s     WWR[yyB''r!   c                 N    \         P                  ! R\        V 4      4      pW^ &   V# )r0  r2  )r   r   r  )rb  r  s   & r   rM  rN  
  s"    a)AaDHr!   )r   r   )r   r   r   r   r   formatr8  r
   )rb  rM  s   & r   _kron_normaliser_implrR  
  s    !U[[!!88:% --3VAHH-=? ? VVq[) ) ( ( 		 
	 r!   c                 z   \        V \        P                  4      p\        V\        P                  4      pV'       dG   V'       d?   V P                  ^8X  g   VP                  ^8X  d   \        R 4       pV# \        R 4       pV# V'       d   \        R 4       pV# V'       d   \        R 4       pV# \        R 4       pV# )r,  c                     V# r/   rS   r  r  r   s   &&&r   r*  _kron_return.<locals>.ret
  s    r!   c                 8    VP                  VP                  4      # r/   )r  r  rU  s   &&&r   r*  rV  
  s    yy((r!   c                 8    VP                  V P                  4      # r/   r  r   rU  s   &&&r   r*  rV  
      yy))r!   c                 8    VP                  VP                  4      # r/   rY  rU  s   &&&r   r*  rV  
  rZ  r!   c                     V^ ,          # r   rS   rU  s   &&&r   r*  rV  
  s    tr!   )r   r   r   r8  r
   )r  r  a_is_arrb_is_arrr*  s   &&   r   _kron_returnr_  
  s     !U[[)H!U[[)HH66Q;!&&A+ J) )J* *J* *J Jr!   c                    aaaa \        V R RR7       \        VR RR7       \        V 4      o\        V4      o\        W4      o\        V RV 4      oVVVV3R lpV# )kronFr.  r   c           	        < S! V 4      pS! V4      pVP                   R,          pVP                   R,          pVP                   R,          pVP                   R,          pWF,          pWW,          p	\        P                  ! W3SR7      p
\        V4       Fh  pW,          p\        V4       FN  pW,           pW=R3,          p\        V4       F*  pVV,          pW+V3,          V,          WVVV,           13&   K,  	  KP  	  Kj  	  S! WV
4      # )r,  r  r'  r  r  )r   r   r   r  )r  r  r<  r=  rQ  r^  rR  ra  cmcnr   r+  rjmpr   irjmpslcr,  cjmpr  fix_afix_bret_cs   &&                r   	kron_implkron_impl.<locals>.kron_impl
  s    1X1XXXb\XXb\XXb\XXb\WW HHbXR( rA6D2YAhrA r6D/1Q$x#~AT$)^+, # 	 " Q1~r!   )r6  rR  r_  rC   )r  r  rl  r  ri  rj  rk  s   && @@@@r   rl  rl  
  s^     q&E:q&E:!!$E!!$EE 
GQ	B& &P r!   )z<BLAS function>)F)Tr"  r  r  r/   r   )rX   
contextlibrA  llvmliter   numpyr   operatornumba.core.imputilsr   r   r   r   numba.core.typingr   numba.core.extendingr   r	   r
   
numba.corer   r   r   numba.core.errorsr   r   r   arrayobjr   r   r   numba.npr   r  r   r   
as_pointer	ll_char_pr   ll_intc	ll_intc_pr   	ll_intp_pr  r  re   float32r   	complex64
complex128r   r    r)   r-   r7   r9   r_   contextmanagerr   r   r   r   r   r   r   r	  r  r  r!  r  r&  matmulr(  r$  rO  rQ  rS  rk  rz  r  rH   rD   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r%  r-  r5  r?  rB  rI  rK  rX  rZ  rc  re  rv  ry  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r#  r%  r(  r-  r3  r6  r>  r@  rB  rD  rF  rR  r_  ra  rl  rS   r!   r   <module>r     s  
     J J ' F F - -  < < 0
**Q- 		
**R. 			 xx{{ 
MM3	MM3	OOS	c	HH5
&; &;R`: `:F - -0F	A	C-,"-J/-dD D D 6 
"&&( ( 
(//# #)(X 
"''6 6<@@6.rV.r 
"&& 2  2F ))*=uzz|L  8 83*7	 

 ! "6 < <  
 
"))--$ $N G G@$ 
"))

) )V 
"))--p pd 
"))

t! t!l 
"))... .` 
"))

. .` 
"))--> >B 
")),,I I` 

  

   

+, -( 

!" #* 
/! !H 
/  
"))//[ [| 

  ! 
"))//9 9x 
"))..` `F! H 
"))

7 7t 
"))--
 
 

"#C $CL 
,   FDN 
")).." " 
"))..) )X 
 
 
"))

 >) !>)B 
"))
 
 !K "K` 
"(( << : :   
"((
 
:D 
"''5 5r!   