+
    :ibw                    J   ^ RI t ^ RIt^ RIHtHt ^ RIt^ RIt^ RIHtH	t	 ^ RI
t
^ RIt^ RIHtHtHt ^ RIHt ^ RIHtHtHtHtHtHt ^RIHt ^ RItR tR	 tR
 t ! R R]]4      tR t R t!R t"R t#R t$R t%RIR lt&R t'RJR lt(R t)RKR lt*R t+R t,RLR lt-RLR lt.RLR lt/R t0RMR lt1R t2RLR  lt3R! t4 ! R" R#]]4      t5 ! R$ R%]4      t6 ! R& R']54      t7 ! R( R)]54      t8 ! R* R+]54      t9 ! R, R-]54      t: ! R. R/]54      t; ! R0 R1]54      t< ! R2 R3]<4      t= ! R4 R5]<4      t> ! R6 R7]54      t? ! R8 R9]54      t@ ! R: R;]<4      tA ! R< R=]54      tB ! R> R?]<4      tC ! R@ RA]54      tD ! RB RC]54      tE ! RD RE]<4      tF ! RF RG]4      tG]HRH8X  d   ]P                  ! 4        R# R# )N    N)productcycle)NumberIntegral)jitnjittypeof)errors)TestCasetagneeds_lapack
needs_blas
_is_armv7lEnableNRTStatsMixin)matmul_usecasec                 .    \         P                  ! W4      # Nnpdotabs   &&U/var/www/html/photoedit/myenv/lib/python3.14/site-packages/numba/tests/test_linalg.pydot2r      s    66!<    c                 2    \         P                  ! WVR 7      # outr   r   r   r    s   &&&r   dot3r"      s    66!C  r   c                 .    \         P                  ! W4      # r   )r   vdotr   s   &&r   r$   r$          771=r   c                   z  a a ] tR t^t oRt]P                  ]P                  ]P                  ]P                  3t
V 3R ltR tR t]P                  R 4       tR tR tR tRR	 ltRR
 ltR t]R 4       t]R 4       tR t]R 4       tR t]R 4       t]R 4       t]R 4       t]R 4       t ]R 4       t!Rt"Vt#V ;t$# )TestProductz
Tests for dot products.
c                V   < \         P                  ! 4        \        \        V `  4        R # r   )gccollectsuperr'   setUpself	__class__s   &r   r,   TestProduct.setUp&   s    


k4&(r   c                    \         P                  ! V4      p\        V\         P                  4      '       d    VR,          R,           P	                  V4      # VR,          ^,
          P	                  V4      #    y               @g      ?y      ?      ࿩r   arange
issubclasscomplexfloatingastyper.   ndtypebases   &&& r   sample_vectorTestProduct.sample_vector+   X     yy|eR//00H%*225993JN**511r   c                R    V P                  W,          V4      P                  W34      # r   )r=   reshape)r.   mr:   r;   s   &&&&r   sample_matrixTestProduct.sample_matrix4   s$    !!!%/77??r   c              #    "   \         P                  ! RR7      ;_uu_ 4       p\         P                  ! R\        P                  4       Rx  RRR4       V P                  \        X4      ^4       V P                  V^ ,          P                  \        P                  4       V P                  R\        V^ ,          P                  4      4       V P                  V^ ,          P                  VP                  P                  4       V P                  V^ ,          P                   VP                  P"                  ^,           4       R#   + '       g   i     L; i5i)z2
Check performance warning(s) for non-contiguity.
T)recordalwaysNzfaster on contiguous arrays)warningscatch_warningssimplefilterr
   NumbaPerformanceWarningassertGreaterEquallenassertIscategoryassertInstrmessageassertEqualfilename__code__co_filenamelinenoco_firstlineno)r.   pyfuncws   && r   check_contiguity_warning$TestProduct.check_contiguity_warning7   s     
 $$D11Q!!(F,J,JK 2 	A*admmV%C%CD3S15FG1(C(CD1foo&D&Dq&HI 21s    E*EC7EE	Ec                    V P                  4       ;_uu_ 4        V! V!  pV! V!  pV P                  WTR R7       ??RRR4       R#   + '       g   i     R# ; i)Tignore_sign_on_zeroN)assertNoNRTLeakassertPreciseEqual)r.   rY   cfuncargsexpectedgots   &&&&  r   
check_funcTestProduct.check_funcF   sJ    !!##t}H,C##Ct#LX	 $###s   "AA	c                   VP                   ^,           VP                  ,          ^,           pVP                   VP                  ,          p\        P                  ! V\        P                  R7      p\        VP                  ^,           4       FE  pWEWS,            P                  VP                  R7      pVP                  P                  '       g   KE   M	  \        R4      hVP                  P                  '       d$   \        P                  ! WaP                  RR7      pM"\        P                  ! WaP                  RR7      pVR,          VR&   VP                  P                  '       g   Q hV# )r3   r;   zCould not obtain aligned arrayCorderFNNN)sizeitemsizer   emptyuint8rangeviewr;   flagsaligned	Exceptionc_contiguousrA   shape)r.   arrro   datasizetmpinews   &&     r   _aligned_copyTestProduct._aligned_copyN   s     1,q088cll*hht288,s||a'(A!,',,399,=Cyy    )
 <==99!!!**S))37C**S))37CQAyy     
r   c           	     j   \         '       d   V P                  M\        P                  pV P	                  4       ;_uu_ 4        V! V4      pV! V4      pV P                  V! VR V/ V4       V P                  V! VR V/ V4       V P                  WvRR7       ??RRR4       R#   + '       g   i     R# ; i)r    Tr^   N)r   r   r   copyr`   rN   ra   )r.   rY   rb   rc   r    copierrd   re   s   &&&&&   r   check_func_outTestProduct.check_func_outc   s    '1z##rww!!##c{H+CMM&$5H5x@MM%/3/5##Ct#LX $###s   AB!!B2	c                    V P                  \        4      ;_uu_ 4       pV! V!   R R R 4       V'       d   RMRpV P                  V\        XP                  4      4       R #   + '       g   i     LC; i)Nzincompatible output array sizezincompatible array sizes)assertRaises
ValueErrorrP   rQ   	exception)r.   rb   rc   is_outraisesmsgs   &&&&  r   assert_mismatching_sizes$TestProduct.assert_mismatching_sizesm   sQ    z**f4L +39/) 	c3v//01	 +*s   A  A0	c                    V P                  \        P                  4      ;_uu_ 4       pV! V!   R R R 4       V P                  V: R2\	        XP
                  4      4       R #   + '       g   i     L;; i)Nz' arguments must all have the same dtype)r   r
   TypingErrorrP   rQ   r   )r.   rb   rc   	func_namer   s   &&&& r   assert_mismatching_dtypes%TestProduct.assert_mismatching_dtypest   sR    v1122f4L 3"%&**+	- 32s   A""A2	c           
     l   ^p\        RR7      ! V4      pV P                   F`  pV P                  W54      pV P                  W54      pV P                  WWg34       V P                  WVRRR1,          VRRR1,          34       Kb  	  V P                  V^,
          \        P
                  4      pV P                  V\        P
                  4      pV P                  WFV34       V P                  V\        P                  4      pV P                  V\        P
                  4      pV P                  WFV3VR7       R# )   TnopythonN)r   )	r   dtypesr=   rf   r   float64r   float32r   )r.   rY   r   r:   rb   r;   r   r   s   &&&     r   check_dot_vvTestProduct.check_dot_vv{   s    T"6*[[E""1,A""1,AOOFA62OOFAddGQttW+=> ! q1ubjj1q"**-%%eV4q"**-q"**-&&u!f	&Jr   c                2    V P                  \        R4       R# )z
Test vector * vector np.dot()
np.dot()N)r   r   r.   s   &r   test_dot_vvTestProduct.test_dot_vv   s    
 	$
+r   c                2    V P                  \        R4       R# )z
Test np.vdot()
z	np.vdot()N)r   r$   r   s   &r   	test_vdotTestProduct.test_vdot   s    
 	$,r   c                f  a  V 3R  lp\        RR7      ! V4      pVe   \        RR7      ! V4      pR F  w  rxV! Wx4       F5  w  rS P                  WW34       S P                  WWP                  34       K7  	  Vf   KL  V! Wx4       FY  w  r\        P                  ! WyP
                  R7      pS P                  VXW3V4       S P                  W&WP                  3V4       K[  	  K  	  ^^rS P                  Wx^,
          \        P                  4      p	S P                  V\        P                  4      p
S P                  WYV
34       S P                  WZV	P                  34       Ve   \        P                  ! V\        P                  4      pS P                  XWV34       S P                  WjV	P                  V34       S P                  Ww\        P                  4      p	S P                  V\        P                  4      p
\        P                  ! V^,
          \        P                  4      pS P                  WiW3RR7       S P                  WjV	P                  V3RR7       S P                  Wx\        P                  4      p	S P                  V\        P                  4      p
S P                  WYV
3V4       Ve}   S P                  Wx\        P                  4      p	S P                  V\        P                  4      p
\        P                  ! V\        P                  4      pS P                  XWV3V4       R# R# )c              3   v  <"   R  FX  pSP                  W\        P                  4      P                  VR7      pSP	                  V\        P                  4      pW43x  KZ  	  SP
                   F+  pSP                  WV4      pSP	                  W4      pW43x  K-  	  XRRR1,          XRRR1,          3x  R# 5iCFrk   Nr   )rC   r   r   r   r=   r   )rB   r:   rl   r   r   r;   r.   s   &&    r   samples)TestProduct.check_dot_vm.<locals>.samples   s     &&qRZZ8==E=J&&q"**5d
  &&qU3&&q0d
 %
 DbD'1TrT7""s   B6B9Tr   Nri   r   )   r   )r   r   )r   r   )r   rf   Tr   rq   r;   r   rC   r   r=   r   r   r   )r.   pyfunc2pyfunc3r   r   cfunc2cfunc3rB   r:   r   r   r    s   f&&&        r   check_dot_vmTestProduct.check_dot_vm   s   
	# d#G,$'0FDA  !8!SS: & "#AMDA((1GG4C''!E''!SS3G * !1qa%4q"**-%%f!f5%%f!##h7((1bjj)C))&1+>))&acc3-@""14A""1bjj1A((1q5"**-C))&a+d)K))&acc3-)MqRZZ0q"**-&&v1vyA""14A""1bjj1A((1bjj)C**6A#;	J	 r   c                <    V P                  \        \        R4       R# )z3
Test vector * matrix and matrix * vector np.dot()
r   N)r   r   r"   r   s   &r   test_dot_vmTestProduct.test_dot_vm       
 	$j1r   c                6  a  V 3R  lp\        RR7      ! V4      pVe   \        RR7      ! V4      pR F  w  rxp	V! WxV	4       F@  w  rS P                  WW34       S P                  WVP                  V
P                  34       KB  	  Vf   KY  V! WxV	4       F  w  r\        P                  ! Wx3V
P
                  R7      pS P                  VXW3V4       \        P                  ! W3V
P
                  R7      pS P                  W&VP                  V
P                  3V4       K  	  K  	  ^^^rpS P                  Wy^,
          \        P                  4      p
S P                  W\        P                  4      pS P                  WZV34       Ve   \        P                  ! Wx3\        P                  4      pS P                  XWV34       S P                  Wy\        P                  4      p
S P                  W\        P                  4      p\        P                  ! Wx^,
          3\        P                  4      pS P                  WjW3RR7       S P                  Wy\        P                  4      p
S P                  W\        P                  4      pS P                  WZV3V4       Ve~   S P                  Wy\        P                  4      p
S P                  W\        P                  4      p\        P                  ! Wx3\        P                  4      pS P                  XWV3V4       R# R# )c              3     <"   \        R R 4       Fj  w  r4SP                  W\        P                  4      P	                  VR7      pSP                  W!\        P                  4      P	                  VR7      pWV3x  Kl  	  SP
                   F,  pSP                  WV4      pSP                  W!V4      pWV3x  K.  	  XRRR1,          XRRR1,          3x  R# 5ir   )r   rC   r   r   r   r   )	rB   r:   korder_aorder_br   r   r;   r.   s	   &&&     r   r   )TestProduct.check_dot_mm.<locals>.samples   s     $+D$$7 &&qRZZ8==G=L&&qRZZ8==G=Ld
 %8 &&qU3&&qU3d
 %
 DbD'1TrT7""s   CCTr   Nri   r   ))r   r      )r3   r   r   )r3   r3   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   rf   r   r   rq   r;   r   rC   r   r   r   r   )r.   r   r   r   r   r   r   rB   r:   r   r   r   r    s   f&&&         r   check_dot_mmTestProduct.check_dot_mm   sw   
	# d#G,$'0FGA!  a(!8!##qss< ) "#A!,DA((A69C''!E((A69C''!##qssSI	 -& Qaqa%4qRZZ0%%f!f5((A62::.C))&1+>""14A""14A((A1u:rzz2C))&a+d)KqRZZ0qRZZ0&&v1vyA""14A""14A((A62::.C**6A#;	J	 r   c                <    V P                  \        \        R4       R# )z
Test matrix * matrix np.dot()
r   N)r   r   r"   r   s   &r   test_dot_mmTestProduct.test_dot_mm  r   r   c                2    V P                  \        R4       R# )z
Test vector @ vector
'@'N)r   r   r   s   &r   test_matmul_vvTestProduct.test_matmul_vv   s    
 	.%0r   c                4    V P                  \        RR4       R# )z*
Test vector @ matrix and matrix @ vector
Nr   )r   r   r   s   &r   test_matmul_vmTestProduct.test_matmul_vm'      
 	.$6r   c                4    V P                  \        RR4       R# )z
Test matrix @ matrix
Nr   )r   r   r   s   &r   test_matmul_mmTestProduct.test_matmul_mm.  r   r   c                n   ^^^r2p\         P                  pV P                  WV4      RRR1,          pV P                  W#V4      RRR1,          p\         P                  ! W3V4      p\	        RR7      ! \
        4      pV P                  VP                  4      ;_uu_ 4        V! WV4       RRR4       \	        RR7      ! \        4      pV P                  VP                  4      ;_uu_ 4        V! WVV4       RRR4       V P                  W44      RRR1,          pV P                  W44      RRR1,          p\	        RR7      ! \        4      pV P                  VP                  4      ;_uu_ 4        V! WV4       RRR4       R#   + '       g   i     L; i  + '       g   i     L; i  + '       g   i     R# ; i)r   NTr   r   )r   r   rC   rq   r   r   r[   py_funcr"   r=   r$   )	r.   rB   r   r:   r;   r   r   r    rb   s	   &        r   test_contiguity_warnings$TestProduct.test_contiguity_warnings5  sF   Qa

qU+DbD1qU+DbD1hhvu%T"4(**5==99!K :T"4(**5==99! : q(2.q(2.T"4(**5==99!K :9 :9 :9 :99s$   	E=)
F*	F#=F	F 	#F4	 )F)r   )%__name__
__module____qualname____firstlineno____doc__r   r   r   
complex128	complex64r   r,   r=   rC   
contextlibcontextmanagerr[   rf   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   __static_attributes____classdictcell____classcell__r/   __classdict__s   @@r   r'   r'      s(     jj"**bmmR\\BF)
2@ J J*2-K& , , - -6Kp 2 2<K| 2 2 1 1 7 7 7 7   r   r'   c                 @    \         P                  P                  V 4      # r   r   linalginvr   s   &r   invert_matrixr   N      99==r   c                 @    \         P                  P                  V 4      # r   )r   r   choleskyr   s   &r   cholesky_matrixr   R      99a  r   c                 @    \         P                  P                  V 4      # r   )r   r   eigr   s   &r   
eig_matrixr   V  r   r   c                 @    \         P                  P                  V 4      # r   )r   r   eigvalsr   s   &r   eigvals_matrixr   Z      99Qr   c                 @    \         P                  P                  V 4      # r   )r   r   eighr   s   &r   eigh_matrixr   ^      99>>!r   c                 @    \         P                  P                  V 4      # r   )r   r   eigvalshr   s   &r   eigvalsh_matrixr   b  r   r   c                 @    \         P                  P                  W4      # r   r   r   svd)r   full_matricess   &&r   
svd_matrixr  f  s    99==**r   c                 @    \         P                  P                  V 4      # r   r   r   qrr   s   &r   	qr_matrixr  j  s    99<<?r   c                 B    \         P                  P                  WV4      # r   r   r   lstsq)ABrconds   &&&r   lstsq_systemr  n  s    99??1''r   c                 @    \         P                  P                  W4      # r   r   r   solve)r	  r
  s   &&r   solve_systemr  r  s    99??1  r   c                 @    \         P                  P                  V 4      # r   r   r   pinv)r	  r  s   &&r   pinv_matrixr  v  r   r   c                 @    \         P                  P                  V 4      # r   r   r   slogdetr   s   &r   slogdet_matrixr  z  r   r   c                 @    \         P                  P                  V 4      # r   )r   r   detr   s   &r   
det_matrixr  ~  r   r   c                 @    \         P                  P                  W4      # r   )r   r   norm)r   ords   &&r   norm_matrixr    s    99>>!!!r   c                 @    \         P                  P                  W4      # r   )r   r   cond)r   ps   &&r   cond_matrixr#    s    99>>!r   c                 @    \         P                  P                  W4      # r   r   r   matrix_rank)r   tols   &&r   matrix_rank_matrixr(    s    99  ((r   c                 @    \         P                  P                  W4      # r   )r   r   matrix_power)r   r:   s   &&r   matrix_power_matrixr+    s    99!!!''r   c                 .    \         P                  ! W4      # r   r   trace)r   offsets   &&r   trace_matrixr0    s    88Ar   c                 .    \         P                  ! V 4      # r   r-  r   s   &r   trace_matrix_no_offsetr2    s    88A;r   c                 2    \         P                  ! WVR 7      # r   )r   outerr!   s   &&&r   outer_matrixr5    s    88Ac""r   c                 .    \         P                  ! W4      # r   )r   kronr   s   &&r   kron_matrixr8    r%   r   c                      a a ] tR tRt oRt]P                  ]P                  ]P                  ]P                  3t
V 3R ltR tRR lt]3R ltR tR tRR	 ltR
 tR tR tRR ltR tR tRtVtV ;t# )TestLinalgBasei  zM
Provides setUp and common data/error modes for testing np.linalg functions.
c                V   < \         P                  ! 4        \        \        V `  4        R # r   )r)   r*   r+   r:  r,   r-   s   &r   r,   TestLinalgBase.setUp  s    


nd)+r   c                    \         P                  ! V4      p\        V\         P                  4      '       d    VR,          R,           P	                  V4      # VR,          ^,           P	                  V4      # r2   r4   r9   s   &&& r   r=   TestLinalgBase.sample_vector  r?   r   c                   Rp\        V4      ^8w  d   \        R4      hVR9  d   \        R4      hV\        P                  \        P                  \        P
                  \        P                  39  d   \        R4      hVe   Ve   \        R4      hVf   TpV^8  d   \        R4      h\        P                  P                  ^ 4       Vw  rxV^ 8  g   V^ 8  d   \        R4      h\        Wx4      p	Vf   T	p
MFV^ 8:  d   \        R	4      h\        V\        4      '       g   \        R
4      hTp
WI8  d   \        R4      hV^8X  g   V^8X  d?   WV8w  d   \        R4      h\        Wx4      pV P                  W4      P                  Wx4      pV# V P                  Ww,          V4      P                  Ww4      p\        P                  P!                  V4      w  rV P                  W,          V4      RRR1,          P                  W4      p\        P                  P!                  V4      w  pp\        P"                  ! WeV
4      p\        P$                  ! Wx34      p\        P&                  ! \        P(                  ! Wx4      4      pVVV^ ,          RV
 V^,          RV
 3&   \        P*                  ! \        P*                  ! VV4      VP,                  4      p\        P.                  ! WVR7      pV# )a  
Provides a sample matrix with an optionally specified rank or condition
number.

size: (rows, columns), the dimensions of the returned matrix.
dtype: the dtype for the returned matrix.
order: the memory layout for the returned matrix, 'F' or 'C'.
rank: the rank of the matrix, an integer value, defaults to full rank.
condition: the condition number of the matrix (defaults to 1.)

NOTE: Only one of rank or condition may be set.
      ?size must be a length 2 tuple. order must be one of 'F' or 'C'.*dtype must be a numpy floating point type.N/Only one of rank or condition can be specified.Condition number must be >=1.+Negative dimensions given for matrix shape.Rank must be greater than zero.Rank must an integer."Rank given greater than full rank.8Condition number was specified for a vector (always 1.).r;   rl   )rm   rj   r   )rM   r   r   r   r   r   r   randomseedmin
isinstancer   maxr=   rA   r   r  linspacezerosnonzeroeyer   r   array)r.   ro   r;   rl   rank	conditiond_condrB   r:   minmnrvmaxmnQr|   U_VsvSidxs   &&&&&&              r   specific_sample_matrix%TestLinalgBase.specific_sample_matrix  sl     t9>=>>
"?@@RZZr}}MMIJJ	 5NOOIq=<==
		qq5AEJKKA	<Bqy !BCCdH-- !899B| !EFF6Q!V " NP PIE""5088>A*  $$QUE2::1@C99<<$DA$$QUE24R48@@FC99<<$DAqV3B! A**RVVA\*C*,Ac!fSbk3q6#2;&'rvva|QSS)Au5Ar   c                    V P                  V4      ;_uu_ 4       pV! V!   R R R 4       V P                  V\        XP                  4      4       R #   + '       g   i     L7; ir   )r   rP   rQ   r   )r.   rb   rc   r   errr   s   &&&&& r   assert_errorTestLinalgBase.assert_error  sC    s##v4L $c3v//01 $#s   AA 	c                `    R pV P                  WV\        P                  P                  4       R# )z.Last 2 dimensions of the array must be square.Nrg  r   r   LinAlgErrorr.   rb   rc   r   s   &&& r   assert_non_square TestLinalgBase.assert_non_square  s#    >%sBII,A,ABr   c                Z    R V,          pV P                  W#V\        P                  4       R# )z9np.linalg.%s() only supported on float and complex arraysNrg  r
   r   r.   namerb   rc   r   s   &&&& r   assert_wrong_dtype!TestLinalgBase.assert_wrong_dtype  s$    IDP%sF,>,>?r   c                t    V'       d   R MRpV: RV: R2pV P                  W#V\        P                  4       R# )	np.linalgr   .z() only supported on 2-D arraysNrp  r.   rr  rb   rc   	la_prefixprefixr   s   &&&&&  r   assert_wrong_dimensions&TestLinalgBase.assert_wrong_dimensions  s-     )t8>E%sF,>,>?r   c                `    R pV P                  WV\        P                  P                  4       R# )z$Array must not contain infs or NaNs.Nrj  rl  s   &&& r   assert_no_nan_or_inf#TestLinalgBase.assert_no_nan_or_inf  s#    4%sBII,A,ABr   c                   \        V\        4      '       d   V F  pV P                  W24       K  	  R# \        V\        4      '       g   VP                  P
                  pVP                  P                  pRpV P                  WE,          V4       RpVR8X  d   V P                  WF4       R# VR8X  d   V P                  WV4       R# \        R4      hR# )a  
This checks that in a computed result from numba (array, possibly tuple
of arrays) all the arrays are contiguous in memory and that they are
all at least one of "C_CONTIGUOUS" or "F_CONTIGUOUS". The computed
result of the contiguousness is then compared against a hardcoded
expected result.

got: is the computed results from numba
expected_contig: is "C" or "F" and is the expected type of
                contiguousness across all input values
                (and therefore tests).
z6Results are not at least one of all C or F contiguous.z0Computed contiguousness does not match expected.rj   rm   zUnknown contigN)	rO  tupleassert_contig_sanityr   ru   rx   f_contiguous
assertTruer   )r.   re   expected_contigr   c_contigf_contigr   s   &&&    r   r  #TestLinalgBase.assert_contig_sanity"  s     c5!!))!=  c6**99119911 O 3S9H"c)OOH2$+OOH2$%566! +r   c                b    R pV P                  WV\        P                  P                  R7       R# )z(Matrix is singular to machine precision.rf  Nrj  rl  s   &&& r   assert_raise_on_singular'TestLinalgBase.assert_raise_on_singularG  s&    8%s		0E0EFr   c                   V P                  VP                  R,          VP                  R,          4       \        P                  ! VP                  R,          VP                  R7      p^\        P
                  ! VP                  4      P                  ,          pVf
   ^
V,          pVf
   ^dV,          p\        P                  P                  WW#4       R# )z5
Checks if a matrix is equal to the identity matrix.
ri   Nr   )	rS   ry   r   rT  r;   finfo
resolutiontestingassert_allclose)r.   re   rtolatolrT  r  s   &&&&  r   assert_is_identity_matrix(TestLinalgBase.assert_is_identity_matrixK  s    
 	2		"6ffSYYr]#))4#)),777
<
?D<#D


""3T8r   c                8    RpV P                  WV\        4       R# )z%
For use in norm() and cond() tests.
z Invalid norm order for matrices.N)rg  r   rl  s   &&& r   assert_invalid_norm_kind'TestLinalgBase.assert_invalid_norm_kind[  s     1%sJ7r   c                `    R pV P                  WV\        P                  P                  4       R# )zArrays cannot be emptyNrj  rl  s   &&& r   assert_raise_on_empty$TestLinalgBase.assert_raise_on_emptyb  s#    &%sBII,A,ABr   r   )NNT)r   r   r   r   r   r   r   r   r   r   r   r,   r=   rc  r   rg  rm  rs  r{  r~  r  r  r  r  r  r   r   r   r   s   @@r   r:  r:    s     
 jj"**bmmR\\BF,
2Rh 2< 2
C@@
C#7JG9 8C Cr   r:  c                   *   a  ] tR tRt o RtR tRtV tR# )TestTestLinalgBaseig  zz
The sample matrix code TestLinalgBase.specific_sample_matrix()
is a bit involved, this class tests it works as intended.
c                  a a \        R 4      o. ROp\        VSP                  R4       EF  w  r#pVw  rV\        WV4      pSP	                  W#V4      pS P                  VP                  V4       S P                  \        P                  P                  V4      V4       V^8  dh   V^,
          p	SP	                  W#WIR7      pS P                  VP                  V4       S P                  \        P                  P                  V4      V	4       ^\        P                  ! V4      P                  ,          p
SP	                  W#V4      pS P                  VP                  V4       \        P                  P                  \        P                  P                  V4      RV
V
R7       V^8  g   EK  RpSP	                  W#WKR7      pS P                  VP                  V4       \        P                  P                  \        P                  P                  V4      RV
V
R7       EK  	  \        3VV 3R llpS P!                  \"        4      ;_uu_ 4       pRpV! R\        P$                  R	3V\        R
7       RRR4       RpV! R\        P$                  R	3V\        R
7       RpV! R\        P$                  R3V\        R
7       RpV! R\        P&                  R	3V\        R
7       RpV! R\        P$                  R	^^3V\        R
7       RpV! R\        P$                  R	RR3V\        R
7       RpV! R\        P$                  R	3V\        R
7       RpV! R\        P$                  R	R3V\        R
7       RpV! R\        P$                  R	^3V\        R
7       RpV! R\        P$                  R	R^
3V\        R
7       RpV! R\        P$                  R	R3V\        R
7       R#   + '       g   i     ELp; i)rc  FCrV  r@  r  r        $@rW  c                    < SP                  V4      ;_uu_ 4       pSP                  ! V !   R R R 4       SP                  V\        XP                  4      4       R #   + '       g   i     L7; ir   )r   rc  rP   rQ   r   )rc   r   rf  r   instr.   s   &&& r   check_errorCTestTestLinalgBase.test_specific_sample_matrix.<locals>.check_error  sK    ""3''6++T2 (MM#s6#3#345 ('s   AA+	blankrm   r  NrA  rB  zrC  rD  rE  rF  rG  rI  rJ  rH  g      ?   r3         r  r  r   r   r3   r  r   r3   r   )r   )r3   r   )r:  r   r   rN  rc  rS   ry   r   r   r&  r  r  r  r  r!  r   r   AssertionErrorr   int32)r.   sizesro   r;   rl   rB   r:   rY  r	  rV  r  rW  r  r   r   r  s   f              @r   test_specific_sample_matrix.TestTestLinalgBase.test_specific_sample_matrixm  sS    67: #*%d"CDDAIE ++D?AQWWd+RYY2215u= qyqy//U/N  $/  !6!6q!94@RXXe_777J ++D?AQWWd+JJ&&ryy~~a'8'),6,6 ' 8 qy	// 0 =  $/

**299>>!+<+.0:0: + <C #DN (2 	6 	6 ~..&CS13JG / /T2::s+SjA 1VRZZ-s
C ;VRXXs+SjA @VRZZa3SjI .VRZZdB7*M <Wbjj#.D 0VRZZb13JG 3VRZZa0#:F IVRZZdB7*M &VRZZc2CZHY /..s   
#OO%	r   N)r   r   r   r   r   r  r   r   r   s   @r   r  r  g  s     
aI aIr   r  c                   D   a  ] tR tRt o Rt]R 4       t]R 4       tRtV t	R# )TestLinalgInvi  z
Tests for np.linalg.inv.
c           	     P  a a ^
p\        RR7      ! \        4      oVV 3R lp\        S P                  R4       F   w  r4S P	                  W3W44      pV! V4       K"  	  V! \
        P                  ! R4      4       S P                  S\
        P                  ! R	4      34       S P                  RS\
        P                  ! R
\
        P                  R7      34       S P                  RS\
        P                  ! ^
4      34       S P                  S\
        P                  ! R
4      34       R# )z
Test np.linalg.inv
Tr   c                   < \        V 4      pS! V 4      pSP                  VR 4       Rp \        P                  P	                  W2^
R7       V'       d(   \        P                  ! W04      pSP                  V4       SP                  4       ;_uu_ 4        S! V 4       RRR4       R#   \
         d    Rp Lii ; i  + '       g   i     R# ; i)rm   FnulpTN)	r   r  r   r  assert_array_almost_equal_nulpr  r   r  r`   )r   kwargsrd   re   use_reconstructionrecrb   r.   s   &,    r   check,TestLinalgInv.test_linalg_inv.<locals>.check  s    $Q'H(C%%c3/!&*

99#?A : C "ffSn..s3 %%''a (' " *%)"* (''s   !B% 	B8%B54B58C		r   r   ri   Nr   r   r   r   r   )r   r   r   r   rc  r   rq   rm  onesrs  r  r{  r  rR  )r.   r:   r  r;   rl   r   rb   s   f     @r   test_linalg_invTestLinalgInv.test_linalg_inv  s    
 T"=1	. $DKK6LE++QFEAA!H 7
 	bhhv 	urwwv&89 	u!#rxx!@ B	D 	$$UEBGGBK>B 	%%ebhhv.>-@Ar   c                   \         P                  ! . RO. R	O. R
O. RO.RR7      p\         P                  ! V4      p\        RR7      R 4       pVP	                  VR4      p\         P
                  P                  W4       V! VR4      p\         P
                  P                  W4       \         P
                  P                  WE4       R# )r@  rm   rk   Tr   c                 b    V'       d
   V R,          p \         P                  P                  V 4      # r3   r   N)r  rn   r   Xtests   &&r   ainv2TestLinalgInv.test_no_input_mutation.<locals>.ainv  !    fI99==##r   FNr@  r   r   r  r   r   r   	   r  r3   r3   r   r  r      r   rU  r   r   r   r  r  )r.   r  X_origr  rd   re   s   &     r   test_no_input_mutation$TestLinalgInv.test_no_input_mutation	  s    HHn$$$& .12
 	d		$ 
	$ <<5)


""1-1en


""1-


""81r   r   N)
r   r   r   r   r   r   r  r  r   r   r  s   @r   r  r    s5      0B 0Bd 2 2r   r  c                   @   a  ] tR tRt o RtR tR t]R 4       tRt	V t
R# )TestLinalgCholeskyi"  z
Tests for np.linalg.cholesky.
c                   \         P                  P                  ^ 4       \         P                  P                  W4      p\         P                  P                  V4      w  rV\         P                  ! ^V^,           4      p\         P                  ! \         P                  ! VP                  \         P                  ! V4      4      V4      p\         P                  ! WVR7      pV# )r   rK  )r   rL  rM  randr   r  r5   r   r   diagrU  )	r.   rB   r;   rl   r	  qr^  Lr\  s	   &&&&     r   rC    TestLinalgCholesky.sample_matrix'  s    
		qIINN1  yy||AIIaQFF266!##rwwqz*A.HHQ51r   c                `    R pV P                  WV\        P                  P                  4       R# )z Matrix is not positive definite.Nrj  rl  s   &&& r   assert_not_pd TestLinalgCholesky.assert_not_pd3  s#    0%sBII,A,ABr   c           	       a a ^
p\        RR7      ! \        4      oVV 3R lp\        S P                  R4       F  w  r4S P	                  WV4      pV! V4       K!  	  V! \
        P                  ! R4      4       RpS P                  S\
        P                  ! R	\
        P                  R7      34       S P                  VS\
        P                  ! R
\
        P                  R7      34       S P                  VS\
        P                  ! ^
\
        P                  R7      34       S P                  S\
        P                  ! ^\
        P                  R7      P                  ^^4      34       R# )z
Test np.linalg.cholesky
Tr   c                 \  < \        V 4      pS! V 4      pR pSP                  VR4        \        P                  P	                  W!^
R7       V'       d   \        P                  ! V\        P                  ! VP                  4      4      p^\        P                  ! V P                  4      P                  ,          p\        P                  P                  V VVVR7       SP                  4       ;_uu_ 4        S! V 4       RRR4       R#   \
         d    Rp Li ; i  + '       g   i     R# ; i)Frj   r  Tr  N)r   r  r   r  r  r  r   conjr   r  r;   r  r  r`   )r   rd   re   r  r  r  rb   r.   s   &     r   r  6TestLinalgCholesky.test_linalg_cholesky.<locals>.check?  s    &q)H(C!&%%c3/*

99#?A : C "ffS"''#%%.1!''!2!=!==


**##	 +  %%''a ('! " *%)"*  (''s   !D 4	DDDD+	r  r   ri   Nr  r   r  )r   r   r   r   rC   r   rq   rm  r  r   rs  r  r{  r  rA   )r.   r:   r  r;   rl   r   rnrb   s   f      @r   test_linalg_cholesky'TestLinalgCholesky.test_linalg_cholesky7  s   
 T"?3	< $DKK6LE""1U3A!H 7
 	bhhvurwwvRZZ'H&JK 	E!#rxx!@ B	D 	$$R&(ggb

&C%E	G 	5GGARZZ8@@AFH	Jr   r   N)r   r   r   r   r   rC   r  r   r  r   r   r  s   @r   r  r  "  s+     
C :J :Jr   r  c                      a  ] tR tRt o RtR tR tR tRR lt]	R 4       t
]	R	 4       t]	R
 4       t]	R 4       t]	R 4       tRtV tR# )TestLinalgEigenSystemsiu  z"
Tests for np.linalg.eig/eigvals.
c                   V P                  W4      p\        P                  ! V4      p\        P                  ! \        P                  ! VP
                  ^ ,          VP
                  ^,          ^4      4      pVR,          WV&   \        P                  ! \        P                  ! VP
                  ^ ,          VP
                  ^,          R4      4      pVRR WV&   \        P                  ! WRVR7      pV# )r   :r3   NNNrK  r   )r=   r   r  rS  rT  ry   rU  )r.   rB   r;   rl   vr\  rb  s   &&&&   r   rC   $TestLinalgEigenSystems.sample_matrixz  s    q(GGAJjj
AGGAJ:;2jj
AGGAJ;<3BHHQ51r   c                <    VR ,           pV P                  W#V4       R# )z+() argument must not cause a domain change.N)rg  rq  s   &&&& r   assert_no_domain_change.TestLinalgEigenSystems.assert_no_domain_change  s    BB%s+r   c                    a aaa VVVV 3R  lpV# )c                    < SP                   ! V !  pS! V !  pV ^ ,          pSP                  \        V4      \        V4      4       Rp\        V\        4      '       d   RpSP                  \        V4      S4       MSP                  VP
                  S4       SP                  VR4       Rp\        \        V4      4       F2  p \        P                  P                  W&,          W,          ^
R7       K4  	  ^\        P                  ! VP                  4      P                  ,          pV'       EdF   V'       Ed   Vw  rSR,          R8X  Ed   \        P                  ! \        P                   ! VP"                  ^ ,          VP"                  ^,          R4      4      p
\        P                  ! \        P                   ! VP"                  ^ ,          VP"                  ^,          ^4      4      pS! V !   \        P$                  ! W:,          4      W;&   \        P&                  ! \        P(                  ! V4      4      V\        P*                  ! VP"                  ^ ,          4      &   \        P,                  ! W94      p\        P,                  ! V	\        P(                  ! V4      4      p\        P                  P/                  VP&                  VP&                  VVR7       \        P0                  ! V	4      '       d8   \        P                  P/                  VP2                  VP2                  VVR7       MK\        P                  P/                  \        P4                  ! V4      \        P4                  ! V4      VVR7       SP7                  4       ;_uu_ 4        S! V !   RRR4       R#   \         d    Rp EK  i ; i  + '       g   i     R# ; i)	r   FTrm   r  hr  Nr   )r   rS   rM   rO  r  ndimr  rs   r   r  r  r  r  r;   r  rS  rT  ry   r  realr  diag_indicesr   r  iscomplexobjimagsortr`   )rc   rd   re   r   res_is_tupler  r   r  rZ   r  idxlidxulhsrhsrb   expected_res_lenrr  r.   s   *             r   r  3TestLinalgEigenSystems._check_worker.<locals>.check  s   }}d+H,CQAS]CH5 L#u%%#  S+;<  +;< %%c3/!&3x=).JJ==" > 6 *$ RXXagg.999J!!<DA Bx3!zz"&&QWWQZ*LM!zz"&&QWWQZ*KLt #%''!'"2 :<9L"//!''!*56&&,C&&BGGAJ/CJJ..''	 /  q))

22HHHH!+!+	 3  JJ..)''	 /  %%''t ('G & .)-&.F (''s   .NN2N/.N/2O	r   )r.   rb   rr  r  check_for_domain_changer  s   ffff& r   _check_worker$TestLinalgEigenSystems._check_worker  s    [	 [	x r   Nc           
        ^
p\        RR7      ! V4      pV P                  WaVV4      p\        V P                  R4       F  w  rV P	                  WXV	4      p
V! V
4       K!  	  \
        P                  \
        P                  3 F  pV! \
        P                  ! RVR7      4       V P                  V\
        P                  ! R	VR7      34       V P                  W\
        P                  ! R
\
        P                  R7      34       V P                  W\
        P                  ! ^
VR7      34       V P                  V\
        P                  ! RR.\
        P                   \
        P"                  ..VR7      34       K  	  V'       d   \
        P                  ! ^R.^^..4      pV! VP%                  \
        P&                  4      4       V! V4      w  rV P)                  \
        P*                  ! VP,                  4      4       \
        P                  \
        P.                  3 F%  pV P1                  WVP%                  V4      34       K'  	  R# R# )z
Test np.linalg.eig
Tr   r  ri   r@         @Nr  r   r  r  )r   r  r   r   rC   r   r   r   rq   rm  r  rs  r  r{  r~  rU  infnanr8   r   r  anyr  r   r  )r.   rr  funcr  r  r:   rb   r  r;   rl   r   tyr	  lr^  s   &&&&&          r   checker_for_linalg_eig-TestLinalgEigenSystems.checker_for_linalg_eig  s   
 T"4(""50@#:<
 $DKK6LE""1U3A!H 7
 ::r||,B "((6,- ""52776+D*FG ##D%'WWV288%D$FH ((rwwr7L6NO %%e')xx"bbffbff=M0N68(: '<=! -( # 1b'Aq6*+A!((2==)*7DAOOBFF166N+ zz2::.,,T188B</J /- #r   c                6    V P                  R \        ^R4       R# )r   TN)r  r   r   s   &r   test_linalg_eig&TestLinalgEigenSystems.test_linalg_eig'  s    ##E:q$?r   c                6    V P                  R \        ^R4       R# )r   TN)r  r   r   s   &r   test_linalg_eigvals*TestLinalgEigenSystems.test_linalg_eigvals+  s    ##I~q$Gr   c                6    V P                  R \        ^R4       R# )r   FN)r  r   r   s   &r   test_linalg_eigh'TestLinalgEigenSystems.test_linalg_eigh/  s    ##FKEBr   c                6    V P                  R \        ^R4       R# )r   FN)r  r   r   s   &r   test_linalg_eigvalsh+TestLinalgEigenSystems.test_linalg_eigvalsh3  s    ##JEJr   c                  a R	 EF2  pVw  r#p\        \        P                  V4      o\        RR7      V3R l4       pV P	                  WRW44      p\        P
                  \        P                  3 F  pV P                  SVR7      ;_uu_ 4        \        P                  ! . R
O. RO. RO. RO.RVR7      p\        P                  ! V4      p	VP                  VR4      p
\        P                  P                  W4       V! VR4      p\        P                  P                  W4       V! VR4       RRR4       K  	  EK5  	  R#   + '       g   i     K  ; i)r   TFr   c                 6   < V'       d
   V R,          p S! V 4      # r  r   )r  r  meths   &&r   r  ;TestLinalgEigenSystems.test_no_input_mutation.<locals>.funcD  s    &	AAwr   )r(  r;   rm   )rl   r;   N))r   r   T)r   r3   T)r   r   F)r   r3   F)r  r3   r   r3   )r3   r  r   r   )r   r   r  r   )r3   r   r   r  )getattrr   r   r   r  r   r   subTestrU  r   r   r  r  )r.   crB   noutdomain_changer  r  r;   r  r  rd   re   r(  s   &           @r   r  -TestLinalgEigenSystems.test_no_input_mutation7  s   *A
 &'"A]299a(D$   &&tDE**bmm4\\t5\99 . , , ,"" *-E	;A  WWQZF#||Au5HJJ..q9q%.CJJ..q9!UO# :9 5%*& :99s   BD=	=Er   r   )r   r   r   r   r   rC   r  r  r  r   r  r  r!  r$  r  r   r   r  s   @r   r  r  u  s     	,^@<K| @ @ H H C C K K '$ '$r   r  c                   J   a  ] tR tRt o RtR t]R 4       t]R 4       tRt	V t
R# )TestLinalgSvdib  z
Tests for np.linalg.svd.
c                V   Vw  rEp\        \        V4      4       F5  pV P                  W',          P                  W7,          P                  4       K7  	  \        P
                  ! VP                  ^,          VP                  ^ ,          34      p\        P                  ! W4       \        P                  ! \        P                  ! WH4      V4      p	\        P                  ! VP                  4      P                  p
\        P                  P                  VV	^
V
,          ^dV
,          R7       R# )r3   r  N)rs   rM   rS   ry   r   rR  fill_diagonalr   r  r;   r  r  r  )r.   r   re   rd   ur`  vtr   sr  r  s   &&&&       r   check_reconstruction"TestLinalgSvd.check_reconstructionm  s    	r s8}%ASV\\8;+<+<= & HHaggaj"((1+./
ffRVVA\2&XXagg&11



""jz!	 	# 	
r   c           	       a a \        RR7      ! \        4      oVV 3R lp. ROpRp\        VS P                  VR4       F!  w  rErgS P	                  WEV4      pV! WR7       K#  	  Rp	S P                  V	S\        P                  ! R\        P                  R7      34       S P                  V	S\        P                  ! ^
\        P                  R7      34       S P                  S\        P                  ! RR	.\        P                  \        P                  ..\        P                  R7      34       R F-  p
\        P                  ! V
4      R3pS P!                  SV4       K/  	  R
# )z
Test np.linalg.svd
Tr   c                 D  < \        V 3/ VB pS! V 3/ VB pSP                  \        V4      \        V4      4       SP                  \        V4      ^4       SP                  VR4       Rp\	        \        V4      4       F2  p \
        P                  P                  W5,          W%,          ^
R7       K4  	  V'       d   SP                  WV4       SP                  4       ;_uu_ 4        S! V 3/ VB  RRR4       R#   \         d    Rp K  i ; i  + '       g   i     R# ; i)r   rm   Fr  TN)r  rS   rM   r  rs   r   r  r  r  r7  r`   )r   r  rd   re   r  r   rb   r.   s   &,    r   r  ,TestLinalgSvd.test_linalg_svd.<locals>.check  s    !!.v.H$V$CS]CH5SXq)%%c3/!&3x=).JJ==" > 6 * "))!(; %%''a"6" (' & .)-&. (''s   .C:&
D:D
DD	r  )r   r   ri   r@  r  N)r  )r  r  )r  r  r  r  )TFr  r   r3   r3   r   r  )r   r  r   r   rc  rs  r   r  r  r{  r   r~  rU  r  r  rq   r  )r.   r  r  r   ro   r;   fmatrl   r   r  szrc   rb   s   f           @r   test_linalg_svdTestLinalgSvd.test_linalg_svd  s3   
 T":.	#< 9 & t{{M4@ %D ++D?A!( A
  	E!#rxx!@ B	D 	$$R&(ggb

&C%E	G 	!!%#%88b"Z"&&"&&9I,J24**$> #@	A +BHHRL$'D&&ud3 +r   c                    \         P                  ! . RO. R	O. R
O. RO.RR7      p\         P                  ! V4      p\        RR7      R 4       pVP	                  VR4      p\         P
                  P                  W4       V! VR4      p\         P
                  P                  W4        \        WE4       F$  w  rg\         P
                  P                  Wg4       K&  	  R#   \         d    T P                  YT4        R# i ; i)r@  rm   rk   Tr   c                 b    V'       d
   V R,          p \         P                  P                  V 4      # r  r   r  s   &&r   r  2TestLinalgSvd.test_no_input_mutation.<locals>.func  r  r   FNr  r  r  r  )
r   rU  r   r   r   r  r  zipr  r7  r.   r  r  r  rd   re   e_ag_as   &       r   r  $TestLinalgSvd.test_no_input_mutation  s    HHn$$$& .12
 	d		$ 
	$ <<5)


""1-1en


""1-	8.

**34 / 	8%%ah7	8s   '3C C=<C=r   N)r   r   r   r   r   r7  r   rA  r  r   r   r  s   @r   r1  r1  b  s:     
( A4 A4F 8 8r   r1  c                   D   a  ] tR tRt o Rt]R 4       t]R 4       tRtV t	R# )TestLinalgQri  z
Tests for np.linalg.qr.
c           	       a a	 \        RR7      ! \        4      o	V	V 3R lp. R
Op\        VS P                  R4       F   w  r4pS P	                  W4V4      pV! V4       K"  	  RpS P                  VS	\        P                  ! R\        P                  R7      34       S P                  VS	\        P                  ! ^
\        P                  R7      34       S P                  S	\        P                  ! RR.\        P                  \        P                  ..\        P                  R7      34       R F*  pS P                  S	\        P                   ! V4      34       K,  	  R	# )z
Test np.linalg.qr
Tr   c                 0  < \        V 3/ VB pS
! V 3/ VB pSP                  \        V4      \        V4      4       SP                  \        V4      ^4       SP                  VR4       Rp\	        \        V4      4       F2  p \
        P                  P                  W5,          W%,          ^
R7       K4  	  V'       Ed   Vw  rg\	        \        V4      4       F5  pSP                  W5,          P                  W%,          P                  4       K7  	  \
        P                  ! Wg4      p\
        P                  ! V P                  4      P                  p	\
        P                  P                  V V^
V	,          ^dV	,          R7       SP                  \
        P                  ! \
        P                   ! VP"                  4      V4      4       SP%                  4       ;_uu_ 4        S
! V 3/ VB  RRR4       R#   \         d    Rp EK  i ; i  + '       g   i     R# ; i)r   rm   Fr  Tr  N)r  rS   rM   r  rs   r   r  r  r  ry   r   r  r;   r  r  r  	conjugater   r`   )r   r  rd   re   r  r   r  rr  r  rb   r.   s   &,        r   r  *TestLinalgQr.test_linalg_qr.<locals>.check  s    -f-H$V$C S]CH5SXq)%%c3/!&3x=).JJ==" > 6 *  "! s8}-A$$SV\\8;3D3DE . ffQlXXagg.99


**jz)	 +  ..rvvbll1336G/KL %%''a"6" ('C & .)-&.B (''s   .G/
H/H HH	r  r  ri   r@  r  Nr  r  r<  )r   r  r   r   rc  rs  r   r  r  r{  r   r~  rU  r  r  r  rq   )
r.   r  r  ro   r;   rl   r   r  r@  rb   s
   f        @r   test_linalg_qrTestLinalgQr.test_linalg_qr  s   
 T"9-3	#n ; t{{D1 D++D?A!H 2  	E!#rxx!@ B	D 	$$R&(ggb

&C%E	G 	!!%#%88b"Z"&&"&&9I,J24**$> #@	A
 +B&&urxx|o> +r   c                   \         P                  ! . RO. R	O. R
O. RO.RR7      p\         P                  ! V4      p\        RR7      R 4       pVP	                  VR4      p\         P
                  P                  W4       V! VR4      p\         P
                  P                  W4       \        WE4       F$  w  rg\         P
                  P                  Wg4       K&  	  R# )r@  rm   rk   Tr   c                 b    V'       d
   V R,          p \         P                  P                  V 4      # r  r  r  s   &&r   r  1TestLinalgQr.test_no_input_mutation.<locals>.funcI  s     fI99<<?"r   FNr  r  r  r  )r   rU  r   r   r   r  r  rF  rG  s   &       r   r  #TestLinalgQr.test_no_input_mutation@  s    HHn$$$& .12
 	d		# 
	# <<5)


""1-1en


""1-H*HCJJ&&s0 +r   r   N)
r   r   r   r   r   r   rR  r  r   r   r  s   @r   rL  rL    s5      V? V?p 1 1r   rL  c                   :   a  ] tR tRt o RtRR ltR tR tRtV t	R# )	TestLinalgSystemsiZ  zi
Base class for testing "system" solvers from np.linalg.
Namely np.linalg.solve() and np.linalg.lstsq().
c                t    V'       d   R MRpV: RV: R2pV P                  W#V\        P                  4       R# )rv  r   rw  z%() only supported on 1 and 2-D arraysNrp  rx  s   &&&&&  r   assert_wrong_dimensions_1D,TestLinalgSystems.assert_wrong_dimensions_1Da  s-     )t>DdK%sF,>,>?r   c                `    R pV P                  WV\        P                  P                  4       R# )z<Incompatible array sizes, system is not dimensionally valid.Nrj  rl  s   &&& r   assert_dimensionally_invalid.TestLinalgSystems.assert_dimensionally_invalidg  s#    L%sBII,A,ABr   c                Z    R V,          pV P                  W#V\        P                  4       R# )zAnp.linalg.%s() only supports inputs that have homogeneous dtypes.Nrp  rq  s   &&&& r   assert_homogeneous_dtypes+TestLinalgSystems.assert_homogeneous_dtypesl  s%    QTXX%sF,>,>?r   r   Nr  )
r   r   r   r   r   r[  r^  ra  r   r   r  s   @r   rY  rY  Z  s"     @C
@ @r   rY  c                   D   a  ] tR tRt o Rt]R 4       t]R 4       tRtV t	R# )TestLinalgLstsqiq  z
Tests for np.linalg.lstsq.
c                  a aaa \        RR7      ! \        4      oVV 3R lo. ROp\        S P                  4      pRR.p\        V4      oRpVVV 3R lpV F  p\	        V4      p\	        S4      pS P                  WgV4      p	V! W4       Vw  r\        W4      pV
^8w  g   KK  V^8w  g   KT  V^,
          pS P                  WgWR7      p	V! W4       S P                  WgWR	7      p	R
V,          pW,          pV! WVR7       K  	  RR.RR.RR.RR..pV FD  w  p	p\        P                  ! V	4      \        P                  ! V4      3pS P                  SV4       KF  	  \        P                  ! R
R.RR..\        P                  R7      pSVV33 Rp\        P                  ! ^^.^^..\        P                  R7      pS P                  VSVV34       S P                  VSVV34       \        P                  ! ^^.^^..\        P                  R7      pS P                  VSVV34       S P                  VSVV34       \        P                  ! ^^.\        P                  R7      pS P!                  VSVV34       \        P                  ! R
R.\        P"                  \        P$                  ..\        P                  R7      pS P'                  SVV34       S P'                  SVV34       \        P                  ! R
R.\        P                  R7      pSVV33 \        P                  ! ^^.^^..^^.^^...\        P                  R7      pS P)                  VSVV34       \        P                  ! R
.\        P                  R7      p\        P                  ! R
.R.R..\        P                  R7      pS P+                  SVV34       S P+                  SVV34       R# )z
Test np.linalg.lstsq
Tr   c           
        < \        W3/ VB pS! W3/ VB pSP                  \        V4      \        V4      4       SP                  \        V4      ^4       SP                  VR4       Rp SP                  V^,          V^,          4       \	        \        V4      4       F2  p \
        P                  P                  WF,          W6,          ^
R7       K4  	  V'       d   Vw  rxr. R
Op SP                  W^,          4       V F]  p\        W6,          \
        P                  4      '       g   K+  SP                  WF,          P                  W6,          P                  4       K_  	  \
        P                  ! V P                  4      P                   p \
        P"                  ! W4      p\
        P                  P%                  VV^
V,          ^
V,          R7       SP/                  4       ;_uu_ 4        S! W3/ VB  R	R	R	4       R	#   \         d    Rp EKr  i ; i  \         d    Rp ELPi ; i  \         d.    SP                  \        Y^,          ,
          4      ^8  4        Li ; i  \         Ed<    T EF0  p \
        P                  P%                  Y6,          YF,          ^dT,          ^dT,          R7       MP  \         dC    \
        P&                  P)                  T 4      pSP+                  ^
T,          RT,          4        Mi ; i\
        P&                  P-                  T\
        P"                  ! Y^ ,          4      ,
          4      p\
        P&                  P-                  T\
        P"                  ! Y4      ,
          4      p\
        P                  P%                  TTRR7       EK3  	   ELi ; i  + '       g   i     R	# ; i)r   rj   Fr  Tr  r@  r  r  N)r   r3   r   )r  rS   rM   r  rs   r   r  r  r  rO  ndarrayry   r  absr  r;   r  r   r  r   r!  assertGreaterr  r`   )r	  r
  r  rd   re   r  r   xresrV  r6  out_array_idxr  r  r,  res_expectedres_gotrb   r.   s   &&,              r   r  0TestLinalgLstsq.test_linalg_lstsq.<locals>.check  s   #A3F3H''C S]CH5SXq)%%c3/!&
*  Q!5s8}-A2

AAFHKb B : . ""% !*	A$$TA;7*%hk2::>> ,,SV\\8;;L;LM +  XXagg.99
$= &&,CJJ..*_*_	 / F %%''a%f% ('A * 2-1*2 " *%)"*  & AOOC{(:$;a$?@A  & = +
JJJ66 ( #%(:%5%(:%5	 7   . J "		q 1A ..rAvZIJ (*yy~~q1+ 66(8"$))..RVVA\1A"B 

22(' 3 =+ +	=: (''s   +7H #.H H 'A H) ,6H) AI$ ,
N. HH HH H&%H&)5I! I!$N+7=J54N+5A
L?N+LB%N+*N+.N?	rm   rj   r  c                    < RpV Fi  p\        S	4      pS
P                  V P                  ^ ,          V3W4      pS! W3/ VB  \        S	4      pVR,          P                  VR7      pS! W3/ VB  Kk  	  R# )r3   rk   Nr3      rn   r   )nextrc  ry   r   )r	  dtr  b_sizesb_sizeb_orderr
  r|   r  cycle_orderr.   s   &&,     r   inner_test_loop_fn=TestLinalgLstsq.test_linalg_lstsq.<locals>.inner_test_loop_fn  sz    G! {+//WWQZ("7a%f% {+glll1a'' "r   r  r  r@  r  r        @      @ri   r  Nr  r=  r  r>  r3   r3   r   )r   r  r   r   ru  rc  rN  r   rq   r  rU  r   r  rs  r   ra  r{  r  r  r~  r[  r^  )r.   r  cycle_dtordersspecific_condr{  a_sizerv  a_orderr	  rB   r:   rY  rP  r  approx_half_rank_rcondemptiesr   rc   okr  badoneDbad1Dbad2Drb   r  rz  s   f                        @@@r   test_linalg_lstsq!TestLinalgLstsq.test_linalg_lstsq  s   
 T"<0X	&x ; %sFm 	($ FhB;'G ++F@A q%DAIE Av!q& AI// 0 1 #1) // 0 B ]*).&"1)?AE N 
				
 DAqHHQK!-D&&ud3 
 XXBx"b*"**= 	Bx  hhAA'rxx8EB95EC95 hhAA'rzz:&&r52s)<&&r53)< hh1vRZZ0$$Rb	: hhR
RVVRVV$45RZZH!!%"c3!!%#r3 xxR

3Dzhh!Q!Q(Aq6Aq6*:;2::N''EB9= "RZZ02$rd+2::>))%"e=))%"e=r   c           	     *   \         P                  ! . RO. R	O. R
O. RO. RO. RO.RR7      p\         P                  ! V4      p\         P                  ! . RO4      p\        RR7      R 4       pV! WR4       \         P                  P                  W4       R# )r@  rm   rk   Tr   c                 b    V'       d
   V R,          p \         P                  P                  W4      # r  r  r  yr  s   &&&r   f2*TestLinalgLstsq.test_issue3368.<locals>.f2n  !    fI99??1((r   FN)r@  g)\(@gGz@)r@  g@r  )r@  g      @gffffff@)r@  gffffff?g(\@)r@  gzG@g)\(
@)r@  g(\?g@)r@  r  r~  r        @g      @)r   rU  r   r   r  r  )r.   r  r  r  r  s   &    r   test_issue3368TestLinalgLstsq.test_issue3368b  s~    HH&&&&&&)
 145 HH-.	d		) 
	) 	1


""1-r   r   N)
r   r   r   r   r   r   r  r  r   r   r  s   @r   rd  rd  q  s5      `> `>D . .r   rd  c                   D   a  ] tR tRt o Rt]R 4       t]R 4       tRtV t	R# )TestLinalgSolveiy  z
Tests for np.linalg.solve.
c                B  a a \        RR7      ! \        4      oVV 3R lp. ROp\        VS P                  R4       F}  w  r4pS P	                  W4V4      pRp\        VR4       FS  w  rS P	                  VP
                  ^ ,          V3WI4      p
V! Wj4       V
R,          P                  V	R7      pV! Wk4       KU  	  K  	  S! \        P                  ! R4      \        P                  ! R4      4       \        P                  ! RR.RR..\        P                  R7      pS! W4       R	p\        P                  ! ^^ .^ ^..\        P                  R7      pS P                  VSW34       S P                  VSW34       \        P                  ! ^^.^^..\        P                  R7      pS P                  VSW34       S P                  VSW34       \        P                  ! ^^ .\        P                  R7      pS P                  VSW34       \        P                  ! RR.\        P                   \        P"                  ..\        P                  R7      pS P%                  SW34       S P%                  SW34       \        P                  ! RR
.\        P                  R7      pS! W4       \        P                  ! ^^.^^..^^.^^...\        P                  R7      pS P'                  VSW34       \        P                  ! R.\        P                  R7      p\        P                  ! R.R
.R..\        P                  R7      pS P)                  SVV34       S P)                  SVV34       S P	                  R\        P                  R^R7      pS P+                  SVV34       R# )z
Test np.linalg.solve
Tr   c                 ~  < \        W3/ VB pS! W3/ VB pS	P                  VR 4       Rp \        P                  P	                  WC^
R7       V'       d   S	P                  VP                  VP                  4       \        P                  ! W4      p\        P                  ! V P                  4      P                  p\        P                  P                  VV^
V,          ^dV,          R7       S	P                  4       ;_uu_ 4        S! W3/ VB  RRR4       R#   \
         d    Rp Li ; i  + '       g   i     R# ; i)rm   Fr  Tr  N)r  r  r   r  r  r  rS   ry   r   r  r;   r  r  r`   )
r   r   r  rd   re   r  r  r  rb   r.   s
   &&,     r   r  0TestLinalgSolve.test_linalg_solve.<locals>.check  s   #A3F3H''C %%c3/!&*

99 : , "  HNN; ffQnXXagg.99


**jz)	 +  %%''a%f% ('7 " *%)"*6 (''s   !D 
D+D('D(+D<	r  rk   r@          ri   r  r  r~  rj   r  N)r  r  r  r  rr  rt  r  r  r  )r   r  r   r   rc  ry   r   r   rq   rU  r   r  rs  r   ra  r{  r  r  r~  r[  r^  r  )r.   r  r  ro   r;   rl   r	  rw  rx  ry  r
  r|   r  r  r  ok_oneDr  r  rb   s   f                 @r   test_linalg_solve!TestLinalgSolve.test_linalg_solve~  s   
 T"<0(	&V ) t{{D1 D++D?AG#*7D#9//WWQZ(%:a glll1a $: 2  	bhhv/ XXBx"b*"**= 	b  hhAA'rxx8EB95EC95 hhAA'rzz:&&r52)<&&r53)< hh1vRZZ0$$R	: hhR
RVVRVV$45RZZH!!%"3!!%#3 ((B82::6bhh!Q!Q(Aq6Aq6*:;2::N''EB9= "RZZ02$rd+2::>))%"e=))%"e= ++FBJJ!+L%%eeR[9r   c                f   \         P                  ! . RO. R	O. R
O. RO.RR7      p\         P                  ! V4      p\         P                  ! . RO4      p\         P                  ! V4      p\        RR7      R 4       pVP	                  WR4      p\         P
                  P                  W4       \         P
                  P                  W44       V! WR4      p\         P
                  P                  W4       \         P
                  P                  W44       \         P
                  P                  Wg4       R# )r@  rm   rk   Tr   c                 b    V'       d
   V R,          p \         P                  P                  W4      # r  r  r  s   &&&r   r  4TestLinalgSolve.test_no_input_mutation.<locals>.func  r  r   FN)r@  r3   r3   r3   )r  r3   r3   r3   )r  r   r3   r3   )r@  r   r   r3   )r@  r  r~  r   r  )r.   r  r  r  y_origr  rd   re   s   &       r   r  &TestLinalgSolve.test_no_input_mutation  s    HHm###& .12
 HH_%	d		) 
	) <<e,


""1-


""1-1


""1-


""1-


""81r   r   N)
r   r   r   r   r   r   r  r  r   r   r  s   @r   r  r  y  s5      r: r:h 2 2r   r  c                   D   a  ] tR tRt o Rt]R 4       t]R 4       tRtV t	R# )TestLinalgPinvi  z
Tests for np.linalg.pinv.
c           	     D  a a \        RR7      ! \        4      oVV 3R lp. ROpRp\        VS P                  R4       Fo  w  rEpS P	                  WEV4      pV! V4       Vw  rV^8w  g   K-  V	^8w  g   K6  \        W4      p
S P	                  WEVVR7      pRV,          pW,          pV! W|R7       Kq  	  R F  pV! \        P                  ! V4      4       K!  	  R	pS P                  VS\        P                  ! R\        P                  R
7      34       S P                  VS\        P                  ! ^
\        P                  R
7      34       S P                  S\        P                  ! RR.\        P                  \        P                   ..\        P                  R
7      34       R# )z
Test np.linalg.pinv
Tr   c                   < \        V 3/ VB pS	! V 3/ VB pS
P                  VR 4       Rp \        P                  P	                  W2^
R7       V'       dO   S
P                  VP                  VP                  4       \        P                  ! W04      p S
P                  V4       S
P+                  4       ;_uu_ 4        S	! V 3/ VB  RRR4       R#   \
         d    Rp Li ; i  \
         Edc    ^\        P                  ! T P                  4      P                  ,          pS	! T4      p\        P                  P                  TT ^
T,          ^dT,          R7       T P                  ^ ,          T P                  ^,          8  d   \        RR7      ! \        4      pT! T \        P                   ! T P                  ^ ,          4      P#                  T P                  4      3/ TB ^ ,          p\        P                  P                  TT^
T,          ^dT,          R7       S
P%                  \        P&                  P)                  Y2,
          4      T4        ELi ; i  + '       g   i     R# ; i)rm   Fr  Tr  r   N)r  r  r   r  r  r  rS   ry   r   r  r  r;   r  r  r   r  rT  r8   
assertLessr   r  r`   )r   r  rd   re   r  r  r  r  
lstsq_pinvrb   r.   s   &,       r   r  .TestLinalgPinv.test_linalg_pinv.<locals>.check  s
   "1//H$V$C %%c3/!&*

99 : , "   HNN;
 ffSnP2237< %%''a"6" ('e " *%)"** & P!"RXXagg%6%A%A!AJ*CJJ..*_ :-	 /  wwqzQWWQZ/ !$T 2< @%*rvv !
 ,,2F !-)&4 -3&4 56&7
 

22&!#j!$z!1	 3  OOBIINN3>$BJO5P: (''s0   !C C" ;
ICC"E*III$	r  r  r  r@  r}  r  ri   r  Nr  )r=  r>  r  )r   r  r   r   rc  rN  r   rq   rs  r  r  r{  r   r~  rU  r  r  )r.   r  r  r  ro   r;   rl   r   rB   r:   rY  r  r  r@  r  rb   s   f              @r   test_linalg_pinvTestLinalgPinv.test_linalg_pinv  ss   
 T";/@	#H ;  t{{D1 D ++D?A!HDAAv!q&A	//U:G 0 I]*).&a6 2  #B"((2, #  	E!#rxx!@ B	D 	$$R&(ggb

&C%E	G 	!!%#%88b"Z"&&"&&9I,J24**$> #@	Ar   c                   \        R R7      R 4       p\        P                  ! . RO. RO. RO. R	O.RR7      p\        P                  ! V4      pVP	                  R
4      pVP                  V4      p\        P                  P                  W#4       V! V4      p\        P                  P                  W#4       \        P                  P                  WV4       R# )Tr   c                 N    \         P                  P                  V ^ ,          4      # r  r  )r  s   &r   some_fn.TestLinalgPinv.test_issue5870.<locals>.some_fn  s    99>>!A$''r   rm   rk   Nr  r  r  r  )r3   r   r   )r   r   rU  r   rA   r   r  r  )r.   r  v_datav_orig
reshaped_vrd   re   s   &      r   test_issue5870TestLinalgPinv.test_issue5870  s     
d		( 
	( >)))+ 367
 ^^I.
??:.


""62j!


""62


""81r   r   N)
r   r   r   r   r   r   r  r  r   r   r  s   @r   r  r    s7      qA qAf 2 2r   r  c                   f   a  ] tR tRt o RtR tR tR t]R 4       t	]R 4       t
]R 4       tR	tV tR
# )TestLinalgDetAndSlogdeti  z
Tests for np.linalg.det. and np.linalg.slogdet.
Exactly the same inputs are used for both tests as
det() is a trivial function of slogdet(), the tests
are therefore combined.
c                P   \        V3/ VB pV! V3/ VB p^\        P                  ! VP                  4      P                  ,          p\        P
                  P                  WTVR7       V P                  4       ;_uu_ 4        V! V3/ VB  RRR4       R#   + '       g   i     R# ; ir  rg  N)r  r   r  r;   r  r  r  r`   )r.   rb   r   r  rd   re   r  s   &&&,   r   	check_det!TestLinalgDetAndSlogdet.check_det  s    a*6*A  !''*555
 	

""3z"B !!##!v $###s    
BB%	c                0   \        V3/ VB pV! V3/ VB pV P                  \        V4      \        V4      4       V P                  \        V4      ^4       \        ^4       FI  pV P                  \        P
                  ! WV,          4      \        P
                  ! WF,          4      4       KK  	  VP                  P                  V^ ,          4      p\        P                  P                  Wt^ ,          ^
R7       ^\        P                  ! VP                  4      P                  ,          p\        P                  P                  V^,          V^,          WR7       V P                  4       ;_uu_ 4        V! V3/ VB  RRR4       R#   + '       g   i     R# ; i)r   r  r  N)r  rS   rM   rs   r   r  r;   typer  r  r  r  r  r`   )	r.   rb   r   r  rd   re   r   got_convr  s	   &&&,     r   check_slogdet%TestLinalgDetAndSlogdet.check_slogdet  s3   !!.v.A   	XC1S1% qA',.  77<<A'


11qk 	2 	, !''*555



""FHQKj 	# 	C !!##!v $###s   0
FF	c           	        . ROp\        W@P                  R4       F   w  rVpV P                  WVV4      pV! W84       K"  	  \        V P                  R4       F%  w  rg\        P                  ! RVR7      pV! W84       K'  	  V! V\        P
                  ! R4      4       V P                  W\        P                  ! R	\        P                  R7      34       V P                  W\        P                  ! ^
\        P                  R7      34       V P                  V\        P                  ! RR.\        P                  \        P                  ..\        P                  R7      34       R# )
r3   r  ri   r@  r  N)r  )r   r   r  r  r  r  )r   r   rc  r   rR  rq   rs  r  r  r{  r   r~  rU  r  r  )	r.   r  r  rb   r  ro   r;   rl   r   s	   &&&&     r   do_testTestLinalgDetAndSlogdet.do_test  s    ) {{D1 D ++D?A%O 2 $DKK6LEu-A%O 7
 	eRXXf%& 	!#rxx!@ B	D 	$$R&(ggb

&C%E	G 	!!%#%88b"Z"&&"&&9I,J24**$> #@	Ar   c                l    \        R R7      ! \        4      pV P                  RV P                  V4       R# )Tr   r  N)r   r  r  r  r.   rb   s   & r   test_linalg_det'TestLinalgDetAndSlogdet.test_linalg_det  s%    T":.UDNNE2r   c                l    \        R R7      ! \        4      pV P                  RV P                  V4       R# )Tr   r  N)r   r  r  r  r  s   & r   test_linalg_slogdet+TestLinalgDetAndSlogdet.test_linalg_slogdet  s'    T">2Y 2 2E:r   c                   \         P                  ! . RO. R	O. R
O. RO.RR7      p\         P                  ! V4      p\        RR7      R 4       pVP	                  VR4      p\         P
                  P                  W4       V! VR4      p\         P
                  P                  W4       \         P
                  P                  WE4       R# )r@  rm   rk   Tr   c                 b    V'       d
   V R,          p \         P                  P                  V 4      # r  r  r  s   &&r   r  <TestLinalgDetAndSlogdet.test_no_input_mutation.<locals>.func  s#    fI99$$Q''r   FNr  r  r  r  r  r.   r  r  r  rd   re   s   &     r   r  .TestLinalgDetAndSlogdet.test_no_input_mutation  s    HHn$$$& .12
 	d		( 
	( <<5)


""1-1en


""1-


""81r   r   N)r   r   r   r   r   r  r  r  r   r  r  r  r   r   r  s   @r   r  r    sX     !FAB 3 3 ; ; 2 2r   r  c                   4   a  ] tR tRt o Rt]R 4       tRtV tR# )TestLinalgNormi   z
Tests for np.linalg.norm.
c                p  a a
 \        RR7      ! \        4      o
V
V 3R lp. ROpR\        P                  \        P                  ) ^ ^R^R^RR.p\	        VS P
                  V4       F   w  rEpS P                  WE4      pV! WvR7       K"  	  \	        S P
                  V4       F'  w  rVS P                  ^
V4      R,          pV! WvR7       K)  	  . ROpR\        P                  \        P                  ) ^R^R.p\	        VS P
                  RV4       F!  w  rErS P                  WEV4      pV! WvR7       K#  	  R.p\	        S P
                  VR4       FK  w  rVpS P                  RWX4      pV! VR	,          VR7       V! VR,          VR7       V! VR,          VR7       KM  	  \	        S P
                  VR4       Ff  w  rVp\        P                  ! RWXR
7      pS P                  S
! Wv4      R4       \        P                  ! RWXR
7      pS P                  S
! Wv4      R4       Kh  	  Rp	S P                  V	S
\        P                  ! R\        P                  R7      34       S P                  V	S
\        P                  ! ^\        P                  R7      P                  ^^^4      34       S P!                  S
\        P"                  ! RR.\        P                  \        P$                  ..\        P                  R7      ^34       S P'                  S
\        P"                  ! RR.RR..\        P                  R7      ^34       R# )z
Test np.linalg.norm
Tr   c                   < \        V 3/ VB pS! V 3/ VB pSP                  \        P                  ! V4      '       * 4       ^\        P                  ! V P
                  4      P                  ,          p\        P                  P                  W2VR7       SP                  4       ;_uu_ 4        S! V 3/ VB  RRR4       R#   + '       g   i     R# ; ir  )
r  r  r   r  r  r;   r  r  r  r`   r   r  rd   re   r  rb   r.   s   &,   r   r  .TestLinalgNorm.test_linalg_norm.<locals>.check,      "1//H$V$C OO 445RXXagg.999J JJ&&s:&F %%''a"6" ('''   +
B??C	Ng@)r  :NNr   r  :Nr   NrK  r  r  ri   r@  r  r~  r  )r3   r   r  r   r  g333333r  )   rs  )rn   :r   NN)r3   :r   Nr   r  r  r  )r   r  r   r  r   r   r=   rc  rq   rS   rs  r  r  r[  r   rA   r~  rU  r  r  )r.   r  r  	nrm_typesro   r;   nrm_typer   rl   r  rb   s   f         @r   test_linalg_normTestLinalgNorm.test_linalg_norm%  s   
 T";/	#" 266BFF7Aq"aQTJ	 t{{I6 "D""4/A!" 7 Y/ E""2u-c2A!" 0 ;266BFF7Ar1b9	 t{{D)< )D ++D?A!" = F	Y5 #EU++HeCA!B%X& !E() !G*(+ 6  Y5 #EUU8AU1/5u:AU1/5	 6  	E!#rxx!@ B	D 	''"**&&-g1a'	 	!!%#%88b"X7G,H24**$>?@#B	C
 	%%ebhhR2r(7K=?ZZ/IJK.M 	Nr   r   N)	r   r   r   r   r   r   r  r   r   r  s   @r   r  r     s"      `N `Nr   r  c                   4   a  ] tR tRt o Rt]R 4       tRtV tR# )TestLinalgCondi  z
Tests for np.linalg.cond.
c           	       a a \        RR7      ! \        4      oVV 3R lpR\        P                  \        P                  ) ^R^R.pRR.p\	        VS P
                  RV4       F!  w  rErgS P                  WEV4      pV! WR7       K#  	  . ROp\	        VS P
                  R4       F   w  rEpS P                  WEV4      pV! V4       K"  	  R F*  p	S P                  S\        P                  ! V	4      34       K,  	  \        P                  ! ^^ .^ ^ ..\        P                  R7      p
V! V
4       V! V
^R7       \        P                  ! ^ ^ .^ ^ ..\        P                  R7      p
V! V
RR7       \        P                  ! 4       ;_uu_ 4        \        P                  ! R^ .^ R	..\        P                  R7      p\        P                  ! R
\        4       V! V4       RRR4       RpS P                  VS\        P                   ! R\        P"                  R7      34       S P%                  VS\        P                   ! ^
\        P                  R7      34       S P'                  S\        P                  ! RR.\        P                  \        P(                  ..\        P                  R7      34       S P+                  S\        P                  ! RR.RR..\        P                  R7      ^34       R#   + '       g   i     EL; i)z
Test np.linalg.cond
Tr   c                   < \        V 3/ VB pS! V 3/ VB pSP                  \        P                  ! V4      '       * 4       ^\        P                  ! V P
                  4      P                  ,          p\        P                  P                  W2VR7       SP                  4       ;_uu_ 4        S! V 3/ VB  RRR4       R#   + '       g   i     R# ; ir  )
r#  r  r   r  r  r;   r  r  r  r`   r  s   &,   r   r  .TestLinalgCond.test_linalg_cond.<locals>.check  r  r  Nr  )r"  ri   gg?ignorer!  r@  r  r~  r  r   r  r  r  )r  r  r  r  r<  r  )r   r#  r   r  r   r   rc  r  rq   rU  r   rH   rI   rJ   RuntimeWarningrs  r  r  r{  r~  r  r  )r.   r  psr  ro   r;   rl   r"  r   r@  rk  r  rb   s   f           @r   test_linalg_condTestLinalgCond.test_linalg_cond  sv    T";/	#" BFFRVVGQAr2  t{{D"5 "D++D?A!M 6
 3t{{D1 D++D?A!H 2
 +B&&urxx|o> + HHq!fq!f%RZZ8aa1HHq!fq!f%RZZ8a2
 $$&&61+3x0

CA!!(N;!H '
  	E!#rxx!@ B	D 	$$R&(ggb

&C%E	G 	!!%#%88b"Z"&&"&&9I,J24**$> #@	A
 	%%ebhhR2r(7K=?ZZ/IJK.M 	N+ '&&s   AK**K;	r   N)	r   r   r   r   r   r   r  r   r   r  s   @r   r  r    s"      KN KNr   r  c                   D   a  ] tR tRt o Rt]R 4       t]R 4       tRtV t	R# )TestLinalgMatrixRanki  z"
Tests for np.linalg.matrix_rank.
c           	       a a \        RR7      ! \        4      oVV 3R lp. ROp\        VS P                  R4       EF  w  r4pS P	                  W4V4      pV! V4       Rp\        ^\        V4      ^,
          4       EFj  pS P	                  W4WXR7      pS P                  S! V4      V4       V! V4       VP                  w  rRVR&   \        P                  ! \        P                  ! W4      4      p\        P                  ! V4      '       d_   R\        P                  P                  V4      ,           R	,           R	\        P                  P                  V4      ,          ,           pRV^ &   M+R\        P                  P                  V4      ,           pR
V^ &   VP                  V4      Wk^ ,          RV V^,          RV 3&   S P                  S! Wg4      V^,
          4       V! WgR7       EKm  	  RVR&   S P                  S! V4      ^ 4       V! V4       \        P                  ! V4      '       d   RVR&   MR
VR&   S P                  S! Wg4      ^ 4       V! WgR7       EK  	  S P                   F`  p\        P                   ! ^VR7      pS P                  S! V4      ^ 4       V! V4       RV^ &   S P                  S! V4      ^4       V! V4       Kb  	  R F4  pR F+  pS P#                  S\        P$                  ! V4      V34       K-  	  K6  	  RpS P'                  VS\        P(                  ! R\        P*                  R7      34       S P-                  VS\        P(                  ! ^\        P.                  R7      P1                  ^^^4      34       S P3                  S\        P4                  ! RR.\        P6                  \        P8                  ..\        P.                  R7      34       R# )z
Test np.linalg.matrix_rank
Tr   c                    < \        V 3/ VB pS! V 3/ VB p\        P                  P                  W24       SP	                  4       ;_uu_ 4        S! V 3/ VB  R R R 4       R #   + '       g   i     R # ; ir   )r(  r   r  r  r`   )r   r  rd   re   rb   r.   s   &,  r   r  ;TestLinalgMatrixRank.test_linalg_matrix_rank.<locals>.check  sb    )!6v6H$V$C JJ&&s5 %%''a"6" ('''s   
A""A3	r  vIh%<=r  r  r@                ?g+=N)r'  ri   r&  r  r  )rn   rn   y+=+=)r   r   r<  )Nr  r  )r   r(  r   r   rc  rs   rN  rS   ry   r   rS  rT  r  rL  r  r8   rR  r  rq   rs  r  r  r[  r   rA   r~  rU  r  r  )r.   r  r  ro   r;   rl   r   r'  r   rB   r:   rb  r   rv  r@  r  rb   s   f               @r   test_linalg_matrix_rank,TestLinalgMatrixRank.test_linalg_matrix_rank  sB    T"#56
	# ; t{{D1 D ++D?A!H C1c$i!m,//U/K  q1-a ww$jj.??1%%RYY^^A..4biinnQ//0A *AaDRYY^^A..A AaD,-HHUOa&!*c!fRaj()  qA6a!!- -0 AdGU1Xq)!Hq!!*&	!&	U1]A.!W 2^ ++B!B'AU1Xq)!HAaDU1Xq)!H  +B$**5288B<2EF % +  	E!#rxx!@ B	D 	''"**&&-g1a'	 	!!%#%88b"Z"&&"&&9I,J24**$> #@	Ar   c                   \         P                  ! . RO. R	O. R
O. RO.RR7      p\         P                  ! V4      p\        RR7      R 4       pVP	                  VR4      p\         P
                  P                  W4       V! VR4      p\         P
                  P                  W4       \         P
                  P                  WE4       R# )r@  rm   rk   Tr   c                 b    V'       d
   V R,          p \         P                  P                  V 4      # r  r%  r  s   &&r   r  9TestLinalgMatrixRank.test_no_input_mutation.<locals>.funcT	  s#    fI99((++r   FNr  r  r  r  r  r  s   &     r   r  +TestLinalgMatrixRank.test_no_input_mutationG	  s     HHn$$$& .12
 	d		, 
	, <<5)


""1-1en


""1-


""81r   r   N)
r   r   r   r   r   r   r  r  r   r   r  s   @r   r  r    s7      bA bAH 2 2r   r  c                   :   a  ] tR tRt o RtR t]R 4       tRtV t	R# )TestLinalgMatrixPowerid	  z#
Tests for np.linalg.matrix_power.
c                    V! V^ ,          ^4       V P                  \        P                  4      ;_uu_ 4        V! V!   RRR4       R#   + '       g   i     R# ; i)r   Nr   r
   r   )r.   rb   rc   s   &&&r   assert_int_exponenent+TestLinalgMatrixPower.assert_int_exponenenti	  s=    d1gqv11224L 3222s   A		A	c           	       a a \        R R7      ! \        4      oVV 3R lp. ROpRR.\        \        R^
4      4      ,           ^^!.,           p\	        W#S P
                  R4       F@  w  rErgS P                  WFV4      pV! W4       \        P                  ! RWgR7      pV! W4       KB  	  Rp	S P                  V	S\        P                  ! R\        P                  R7      ^34       S P                  V	S\        P                  ! R\        P                  R7      ^34       \        P                  ! R4      ^3p
RpS P                  SW4       S P                  V	S\        P                  ! ^
\        P                  R7      ^34       S P                  S\        P                  ! R4      R34       S P!                  S\        P"                  ! R	^ .^^..4      R34       R
# )Tr   c                 p  < \        W4      pS! W4      pSP                  VR 4       ^\        P                  ! V P                  4      P
                  ,          p\        P                  P                  W2WDR7       SP                  4       ;_uu_ 4        S! W4       RRR4       R#   + '       g   i     R# ; i)rj   r  N)	r+  r  r   r  r;   r  r  r  r`   )r   pwrrd   re   rl  rb   r.   s   &&   r   r  =TestLinalgMatrixPower.test_linalg_matrix_power.<locals>.checkt	  s    *12H-C %%c3/bhhqww'222CJJ&&s3&I %%''a ('''s   	B$$B5	r  rK  r*  ri   zinput must be a square array333333?r  N)r  r  r  r  iir  r  )r   r  r   )r   r+  listrs   r   r   rc  r   rq   rs  r  r  rg  r{  r   r  r  rU  )r.   r  r  powersro   r  r;   rl   r   r  rc   r   rb   s   f           @r   test_linalg_matrix_power.TestLinalgMatrixPower.test_linalg_matrix_powerp	  s   T"#67	 )sd5b>22b"X= t{{D9 $Du++D?A!Mu:A!M	 :  	E!#rxx!@! D	F 	E!#rxx!@! D	F #,%+ 	$$R&(ggb

&CQ%G	I 	""52776?C*@A 	%%ebhhQ!Q7H.I2-NOr   r   N)
r   r   r   r   r   r  r   r  r   r   r  s   @r   r  r  d	  s%      2P 2Pr   r  c                   H   a a ] tR tRt oRtV 3R ltR tR tR tRt	Vt
V ;t# )	TestTracei	  z
Tests for np.trace.
c                   < \         \        V `  4        \        R R7      ! \        4      V n        \        R R7      ! \        4      V n        R# )Tr   N)r+   r  r,   r   r0  cfunc_w_offsetr2  cfunc_no_offsetr-   s   &r   r,   TestTrace.setUp	  s5    i$&!40>"D12HIr   c                    V! V4       V P                  \        P                  4      ;_uu_ 4        V! V3/ VB  R R R 4       R #   + '       g   i     R # ; ir   r  )r.   rb   r   r  s   &&&,r   assert_int_offsetTestTrace.assert_int_offset	  s<    av1122!v 3222s   
AA	c           	       a  V 3R  lp. R	Op. R
O\        \        R^
4      4      ,           . RO,           p\        W#S P                  R4       Fb  w  rErgS P	                  WFV4      pV! WR7       V^ 8X  d	   V! V4       \
        P                  ! RWgR7      pV! WR7       V^ 8X  g   KZ  V! V4       Kd  	  Rp	S P                  V	S P                  \
        P                  ! ^
\
        P                  R7      ^3R4       S P                  V	S P                  \
        P                  ! ^
\
        P                  R7      3R4       S P                  S P                  \
        P                  ! R4      RR7       R# )c                   < R V9   d   \        V 3/ VB pSP                  pM\        V 3/ VB pSP                  pV! V 3/ VB p^\        P
                  ! V P                  4      P                  ,          p\        P                  P                  WBWUR7       SP                  4       ;_uu_ 4        V! V 3/ VB  RRR4       R#   + '       g   i     R# ; i)r/  r  N)r0  r  r2  r  r   r  r;   r  r  r  r`   )r   r  rd   rb   re   rl  r.   s   &,    r   r  #TestTrace.test_trace.<locals>.check	  s    6!'4V4++1!>v>,,$V$Cbhhqww'222CJJ&&s3&I %%''a"6" ('''s   -
CC	r  )r/  rK  r.  ri   Fr  Nr  )iiir  )r     rs  r  r  )r  rs   r   r   rc  r   rq   r{  r  r  r   r  r  )
r.   r  r  offsetsro   r/  r;   rl   r   r  s
   f         r   
test_traceTestTrace.test_trace	  s3   	#& ; "DsB$88<G T: 'D%++D?A!#{au:A!#{a ;  	$$R)<)<&(ggb

&CQ%G	P$$R)=)=&(ggb

&C%Eu	N 	" # 	 	%r   c                X   \        RRR7      R 4       p\        P                  ! R\        P                  R7      pV! V4       V P	                  \
        4      ;_uu_ 4       pV! R4       RRR4       \        XP                  4      pV P                  RV4       R#   + '       g   i     L9; i)	z
Issue 2314z(optional(float64[:,:]),)Tr   c                 .    \         P                  ! V 4      # r   r-  r   s   &r   tested5TestTrace.test_trace_w_optional_input.<locals>.tested	  s    88A;r   ri   Nz(expected array(float64, 2d, A), got Noner  )	r   r   r  r   r   	TypeErrorrQ   r   rS   )r.   r  r   r   errmsgs   &    r   test_trace_w_optional_input%TestTrace.test_trace_w_optional_input	  s    	(4	8	 
9	 GGF"**-q	y))V4L * V%%&CVL	 *)s   	BB)	)r  r  )r   r   r   r   r   r,   r  r  r   r   r   r   r   s   @@r   r  r  	  s'     J0%dM Mr   r  c                   n   a  ] tR tRt o ]! . R	O4      t]! . R
O4      t. ROtR tR t	R t
R tR tRtV tR# )
TestBasicsi	  c           
     F   V P                  W\        P                  ! ^...\        P                  R7      \        P                  ! ^4      3R4       V P                  W\        P                  ! ^4      \        P                  ! ^...\        P                  R7      3R4       R# )r3   ri   FN)r[  r   rU  r   r  )r.   r  rb   s   &&&r   _assert_wrong_dimTestBasics._assert_wrong_dim
  sr    ''A3%

;RWWQZH%	Q''
BHHseWBJJ$GH%	Qr   c                    \        V\        4      '       g   V# \        V4      ^8X  d   V P                  V^ ,          V4      # V P                  V^ ,          V^,          ,          V4      P	                  WR7      # )r3   rk   )rO  r  rM   r=   rA   )r.   ro   r;   rl   s   &&&&r   
_gen_inputTestBasics._gen_input

  sn    $&&K4yA~))$q'599))Gd1g%"7 # ''r   c                0   V P                  W\        V P                  4      4      pV P                  W#\        V P                  4      4      p\        P
                  ! V4      '       d
   VR ,           p\        P
                  ! V4      '       d
   VR ,           pWE3# )r  )r(  ru  order1order2r   r  )r.   size1size2r;   r   r   s   &&&&  r   
_get_inputTestBasics._get_input
  sk    OOE$t{{*;<OOE$t{{*;<??1BA??1BAvr   c                .  a a	 \        R R7      ! \        4      o	V	V 3R lp\        S P                  4      p\	        S P
                  S P
                  4       F  w  r4\        V4      pS P                  W4V4      w  rgV! Wg4       \        P                  ! \        P                  ! V4      P                  \        P                  ! V4      P                  3\        P                  ! V4      P                  R7      pV! WgVR7       K  	  S P                  RS	4       R# )Tr   c                 ,  < \        W4      pS! W4      p^\        P                  ! \        P                  ! V 4      P                  4      P
                  ,          p\        P                  P                  WCWUR7       RV9   dU   S! W3/ VB p\        P                  P                  WCVVR7       \        P                  P                  VR,          VWUR7       SP                  4       ;_uu_ 4        S! W3/ VB  RRR4       R#   + '       g   i     R# ; i)r  r  r    N)	r5  r   r  asarrayr;   r  r  r  r`   r   r   r  rd   re   rl  rb   r.   s   &&,   r   r  $TestBasics.test_outer.<locals>.check#
  s     $A)H+Cbhhrzz!}223>>>CJJ&&s3&I A+F+

**3s03 + 5

**6%=(03 + ? %%''a%f% ('''s   .
DD	ri   r   r4  N)r   r5  r   r   r   r  ru  r/  r   rq   r3  ro   r;   r%  )
r.   r  dtsr-  r.  r;   r   r   r,  rb   s
   f        @r   
test_outerTestBasics.test_outer 
  s    T"<0	&* DKK #DJJ

;LEIE__U59FQ!K"**Q-,,bjjm.@.@A"$**Q-"5"57A!A < 	w.r   c                  a a	 \        R R7      ! \        4      o	V	V 3R lp\        S P                  S P                  S P                  4       F"  w  r#pS P                  W#V4      w  rVV! WV4       K$  	  S P                  RS	4       \        P                  ! ^
4      R,          \        P                  ! ^
4      R,          3pRpS P                  S	Wx\        P                  R7       R# )Tr   c                 t  < \        W4      pS! W4      p^\        P                  ! \        P                  ! V 4      P                  4      P
                  ,          p\        P                  P                  WCWUR7       SP                  4       ;_uu_ 4        S! W4       RRR4       R#   + '       g   i     R# ; i)r  r  N)	r8  r   r  r3  r;   r  r  r  r`   r4  s   &&,   r   r  #TestBasics.test_kron.<locals>.checkF
  s{    "1(H+Cbhhrzz!}223>>>CJJ&&s3&I %%''a ('''s   	B&&B7	r7  NNr   zonly supports 'C' or 'F' layoutr  N)r   r8  r   r  r   r/  r%  r   rq   rg  r
   r   )
r.   r  r-  r.  r;   r   r   rc   r   rb   s
   f        @r   	test_kronTestBasics.test_kronC
  s    T";/
	 

DJJ<  E%__U59FQ!K = 	vu-S!288B<#45/%0B0BCr   r   N)rm   rj   rj   rm   )rj   rm   rj   rm   )r  r  r  )r  r  )r   r~  r  )r   r   r   r   r   r+  r,  r  r%  r(  r/  r7  r=  r   r   r  s   @r   r#  r#  	  sD     '(F'(F ?EQ
'!/FD Dr   r#  c                   &   a  ] tR tRt o R tRtV tR# )TestHelpersi^
  c                  a a ^ RI Ho V 3R lp\        V3R l4       pR	R
.p\        P                  .pRR.pV! V\        P
                  W4V4       \        V3R l4       pRR.p\        P                  .pRR.pR pV! WgW4V4       R# )r   )_copy_to_fortran_orderc                 \  < \        W#V4       F  w  rVp\        P                  ! \        P                  ! V4      4      P	                  WWR 7      pV ! V4      p	S
P                  V! V4      V	4       S
P                  VP                  P                  V	P                  P                  4       K  	  R# )rk   N)	r   r   r5   prodrA   ra   assertNotEqualctypesdata)udtexpectfnshapesr   r  ry   r;   rl   r   rP  r.   s   &&&&&     r   r  5TestHelpers.test_copy_to_fortran_order.<locals>.checkb
  s{    '.vv'F#eIIbggen-55e5IF''Q7##AHHMM188==A (Gr   c                    < S! V 4      # r   r   )r   rB  s   &r   direct_call;TestHelpers.test_copy_to_fortran_order.<locals>.direct_calll
  s    )!,,r   rj   rm   c                 4   < V R ,          ^ ,          pS! V4      # r<  r   )r   slicedrB  s   & r   slice_to_any<TestHelpers.test_copy_to_fortran_order.<locals>.slice_to_anyv
  s     sVAYF)&11r   c                 N    V R ,          ^ ,          p\         P                  ! V4      # rP  )r   asfortranarray)r   rQ  s   & r   expected_slice_to_anyETestHelpers.test_copy_to_fortran_order.<locals>.expected_slice_to_any
  s     sVAYF$$V,,r   N)r   r   )r   r   r  )r   r   r   )r   r   r   r  )numba.np.linalgrB  r   r   intprU  )	r.   r  rM  rJ  r   r  rR  rV  rB  s	   f       @r   test_copy_to_fortran_order&TestHelpers.test_copy_to_fortran_order_
  s    :	B 
	- 
	- )$''sk2,,ffE 
	2 
	2
 \*''s	-
 	l66Jr   r   N)r   r   r   r   rZ  r   r   r  s   @r   r@  r@  ^
  s     &K &Kr   r@  __main__r  )r   )gV瞯<r   r  )Jr   r)   	itertoolsr   r   sysrH   numbersr   r   platformnumpyr   numbar   r   r	   
numba.corer
   numba.tests.supportr   r   r   r   r   r   r   unittestr   r"   r$   r'   r   r   r   r   r   r   r  r  r  r  r  r  r  r  r#  r(  r+  r0  r2  r5  r8  r:  r  r  r  r  r1  rL  rY  rd  r  r  r  r  r  r  r  r  r#  r@  r   mainr   r   r   <module>rg     s    	 $ 
  $   # # B B * !j%x j^	! !+(! " )(#BC(( BCJgI gITN2N N2bPJ PJfj$^ j$Z}8N }8@u1> u1p@ @.E.' E.PT2' T2nN2^ N2by2n y2~fN& fNRQN^ QNhD2, D2N?PN ?PDQM QMhaD" aDH'K( 'KR zMMO r   