+
    LV-jš0  ã                   óª   € R t ^ RIt^ RIt^ RIHt RR.t]! RR4      RR l4       tR t	 Rt
R tR tR	 tR
 tR tR tRR lt]! R4      RR l4       tR# )z-Frechet derivative of the matrix exponential.N)Ú_apply_over_batchÚexpm_frechetÚ	expm_condc                óº  € V'       d.   \         P                  ! V 4      p \         P                  ! V4      pM,\         P                  ! V 4      p \         P                  ! V4      pV P                  ^8w  g*   V P                  ^ ,          V P                  ^,          8w  d   \        R4      hVP                  ^8w  g*   VP                  ^ ,          VP                  ^,          8w  d   \        R4      hV P                  VP                  8w  d   \        R4      hVf   RpVR8X  d   \        W4      w  rVM#VR8X  d   \        W4      w  rVM\        RV 24      hV'       d   WV3# V# )aé  
Frechet derivative of the matrix exponential of A in the direction E.

Parameters
----------
A : (N, N) array_like
    Matrix of which to take the matrix exponential.
E : (N, N) array_like
    Matrix direction in which to take the Frechet derivative.
method : str, optional
    Choice of algorithm. Should be one of

    - `SPS` (default)
    - `blockEnlarge`

compute_expm : bool, optional
    Whether to compute also `expm_A` in addition to `expm_frechet_AE`.
    Default is True.
check_finite : bool, optional
    Whether to check that the input matrix contains only finite numbers.
    Disabling may give a performance gain, but may result in problems
    (crashes, non-termination) if the inputs do contain infinities or NaNs.

Returns
-------
expm_A : ndarray
    Matrix exponential of A.
expm_frechet_AE : ndarray
    Frechet derivative of the matrix exponential of A in the direction E.
For ``compute_expm = False``, only `expm_frechet_AE` is returned.

See Also
--------
expm : Compute the exponential of a matrix.

Notes
-----
This section describes the available implementations that can be selected
by the `method` parameter. The default method is *SPS*.

Method *blockEnlarge* is a naive algorithm.

Method *SPS* is Scaling-Pade-Squaring [1]_.
It is a sophisticated implementation which should take
only about 3/8 as much time as the naive implementation.
The asymptotics are the same.

.. versionadded:: 0.13.0

References
----------
.. [1] Awad H. Al-Mohy and Nicholas J. Higham (2009)
       Computing the Frechet Derivative of the Matrix Exponential,
       with an application to Condition Number Estimation.
       SIAM Journal On Matrix Analysis and Applications.,
       30 (4). pp. 1639-1657. ISSN 1095-7162

Examples
--------
>>> import numpy as np
>>> from scipy import linalg
>>> rng = np.random.default_rng()

>>> A = rng.standard_normal((3, 3))
>>> E = rng.standard_normal((3, 3))
>>> expm_A, expm_frechet_AE = linalg.expm_frechet(A, E)
>>> expm_A.shape, expm_frechet_AE.shape
((3, 3), (3, 3))

Create a 6x6 matrix containing [[A, E], [0, A]]:

>>> M = np.zeros((6, 6))
>>> M[:3, :3] = A
>>> M[:3, 3:] = E
>>> M[3:, 3:] = A

>>> expm_M = linalg.expm(M)
>>> np.allclose(expm_A, expm_M[:3, :3])
True
>>> np.allclose(expm_frechet_AE, expm_M[:3, 3:])
True

z expected A to be a square matrixz expected E to be a square matrixz%expected A and E to be the same shapeÚSPSÚblockEnlargezUnknown implementation )ÚnpÚasarray_chkfiniteÚasarrayÚndimÚshapeÚ
ValueErrorÚexpm_frechet_algo_64Úexpm_frechet_block_enlarge)ÚAÚEÚmethodÚcompute_expmÚcheck_finiteÚexpm_AÚexpm_frechet_AEs   &&&&&  Úk/Volumes/fast/ai/experiments/ui-tars-smoke/.venv/lib/python3.14/site-packages/scipy/linalg/_expm_frechet.pyr   r   
   s  € ÷j Ü× Ò  Ó#ˆÜ× Ò  Ó#‰ä�JŠJ�q‹MˆÜ�JŠJ�q‹MˆØ‡v�v�„{�a—g‘g˜a•j A§G¡G¨A¥JÔ.ÜÐ;Ó<Ð<Ø‡v�v�„{�a—g‘g˜a•j A§G¡G¨A¥JÔ.ÜÐ;Ó<Ð<Ø‡w�w�!—'‘'ÔÜÐ@ÓAÐAØ‚~ØˆØ�„Ü"6°qÓ"<Ñˆ�Ø	�>Ô	!Ü"<¸QÓ"BÑˆ�äÐ2°6°(Ð;Ó<Ð<ßØÐ&Ð&àÐó    c                óP  € V P                   ^ ,          p\        P                  ! \        P                  ! W.4      \        P                  ! \        P                  ! V 4      V .4      .4      p\
        P                  P                  V4      pVRV1RV13,          VRV1VR13,          3# )z\
This is a helper function, mostly for testing and profiling.
Return expm(A), frechet(A, E)
N)r   r   ÚvstackÚhstackÚ
zeros_likeÚscipyÚlinalgÚexpm)r   r   ÚnÚMÚexpm_Ms   &&   r   r   r   y   s‹   € ð
 	
�‰��
€AÜ
�	Š	Ü
�	Š	�1�&ÓÜ
�	Š	”2—=’= Ó# QÐ'Ó(ð*ó 	+€Aô �\‰\×Ñ˜qÓ!€FØ�"�1�"�b�q�b�&�>˜6 " 1 " a¡b &�>Ð)Ð)r   c                 ó  € RpV P                  V 4      p\        P                   ! W4      \        P                   ! W4      ,           pV P                  V^,          V,          V^,          V,          ,           4      pV^,          V,          V^ ,          V,          ,           pV P                  V^,          V,          4      VP                  V^,          V,          V^,          V,          ,           4      ,           pV^,          V,          p	WgW‰3# )ç      ^@)r$   g      N@g      (@ç      ð?©Údotr   )
r   r   ÚidentÚbÚA2ÚM2ÚUÚVÚLuÚLvs
   &&&       r   Ú_diff_pade3r0   ©   sº   € Ø€AØ	
�‰ˆq‹€BÜ	�Š�‹œŸš˜q›Õ	$€BØ	�‰ˆa��d�2�g˜˜!�˜U�
Õ"Ó#€AØ	ˆ!�ˆR��!�A•$�u•*Õ€AØ	
�‰ˆq��t�B�w‹˜!Ÿ%™%  !¥ R¥¨!¨A­$¨u­*Õ 4Ó5Õ	5€BØ	
ˆ1�ˆb�€BØ�ˆ<Ðr   c                 ót  € RpV P                  V 4      p\        P                   ! W4      \        P                   ! W4      ,           p\        P                   ! WD4      p\        P                   ! WE4      \        P                   ! WT4      ,           pV P                  V^,          V,          V^,          V,          ,           V^,          V,          ,           4      pV^,          V,          V^,          V,          ,           V^ ,          V,          ,           p	V P                  V^,          V,          V^,          V,          ,           4      VP                  V^,          V,          V^,          V,          ,           V^,          V,          ,           4      ,           p
V^,          V,          V^,          V,          ,           pW‰W«3# )ç     ˆÝ@)r2   g     ˆÍ@g     @ª@g     @z@g      >@r%   r&   )r   r   r(   r)   r*   r+   ÚA4ÚM4r,   r-   r.   r/   s   &&&         r   Ú_diff_pade5r5   ´   s&  € Ø.€AØ	
�‰ˆq‹€BÜ	�Š�‹œŸš˜q›Õ	$€BÜ	�Š�‹€BÜ	�Š�‹œ"Ÿ&š& ›.Õ	(€BØ	�‰ˆa��d�2�g˜˜!�˜R�Õ ! A¥$ u¥*Õ,Ó-€AØ	ˆ!�ˆR��!�A•$�r•'Õ˜A˜a�D �JÕ&€AØ
�%‰%��!•�R•˜!˜A�$˜r�'Õ!Ó
"Ø�E‰E�!�A•$�r•'˜A˜a�D �GÕ# a¨¥d¨5¥jÕ0Ó1õ2€Bà	
ˆ1�ˆb��1�Q•4˜•7Õ	€BØ�ˆ<Ðr   c                 óÔ  € RpV P                  V 4      p\        P                   ! W4      \        P                   ! W4      ,           p\        P                   ! WD4      p\        P                   ! WE4      \        P                   ! WT4      ,           p\        P                   ! WF4      p\        P                   ! We4      \        P                   ! Wt4      ,           p	V P                  V^,          V,          V^,          V,          ,           V^,          V,          ,           V^,          V,          ,           4      p
V^,          V,          V^,          V,          ,           V^,          V,          ,           V^ ,          V,          ,           pV P                  V^,          V	,          V^,          V,          ,           V^,          V,          ,           4      VP                  V^,          V,          V^,          V,          ,           V^,          V,          ,           V^,          V,          ,           4      ,           pV^,          V	,          V^,          V,          ,           V^,          V,          ,           pW«WÍ3# )ç    ø~pA)r7   g    ø~`Ag    @t>Ag    @ëAg     œØ@g      —@g      L@r%   r&   )r   r   r(   r)   r*   r+   r3   r4   ÚA6ÚM6r,   r-   r.   r/   s   &&&           r   Ú_diff_pade7r:   Â   sŽ  € ØH€AØ	
�‰ˆq‹€BÜ	�Š�‹œŸš˜q›Õ	$€BÜ	�Š�‹€BÜ	�Š�‹œ"Ÿ&š& ›.Õ	(€BÜ	�Š�‹€BÜ	�Š�‹œ"Ÿ&š& ›.Õ	(€BØ	�‰ˆa��d�2�g˜˜!�˜R�Õ ! A¥$ r¥'Õ)¨A¨a­D°­JÕ6Ó7€AØ	ˆ!�ˆR��!�A•$�r•'Õ˜A˜a�D �GÕ# a¨¥d¨5¥jÕ0€AØ
�%‰%��!•�R•˜!˜A�$˜r�'Õ! A a¥D¨¥GÕ+Ó
,Ø�E‰E�!�A•$�r•'˜A˜a�D �GÕ# a¨¥d¨2¥gÕ-°°!µ°Uµ
Õ:Ó;õ<€Bà	
ˆ1�ˆb��1�Q•4˜•7Õ	˜Q˜q�T "�WÕ	$€BØ�ˆ<Ðr   c                 ó4  € RpV P                  V 4      p\        P                   ! W4      \        P                   ! W4      ,           p\        P                   ! WD4      p\        P                   ! WE4      \        P                   ! WT4      ,           p\        P                   ! WF4      p\        P                   ! We4      \        P                   ! Wt4      ,           p	\        P                   ! Wf4      p
\        P                   ! Wg4      \        P                   ! Wv4      ,           pV P                  V^	,          V
,          V^,          V,          ,           V^,          V,          ,           V^,          V,          ,           V^,          V,          ,           4      pV^,          V
,          V^,          V,          ,           V^,          V,          ,           V^,          V,          ,           V^ ,          V,          ,           pV P                  V^	,          V,          V^,          V	,          ,           V^,          V,          ,           V^,          V,          ,           4      VP                  V^	,          V
,          V^,          V,          ,           V^,          V,          ,           V^,          V,          ,           V^,          V,          ,           4      ,           pV^,          V,          V^,          V	,          ,           V^,          V,          ,           V^,          V,          ,           pWÍWï3# )ç   ynB)
r<   g   yn Bg    îÞAg   @ß
²Ag    2Þ|Ag    ø~@Ag     û@g     ð®@g     €V@r%   r&   )r   r   r(   r)   r*   r+   r3   r4   r8   r9   ÚA8ÚM8r,   r-   r.   r/   s   &&&             r   Ú_diff_pade9r?   Ò   sù  € ð	/€Aà	
�‰ˆq‹€BÜ	�Š�‹œŸš˜q›Õ	$€BÜ	�Š�‹€BÜ	�Š�‹œ"Ÿ&š& ›.Õ	(€BÜ	�Š�‹€BÜ	�Š�‹œ"Ÿ&š& ›.Õ	(€BÜ	�Š�‹€BÜ	�Š�‹œ"Ÿ&š& ›.Õ	(€BØ	�‰ˆa��d�2�g˜˜!�˜R�Õ ! A¥$ r¥'Õ)¨A¨a­D°­GÕ3°a¸µd¸5µjÕ@ÓA€AØ	ˆ!�ˆR��!�A•$�r•'Õ˜A˜a�D �GÕ# a¨¥d¨2¥gÕ-°°!µ°Uµ
Õ:€AØ
�%‰%��!•�R•˜!˜A�$˜r�'Õ! A a¥D¨¥GÕ+¨a°­d°2­gÕ5Ó
6Ø�E‰E�!�A•$�r•'˜A˜a�D �GÕ# a¨¥d¨2¥gÕ-°°!µ°RµÕ7¸!¸A½$¸u½*ÕDÓEõF€Bà	
ˆ1�ˆb��1�Q•4˜•7Õ	˜Q˜q�T "�WÕ	$ q¨¥t¨B¥wÕ	.€BØ�ˆ<Ðr   c                 óž  € V P                   ^ ,          pRp\        P                  ! V4      p\        P                  P                  V ^4      p^\        3^\        3^\        3^	\        33pV F'  w  rxV\        V,          8:  g   K  V! WV4      w  ršr¼^ p M	  VEf>   \        ^ \        \        P                  ! \        P                  ! V\        ^,          ,          4      4      4      4      pV RV) ,          ,          p VRV) ,          ,          p\        P                  ! W 4      p\        P                  ! W4      \        P                  ! W4      ,           p\        P                  ! WÝ4      p\        P                  ! WÞ4      \        P                  ! Wí4      ,           p\        P                  ! Wß4      p\        P                  ! Wþ4      \        P                  ! VV4      ,           pRpV^,          V,          V^,          V,          ,           V^	,          V,          ,           pV^,          V,          V^,          V,          ,           V^,          V,          ,           V^,          V,          ,           pV^,          V,          V^
,          V,          ,           V^,          V,          ,           pV^,          V,          V^,          V,          ,           V^,          V,          ,           V^ ,          V,          ,           p\        P                  ! VV4      V,           p\        P                  ! V V4      p	\        P                  ! VV4      V,           p
V^,          V,          V^,          V,          ,           V^	,          V,          ,           pV^,          V,          V^,          V,          ,           V^,          V,          ,           pV^,          V,          V^
,          V,          ,           V^,          V,          ,           pV^,          V,          V^,          V,          ,           V^,          V,          ,           p\        P                  ! VV4      \        P                  ! VV4      ,           V,           p\        P                  ! V V4      \        P                  ! VV4      ,           p\        P                  ! VV4      \        P                  ! VV4      ,           V,           p\        P                  P!                  X	) X
,           4      p\        P                  P#                  VWš,           4      p\        P                  P#                  VXX,           \        P                  ! W¼,
          V4      ,           4      p \%        V4       FM  p!\        P                  ! VV 4      \        P                  ! V V4      ,           p \        P                  ! VV4      pKO  	  VV 3# )é    Ng       @)g D•`æÂlCg D•`æÂ\Cg `=Hbœ;Cg 	e‘ßCg €ùÅJXÝBg  šú"5£Bg  €¹/ƒcBg   \L8Bg   pÄ·ÓAg    syƒAg    €S-Ag     þÏ@g     Àf@r%   )r   r   Úidentityr   r   Únormr0   r5   r:   r?   Úell_table_61ÚmaxÚintÚceilÚlog2r'   Ú	lu_factorÚlu_solveÚrange)"r   r   r    Úsr(   ÚA_norm_1Úm_pade_pairsÚmÚpader,   r-   r.   r/   r*   r+   r3   r4   r8   r9   r)   ÚW1ÚW2ÚZ1ÚZ2ÚWÚLw1ÚLw2ÚLz1ÚLz2ÚLwÚlu_pivÚRÚLÚks"   &&                                r   r   r   å   só  € Ø	�‰��
€AØ€AÜ�KŠK˜‹N€EÜ�|‰|× Ñ   AÓ&€Hà”ÐØ”ÐØ”ÐØ”Ðð	€Ló
  ‰ˆØ”| A•Ö&Ù  eÓ,‰LˆA�"ØˆAÙñ	  ð
 	ƒyä�”3”r—w’wœrŸwšw x´,¸rÕ2BÕ'BÓCÓDÓEÓFˆØ��a�R•�KˆØ��a�R•�Kˆä�VŠV�A‹\ˆÜ�VŠV�A‹\œBŸFšF 1›LÕ(ˆÜ�VŠV�B‹^ˆÜ�VŠV�B‹^œbŸfšf R›nÕ,ˆÜ�VŠV�B‹^ˆÜ�VŠV�B‹^œbŸfšf R¨›nÕ,ˆð"ˆð ˆr�U�2�X˜˜"�˜b�Õ  1 Q¥4¨¥7Õ*ˆØˆq�T�"�W�q˜•t˜B•wÕ  1¥ b¥Õ(¨1¨Q­4°­:Õ5ˆØˆr�U�2�X˜˜"�˜b�Õ  1 Q¥4¨¥7Õ*ˆØˆq�T�"�W�q˜•t˜B•wÕ  1¥ b¥Õ(¨1¨Q­4°­:Õ5ˆÜ�FŠF�2�r‹N˜RÕˆÜ�FŠF�1�a‹LˆÜ�FŠF�2�r‹N˜RÕˆØ��e�B�h˜˜2�˜r�Õ! A a¥D¨¥GÕ+ˆØ��d�2�g˜˜!�˜R�Õ ! A¥$ r¥'Õ)ˆØ��e�B�h˜˜2�˜r�Õ! A a¥D¨¥GÕ+ˆØ��d�2�g˜˜!�˜R�Õ ! A¥$ r¥'Õ)ˆÜ�VŠV�B˜‹_œrŸvšv b¨"›~Õ-°Õ3ˆÜ�VŠV�A�r‹]œRŸVšV A q›\Õ)ˆÜ�VŠV�B˜‹_œrŸvšv b¨"›~Õ-°Õ3ˆä�\‰\×#Ñ# Q B¨¥FÓ+€FÜ�‰×Ñ˜f a¥eÓ,€AÜ�‰×Ñ˜f b¨2¥g´·²¸½À!Ó0DÕ&DÓE€Aä�1ŽXˆÜ�FŠF�1�a‹Lœ2Ÿ6š6 ! Q›<Õ'ˆÜ�FŠF�1�a‹LŠñ ð ˆaˆ4€Kr   c                ó6   € V P                   P                  4       # )zØ
Stack columns of M to construct a single vector.

This is somewhat standard notation in linear algebra.

Parameters
----------
M : 2-D array_like
    Input matrix

Returns
-------
v : 1-D ndarray
    Output vector

)ÚTÚravel)r!   s   &r   Úvecrb     s   € ð" �3‰3�9‰9‹;Ðr   c           
     ó~  € V'       d   \         P                  ! V 4      p M\         P                  ! V 4      p \        V P                  4      ^8w  g*   V P                  ^ ,          V P                  ^,          8w  d   \        R4      hV P                  ^ ,          p\         P                  ! V4      p. p\        V4       Fa  p\        V4       FO  p\         P                  ! WF,          WG,          4      p\        WVRRR7      p	VP                  \        V	4      4       KQ  	  Kc  	  \         P                  ! V4      P                  # )a¥  
Construct the Kronecker form of the Frechet derivative of expm.

Parameters
----------
A : array_like with shape (N, N)
    Matrix to be expm'd.
method : str, optional
    Extra keyword to be passed to expm_frechet.
check_finite : bool, optional
    Whether to check that the input matrix contains only finite numbers.
    Disabling may give a performance gain, but may result in problems
    (crashes, non-termination) if the inputs do contain infinities or NaNs.

Returns
-------
K : 2-D ndarray with shape (N*N, N*N)
    Kronecker form of the Frechet derivative of the matrix exponential.

Notes
-----
This function is used to help compute the condition number
of the matrix exponential.

See Also
--------
expm : Compute a matrix exponential.
expm_frechet : Compute the Frechet derivative of the matrix exponential.
expm_cond : Compute the relative condition number of the matrix exponential
            in the Frobenius norm.

úexpected a square matrixF)r   r   r   )r   r	   r
   Úlenr   r   rB   rK   Úouterr   Úappendrb   r   r`   )
r   r   r   r    r(   ÚcolsÚiÚjr   ÚFs
   &&&       r   Úexpm_frechet_kronformrl   1  sá   € ÷B Ü× Ò  Ó#‰ä�JŠJ�q‹MˆÜ
ˆ1�7‰7ƒ|�qÔ˜AŸG™G A�J¨!¯'©'°!­*Ô4ÜÐ3Ó4Ð4à	�‰��
€AÜ�KŠK˜‹N€EØ€DÜ�1ŽXˆÜ�q–ˆAÜ—’˜� 5¥8Ó,ˆAÜ˜QØ!°ÀEôKˆAà�K‰Kœ˜A›Öó	 ñ ô �9Š9�T‹?×ÑÐr   c                óB  € V'       d   \         P                  ! V 4      p M\         P                  ! V 4      p \        V P                  4      ^8w  g*   V P                  ^ ,          V P                  ^,          8w  d   \        R4      h\        P                  P                  V 4      p\        V RR7      p\        P                  P                  V R4      p\        P                  P                  VR4      p\        P                  P                  V^4      pWd,          V,          pV# )aø  
Relative condition number of the matrix exponential in the Frobenius norm.

Parameters
----------
A : 2-D array_like
    Square input matrix with shape (N, N).
check_finite : bool, optional
    Whether to check that the input matrix contains only finite numbers.
    Disabling may give a performance gain, but may result in problems
    (crashes, non-termination) if the inputs do contain infinities or NaNs.

Returns
-------
kappa : float
    The relative condition number of the matrix exponential
    in the Frobenius norm

See Also
--------
expm : Compute the exponential of a matrix.
expm_frechet : Compute the Frechet derivative of the matrix exponential.

Notes
-----
A faster estimate for the condition number in the 1-norm
has been published but is not yet implemented in SciPy.

.. versionadded:: 0.14.0

Examples
--------
>>> import numpy as np
>>> from scipy.linalg import expm_cond
>>> A = np.array([[-0.3, 0.2, 0.6], [0.6, 0.3, -0.1], [-0.7, 1.2, 0.9]])
>>> k = expm_cond(A)
>>> k
1.7787805864469866

rd   F)r   Úfro)r   r	   r
   re   r   r   r   r   r   rl   rC   )r   r   ÚXÚKÚA_normÚX_normÚK_normÚkappas   &&      r   r   r   e  sÍ   € ÷T Ü× Ò  Ó#‰ä�JŠJ�q‹MˆÜ
ˆ1�7‰7ƒ|�qÔ˜AŸG™G A�J¨!¯'©'°!­*Ô4ÜÐ3Ó4Ð4ä�‰×Ñ˜!Ó€AÜ˜a¨eÔ4€Aô
 �\‰\×Ñ˜q %Ó(€FÜ�\‰\×Ñ˜q %Ó(€FÜ�\‰\×Ñ˜q !Ó$€Fà�_ Õ&€EØ€Lr   )r   é   )r   ru   )NTT)NgaÑŒ€ì§V>gXþ|[°T7?g®Ø_vO†?g“©‚QI�°?gš™™™™™É?g+‡ÙÎ÷Û?gu“Vé?g®Gáz®ó?g{®Gázü?g\�Âõ(\@g
×£p=
	@g333333@gö(\�Âõ@g…ëQ¸…@g=
×£p=@g®Gáz@g�Âõ(\!@g…ëQ¸#@g333333%@gffffff'@)NT)T)Ú__doc__Únumpyr   Úscipy.linalgr   Úscipy._lib._utilr   Ú__all__r   r   rD   r0   r5   r:   r?   r   rb   rl   r   © r   r   Ú<module>r|      sŠ   ðÙ 3Û Û Ý .ð ˜;Ð
'€ñ �8˜XÓ&ókó 'ðkò\
*ðð
€ò>òòò ò&5òpô(1ñh �8Óó;ó ò;r   