+
    0iV                        R t ^ RIt^ RIt^ RIt^ RIHtHtHtHt ^ RI	H
t
HtHtHtHt ^ RI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Ht ^ R	IH t H!t! ^ RIt"^ RI#t"R
 t$R t%R t& ! R R4      t' ! R R4      t(R# )z2Test functions for scipy.linalg._matfuncs module

N)arrayeyeexprandom)assert_allcloseassert_assert_array_almost_equalassert_equalassert_array_almost_equal_nulp)	csc_arraySparseEfficiencyWarning)	eye_array)expm_expmProductOperatorMatrixPowerOperator_onenorm_matrix_power_nnmmatrix_power)matrix)logm)	factorialbinomc                   V \        V 4      8w  g   V ^8  d   \        R4      h\        V 4      p V\        V4      8w  g   V^ 8  d   \        R4      h\        V4      p\        W4      w  r#\        P                  ! RV ) V,          4      pV\        P                  ! RV ) 4      ,          p\        P
                  ! V.W,
          ,          V4      \        P
                  ! V.V,          W0,
          4      ,           # )a:  
A helper function for testing matrix functions.

Parameters
----------
n : integer greater than 1
    Order of the square matrix to be returned.
p : non-negative integer
    Power of the matrix.

Returns
-------
out : ndarray representing a square matrix
    A Forsythe matrix of order n, raised to the power p.

z#n must be an integer greater than 1z p must be a non-negative integer      $@)int
ValueErrordivmodnppowerdiag)npablargesmalls   &&    e/var/www/html/photoedit/myenv/lib/python3.14/site-packages/scipy/sparse/linalg/tests/test_matfuncs.py_burkardt_13_powerr'      s    $ 	CF{a!e>??AACF{a!e;<<AA !<DAHHTA2a4 EBHHTA2&&E77E7AC=!$rwwwqy!#'>>>    c                  x   \         P                  P                  R 4       \        ^^4       F  p \        ^4       Fx  p\         P                  P                  W 34      p\         P                  P                  W!4      p\        W!4      p\         P                  P                  V^4      p\        WE4       Kz  	  K  	  R#   N)	r   r   seedrangelinalgr   r   normr   )r    r!   MMpobservedexpecteds         r&   test_onenorm_matrix_power_nnmr4   <   s    IINN41a[qA		  !(A''-B06Hyy~~b!,HH/  r(   c                     \         P                  P                  R 4       \         P                  P                  ^ ^RR7      w  r\         P                  P                  RR7      p\	        W V33RR7      p\	        W V33RR7      pVP                  4       pR Fj  p\        WF4      P                  4       p\        W64      P                  4       p\         P                  P                  WV4      p	\        Wy4       \        Wx4       Kl  	  R# )r+   )size)shapeN)      )r9   )   r:   )r8      r9   )	r   r   r,   randintr   toarrayr   r.   r   )
rowcoldataAmatAAdenser   ApowAmat_pow
Adense_pows
             r&   test_matrix_powerrG   F   s    IINN4yy  AF 3HC99&Dd#J'v6D4s$F3AYY[FA%--/,446YY++F:
)' r(   c                      a  ] tR t^Ut o R tR tR tR tR tR t	R t
R tR	 tR
 tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR t R t!Rt"V t#R # )!TestExpMc                ^    \        R ^ .^ ^ ..4      p\        \        V4      ^^ .^ ^..4       R#         N)r   r   r   selfr"   s   & r&   test_zero_ndarrayTestExpM.test_zero_ndarrayV   s2    Bq61Q%.!!$q'Aa5!A-8r(   c                z    \        R ^ .^ ^ ..4      p\        \        V4      P                  4       ^^ .^ ^..4       R# rK   )r   r   r   r=   rM   s   & r&   test_zero_sparseTestExpM.test_zero_sparseZ   s9    1vqen%!$q'//"3aUAa5MBr(   c                ^    \        R ^ .^ ^ ..4      p\        \        V4      ^^ .^ ^..4       R# rK   )r   r   r   rM   s   & r&   test_zero_matrixTestExpM.test_zero_matrix^   s2    RFAa5>"!$q'Aa5!A-8r(   c                   \        \        P                  ! ^..4      4      p\        \        R4      V4       \        \        ^..4      V4       \        \        \	        ^..4      4      V4       \        \        \        P                  ! ^..4      4      V4       \        \        \        ^..4      4      P                  4       V4       \        \        P                  ! R..4      4      p\        \        R4      V4       \        \        R..4      V4       \        \        \	        R..4      4      V4       \        \        \        R..4      4      P                  4       V4       R# )                 ?N))rX   ))rY   )r   r   r   r   r   r   r=   )rN   rB   Bs   &  r&   test_misc_typesTestExpM.test_misc_typesb   s    A3%!Wq)qcUQ'VaSE]+Q/RXXse_-q1Yu-.668!<B4&!"X*rdVa(VbTF^,a0Yv./7791=r(   c                |   \        . RO. RO. RO.\        R7      p\        P                  ! ^4      p\        P                  ! ^4      p\        P
                  ! V^V,          ^V^V,          ,
          ,          .^ V^W2,
          ,          .^ ^ V..\        R7      p\        V4      P                  4       p\        WT4       R# )rX   dtypeN)rX          )ra   rX   r;   )ra   ra   r8   )	r   floatmathr   r   r   r   r=   r   )rN   rB   e1e2r3   r2   s   &     r&   test_bidiagonal_sparseTestExpM.test_bidiagonal_sparseo   s     $% XXa[XXa[882r2"9~&ArwK 2J  %& 7??$!(5r(   c                    \         P                  \         P                  3 FV  pR FM  pV\        ^VR7      ,          p\	        V4      p\        W!R7      \        ^VR7      ,          p\        WE^dR7       KO  	  KX  	  R# {Gz?r^   nulpNrj   皙?g      ?rX   
   )r   float32float64r   r   r   r
   rN   r_   scalerB   r2   r3   s   &     r&   test_padecases_dtype_float#TestExpM.test_padecases_dtype_float}   s]    jj"**-E2C//7u2S%5HH.xL	 3 .r(   c                    \         P                  \         P                  3 FV  pR FM  pV\        ^VR7      ,          p\	        V4      p\        W!R7      \        ^VR7      ,          p\        WE^dR7       KO  	  KX  	  R# ri   )r   	complex64
complex128r   r   r   r
   rr   s   &     r&   test_padecases_dtype_complex%TestExpM.test_padecases_dtype_complex   s]    llBMM2E2C//7u2S%5HH.xL	 3 3r(   c           	        \         P                  pR F  pV\        ^^VRR7      ,          p\        W!R7      \	        ^VR7      ,          p\
        P                  ! 4       ;_uu_ 4        Rp\
        P                  ! RV\        4       \        VRR7      P                  4       p\        VRR7      P                  4       pR	R	R	4       \        XV^dR
7       \        XV^dR
7       K  	  R	#   + '       g   i     L2; i)rj   cscr_   formatr^   Changing the sparsity structureignoreT)use_exact_onenormFNrk   rm   )r   rq   r   r   r   warningscatch_warningsfilterwarningsr   r   r=   r
   )rN   r_   rs   r"   emsgexact_onenorminexact_onenorms   &       r&   !test_padecases_dtype_sparse_float*TestExpM.test_padecases_dtype_sparse_float   s    

.E	!QeEBBAE'#au*==A((**7''#7NO %a4 @ H H J"'U"C"K"K"M	 +
 +=!#F*?ACH / +*s   'AC&&C6c           	        \         P                  pR F  pV\        ^^VRR7      ,          p\        V4      \	        ^VR7      ,          p\
        P                  ! 4       ;_uu_ 4        Rp\
        P                  ! RV\        4       \        \        V4      P                  4       V^dR7       RRR4       K  	  R#   + '       g   i     K  ; i)	rj   r|   r}   r^   r   r   rk   Nrm   )r   rx   r   r   r   r   r   r   r   r
   r   r=   )rN   r_   rs   r"   r   r   s   &     r&   #test_padecases_dtype_sparse_complex,TestExpM.test_padecases_dtype_sparse_complex   s    .E	!QeEBBAE
S%00A((**7''#7NO.tAw/@!#N +* / +**s   &AB88C	c           
        \         P                  ! R 4       \        P                  \        P                  3 F  p\        ^^
4       F  pR F  p\        V4      \         P                  ! W"4      V,          ,           P                  V4      p\        P                  ! V4      '       d,   VR\         P                  ! W"4      ,          V,          ,           p\        \        \        V4      4      V4       K  	  K  	  K  	  R# )r+   rY   N)-C6?MbP?rj   rn   rX   r   g      Y@)r   r,   r   rq   rx   r-   r   randastypeiscomplexobjr   r   r   )rN   r_   r    rs   rB   s   &    r&   test_logm_consistencyTestExpM.test_logm_consistency   s    Djj"--0E1b\BEQ&++a"3e";;CCEJAq))V[[%6 6 >>-d47mQ? C " 1r(   c                    \         P                  ! . RO. RO. RO. RO.4      p\        \        V4      \        RV,          4      4       R# )r`         ?N)rX   rX   rX   )rX   r   rX   rX   )rX   rX   r   rX   )rX   rX   rX   r   )r   r   r   r   rN   Qs   & r&   test_integer_matrixTestExpM.test_integer_matrix   s9    HH	 
 	QcAg/r(   c                L   \         P                  ! . RO. RO. RO. RO.\         P                  R7      p\        \	        V4      \	        RV,          4      4       \        V4      p\        \	        V4      P                  4       \	        RV,          4      P                  4       4       R# )  r^   r   N)ir   ra   ra   )ra   iih     )ra   iv  ira   ra   ra   ra   ra   )r   r   int16r   r   r   r=   r   s   & r&   test_integer_matrix_2TestExpM.test_integer_matrix_2   sq    HH')'"$ ,.885 	QcAg/aLQ)4a=+@+@+BCr(   c           	        \         P                  ! . RO. RO. RO. RO.\        R7      p\         P                  ! . RO. RO. RO. RO.\        R7      p\        \	        V4      VRR7       \
        P                  ! R4       RpVP                  4       pW4R&   \        P                  ! 4       ;_uu_ 4        \        P                  ! RR\        4       \        P                  ! RR\        4       \	        V4      pR	R	R	4       Rp^dV,          p\        \         P                  ! XWVR
7      '       * 4       R	#   + '       g   i     LD; i)3d?r^   r   )rtolr+   gFFg<r   zIll-conditioned.*zAn ill-conditioned.*N)r   atol)r        L@r   r   )ra   gRal!A?r   r   )ra   ra   gQI?r   )ra   ra   ra   g^?)g<gGgx@g9=g[dB)rL   g'V7gZ@g2p)rL   rL   gѤT g\GeE@)rL   rL   rL   gPǆ!)rX   ra   )r   r   rb   r   r   r   r,   copyr   r   r   RuntimeWarningr   allclose)rN   rB   A_logmtinyA_logm_perturbedA_expm_logm_perturbedr   r   s   &       r&   test_triangularity_perturbation(TestExpM.test_triangularity_perturbation   s   
 HH&$! 	"
  @@@@A 	 	Vad3 	D!;;=!%$$&&##H.A>R##H.DnU$()9$:!	 '
 TzBKK 5q$OOP '&s   1AD11E	c                   \         P                  ! ^4      p\         P                  ! ^4      p\         P                  ! ^^ .^ ^..\        R7      p\         P                  ! V^ .^ V..\        R7      p\	        V4      p\        WT4       R# rX   r^   Nr   r   r   rb   r   r   )rN   exp1exp2rB   desiredactuals   &     r&   test_burkardt_1TestExpM.test_burkardt_1   s    6 vvayvvayHHFF  ((1II  a(r(   c                    \         P                  ! ^^.^^..\        R7      p\         P                  ! RR.RR..\        R7      p\        V4      p\	        W24       R# )rX   r^   gkQC@gb]IG@gd]IG@gJ[K@Nr   r   rb   r   r   rN   rB   r   r   s   &   r&   test_burkardt_2TestExpM.test_burkardt_2  si     HHFF  ((!34!34  a(r(   c                6   \         P                  ! ^4      p\         P                  ! ^'4      p\         P                  ! ^ ^.RR..\        R7      p\         P                  ! ^'^&V,          ,          ^^&V,          ,          ,
          \         P                  ! R4      ) ^&V,          ,          .^'\         P                  ! R4      ,          ^&V,          ,          R^&V,          ,          ^'^&V,          ,          ,           ..\        R7      p\        V4      p\        WT4       R# )rX   r^   Niii)r   r   r   rb   expm1r   r   )rN   r   exp39rB   r   r   s   &     r&   test_burkardt_3TestExpM.test_burkardt_3   s     vvayr
HHF#J  ((BtGq"U(|+#"T'*, 288C= BtG,BtGr2e8},.	  a(r(   c                   \         P                  ! R^.R^..\        R7      p\         P                  ! ^^.^^..\        R7      p\         P                  ! ^R.RR..\        R7      p\         P                  ! R	R.\        R7      p\         P                  ! V\         P                  ! V4      ,          V4      p\        V4      p\        We4       R# )
1   r^   Niir         g      ?i)r   r   rb   dotr   r   r   )rN   rB   UVwr   r   s   &      r&   test_burkardt_4TestExpM.test_burkardt_45  s     HH"I"I  HHq!fq!f%U3HHq$i"c+59HHc2Ye,&&RVVAY*a(r(   c                    \         P                  ! . RO. RO. RO. RO.\        R7      p\         P                  ! . RO. RO. R	O. R
O.\        R7      p\        V4      p\	        W24       R# )ra   r^   N)ra   r9   ra   ra   )ra   ra   r9   ra   )ra   ra   ra   r9   r   )rX   r9      $   )ra   rX   r9   r   )ra   ra   rX   r9   ra   ra   ra   rX   r   r   s   &   r&   test_burkardt_5TestExpM.test_burkardt_5D  sa    
 HH	
  ((	
  a(r(   c                    \         P                  ! ^4      p\         P                  ! ^^.^ ^..\        R7      p\         P                  ! W.^ V..\        R7      p\	        V4      p\        WC4       R# r   r   )rN   r   rB   r   r   s   &    r&   test_burkardt_6TestExpM.test_burkardt_6X  sp     vvayHHFF  ((LI  a(r(   c                ,   \         P                  ! ^4      p\         P                  ! ^4      p\         P                  ! ^V,           ^.^ ^V,
          ..\        R7      p\         P                  ! W.^ V..\        R7      p\        V4      p\        WT4       R# r   )r   r   spacingr   rb   r   r   )rN   r   epsrB   r   r   s   &     r&   test_burkardt_7TestExpM.test_burkardt_7h  s    
 vvayjjmHHWaLCL  ((LI  a(r(   c                <   \         P                  ! ^4      p\         P                  ! ^4      p\         P                  ! . RO. RO. RO.\        R7      p\         P                  ! ^V,          V,
          ^V,          ^V,          ,
          ^V,          ^V,          ,
          .RV,          V,           RV,          ^V,          ,           RV,          ^V,          ,           .^V,          ^V,          ^V,          ..\        R7      R,          p\	        V4      p\        WT4       R# )	r:   r^   g      ?N)      r9   )r   i)r:   r:      ir   r   )rN   exp4exp16rB   r   r   s   &     r&   test_burkardt_8TestExpM.test_burkardt_8z  s    vvayr
HH 	
 ((X_bh4/51T61ABX_bh4/EAdF1BCXr%x5) 	 #	#
 a(r(   c                    \         P                  ! . RO. RO. RO. RO.\        R7      p\         P                  ! . RO. RO. R	O. R
O.\        R7      p\        V4      p\	        W24       R# )rX   r^   N)rX   r8   r8   r8   )r`   rX   rX   r8   )r`   r8   rX   r8   )r`   r`   r`   rX   )fa%@@X21@g鷯g)@)^Iچ@|Pk܂@g'@r   )v@gBfg;@r   r   )gDl{3@r   r   r   r   r   s   &   r&   test_burkardt_9TestExpM.test_burkardt_9  sa     HH	
  ((4444	
  a(r(   c                *   \         P                  ! . RO. RO. RO.\        R7      p\        \	        \
        P                  P                  V4      4      R4       \         P                  ! . RO. RO. R	O.\        R7      p\        V4      p\        W24       R# )
r:   r^   N)r:   r8   ra   )rX   r:   rX   )rX   rX   r:   )r`   r`   r9   )gl$^{b@
|f@g.Q@)g\"N_@r   g
|V@)g\"N_@gLud@gs[@	r   r   rb   r   sortedscipyr.   eigvalsr   r   s   &   r&   test_burkardt_10TestExpM.test_burkardt_10  sy     HH 	
 	u||33A67C((EEE 	
 a(r(   c                   \         P                  ! . RO. RO. RO.\        R7      p\        \        P
                  P                  V4      R4       \         P                  ! . RO. RO. R	O.\        R7      p\        V4      p\        W24       R# )
!=@r^   N)r   l?QP)r   gt 9@猽誉\!@)r   r   g0n2A@)      (   )gJކ3Cg;%s1PMSUc[)g;%s1Pgcx
MjCO}vC)r   r  g˂C)r   r   rb   r   r   r.   eigvalshr   r   s   &   r&   test_burkardt_11TestExpM.test_burkardt_11  sz     HHGFF 	
 	--a0,?(()''  a(r(   c                *   \         P                  ! . RO. RO. RO.\        R7      p\        \	        \
        P                  P                  V4      4      R4       \         P                  ! . RO. RO. R	O.\        R7      p\        V4      p\        W24       R# )
   r^   N)i}   r   )iz8   6   )i}9   4   )ir   r   )g)'g13V?g-RR?)gǣg׃4V?g3?)gWNx`gp?g}mR?r   r   s   &   r&   test_burkardt_12TestExpM.test_burkardt_12  sy     HH 	
 	u||33A67G((HGG 	
 a(r(   c                   \        ^^4      p. RO. RO. RO. RO.p\        W4       R EF#  p\        ^\        \        P
                  ! ^V,          4      4      4      p\        P                  ! W33\        R7      p\        W4,          4       F  p\        W64      p\        \        P                  ! V4      ^ 4       \        \        P                  ! V4      \        P                  ! ^
\        P                  ! Wc,          4      ) V,          4      4       WW\        V4      ,          ,          pK  	  \        \        V^4      4      p\        W4       EK&  	  R# )r:   r^   N)ra   rX   ra   ra   )ra   ra   rX   ra   r   )r   ra   ra   ra   )r8   r`   r:   ro   )r'   r   maxr   r   ceilzerosrb   r-   r	   minr   floorr   r   )	rN   	A4_actual
A4_desiredr    kr   r!   Apr   s	   &        r&   test_burkardt_13TestExpM.test_burkardt_13  s     'q!,	"""%'
 		.A As2772a4=)*AhhvU3G13Z'-RVVBZ+r
BHHR"((13-9I,JK	!,,	  
 ,Q23FF, r(   c                    \         P                  ! . RO. RO. RO.\        R7      p\         P                  ! . RO. RO. RO.\        R7      p\        V4      p\	        W24       R# )	ra   r^   N)ra   g:0yE>ra   )g"Dr   g    _B)gP@ra   gP)g .?gzDv>g1O?)gvUg԰gLg@sDQ)g F~?gg=>gcE?r   r   s   &   r&   test_burkardt_14TestExpM.test_burkardt_14  s[     HH(" 	
 ((HGH 	
 a(r(   c           	        R EF;  p\        ^ ^P^4       EF%  pV\        P                  ! VRR4      ,          p\        P                  ! VR8  4      '       d    KV  \        P                  ! \        P                  ! ^V^,           4      R4      V,          p\        V4      pTp\        \        P                  ! V^,           4      R,          \        P                  ! V^,           4      R,          4      VR,          ,          VR,          ,          pR\        V4      P                  4       ,          p\        WgVR7       EK(  	  EK>  	  R# )	r   gYnNgvIh%<=)r   )r   r   gư>r   )NNNN)Nr  )
r-   r   arangeanyr   r   r   absr  r   )	rN   rs   r    scrB   rZ   gotr3   r   s	   &        r&   test_pascalTestExpM.test_pascal	  s     'E1b!_bii2r2266"v+&&GGBIIaQ/4u<G 1q5!1&!9!#1q5!1&!9;=?ZHJLV*Us8}0022D99 % 'r(   c                   \         P                  ! R4      p^VR&   \        V4      p\        P                  ! 4       ;_uu_ 4        \        P
                  ! RR\        4       \        P
                  ! RR\        4       \        \         P                  ! V4      4      pRRR4       \        XV4       R#   + '       g   i     L; i)   r   zthe matrix subclass.*N)r'  r'  )r   ra   )
r   r  r   r   r   r   DeprecationWarningPendingDeprecationWarningr   r   )rN   rB   B0rZ   s   &   r&   test_matrix_inputTestExpM.test_matrix_input  s    HHZ $!W$$&&##13EG##13LNRYYq\"A ' 	2 '&s   AB22C	c           
         \         P                  ! . RO. RO. RO. RO. RO. RO. RO.4      p\        V) 4      p\        RV,          4      pTp\        ^4       F  pWD,          pK  	  \	        W44       R# )r   N)r   r   r   rL   rL   rL   rL   )rL   r   rL   r   r   rL   rL   )rL   rL   r   rL   rL   r   r   )rL   rL   rL   rL   rL   rL   rL   i )r   r   r   r-   r   )rN   LE0E1E2js   &     r&   test_exp_sinch_overflow TestExpM.test_exp_sinch_overflow)  si    HH;;;9999; < 1"X&1*rAB  	r(    N)$__name__
__module____qualname____firstlineno__rO   rR   rU   r[   rf   rt   ry   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r$  r+  r3  __static_attributes____classdictcell____classdict__s   @r&   rI   rI   U   s     9C9>6MMI	O	@0	D$QL&)P))*))() )$)")$)")4)$->) :&   r(   rI   c                   ,   a  ] tR tRt o R tR tRtV tR# )TestOperatorsi<  c                   \         P                  ! R 4       ^p^p^
p\        V4       EF0  p\        P                   P	                  W4      p\        P                   P	                  W4      p\        P                   P	                  W4      p\        P                   P	                  W4      p\        WVV4      p	\        V	P                  V4      VP                  V4      P                  V4      P                  V4      4       \        V	P                  P                  V4      VP                  V4      P                  V4      P                  P                  V4      4       EK3  	  R# r*   )
r   r,   r-   r   randnr   r   matmatr   T)
rN   r    r  nsamplesirB   rZ   CDops
   &         r&   test_product_operator#TestOperators.test_product_operator>  s    DxA		%A		%A		%A		%A q)BBIIaL!%%(,,q/*=*=a*@ABDDKKNQUU1X\\!_,?,?,C,CA,FG !r(   c                <   \         P                  ! R 4       ^p^p^p^
p\        V4       F  p\        P                   P	                  W4      p\        P                   P	                  W4      p\        Wc4      p\        VP                  V4      \        P                  P                  Wc4      P                  V4      4       \        VP                  P                  V4      \        P                  P                  Wc4      P                  P                  V4      4       K  	  R# r*   )r   r,   r-   r   rA  r   r   rB  r.   r   r   rC  )	rN   r    r  r!   rD  rE  rB   rZ   rH  s	   &        r&   test_matrix_power_operator(TestOperators.test_matrix_power_operatorL  s    DxA		%A		%A$Q*BBIIaL"))*@*@*F*J*J1*MNBDDKKNBII,B,B1,H,J,J,N,Nq,QR !r(   r5  N)r6  r7  r8  r9  rI  rL  r:  r;  r<  s   @r&   r?  r?  <  s     HS Sr(   r?  ))__doc__rc   r   numpyr   r   r   r   r   numpy.testingr   r   r   r	   r
   scipy.sparser   r   scipy.sparse._constructr   scipy.sparse.linalg._matfuncsr   r   r   r   r   r   scipy.sparse._sputilsr   scipy.linalgr   scipy.specialr   r   r   scipy.sparse.linalgr'   r4   rG   rI   r?  r5  r(   r&   <module>rX     sq       ) )( ( < -1 1 )  *  ?@0(d  d NS Sr(   