
    Bpj8                     t    S r / rSSKrSSKJr   " S S\R                  R                  5      rSSK	J
r
  S	S jrg)
zz
Matrix square root for general matrices and for upper triangular matrices.

This module exists to avoid cyclic imports.

    N   )get_lapack_funcsc                       \ rS rSrSrg)
SqrtmError    N)__name__
__module____qualname____firstlineno____static_attributes__r       X/var/www/html/pdf-tiff/venv/lib/python3.13/site-packages/scipy/linalg/_matfuncs_sqrtm.pyr   r      s    r   r   )within_block_loopc           	         [         R                  " U 5      n[         R                  " U 5      =(       a    [         R                  " USS9S:  nU(       dH  [         R                  " U [         R
                  SS9n [         R                  " U[         R
                  S9nOG[         R                  " U [         R                  SS9n [         R                  " U[         R                  S9n[         R                  " [         R                  " U5      5      n[        SU4SS	9nU R                  u    n[        Xa-  S
5      n[        Xg5      u  pUS
-   n
Xy-
  nX-  X-  -   U:w  a  [        S5      e/ nSnX4X44 H0  u  p[        U5       H  nUR                  XU-   45        X-  nM     M2      [        X@X5        [        U5       H  nUU   u  nn[        US
-
  SS5       Hw  nUU   u  nnU UU2UU24   nUU-
  S
:  a&  UUUU2UU24   R'                  UUU2UU24   5      -
  nUUU2UU24   nUUU2UU24   nU" UUU5      u  nnnUU-  UUU2UU24'   My     M     U$ ! [          a  n[#        UR$                  6 UeSnAff = f)a  
Matrix square root of an upper triangular matrix.

This is a helper function for `sqrtm` and `logm`.

Parameters
----------
T : (N, N) array_like upper triangular
    Matrix whose square root to evaluate
blocksize : int, optional
    If the blocksize is not degenerate with respect to the
    size of the input array, then use a blocked algorithm. (Default: 64)

Returns
-------
sqrtm : (N, N) ndarray
    Value of the sqrt function at `T`

References
----------
.. [1] Edvin Deadman, Nicholas J. Higham, Rui Ralha (2013)
       "Blocked Schur Algorithms for Computing the Matrix Square Root,
       Lecture Notes in Computer Science, 7782. pp. 171-182.

g        )initialr   C)dtypeorder)r   trsyl	preferred)ilp64r   zinternal inconsistencyN)npdiag	isrealobjminasarray
complex128float64sqrtr   shapemaxdivmod	Exceptionrangeappendr   RuntimeErrorr   argsdot)T	blocksizeT_diagkeep_it_realRr   nnblocksbsmallnlargeblargensmallstart_stop_pairsstartcountsizeiejjstartjstopistartistopSRiiRjjxscaleinfos                                r   _sqrtm_triurG      s   4 WWQZF<<?Frvvfb'AQ'FL JJqS9F"--8JJq

#6F"**5
 AWqd+>E 77DAq!.!$G A'NFaZFF(A-011 E(6*:;uA##UDL$9:ME  <)! 0:
 7^(+qsB#A,Q/MFE&,u,-A1uqy&,f4599!E&L<B5L=I ;J K K F5L&,./CF5L&,./C"3Q/NAud,-IAfUlF5L() $ $ H-  )!&&!q()s   "I 
I7I22I7)@   )__doc____all__numpyr   lapackr   linalgLinAlgErrorr   _matfuncs_sqrtm_triur   rG   r   r   r   <module>rP      s:      %	&& 	 4Vr   