| Server IP : 217.160.0.135 / Your IP : 216.73.217.85 Web Server : Apache System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64 User : sws1074145052 ( 1074145052) PHP Version : 8.3.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /lib/python3/dist-packages/scipy/linalg/__pycache__/ |
Upload File : |
�
d�c&0 � �j � d Z ddlZddlZddgZdd�Zd� Z dZd � Z d
� Z
d� Zd� Zd
� Z
d� Zdd�Zdd�ZdS )z-Frechet derivative of the matrix exponential.� N�expm_frechet� expm_condTc �b � |r)t j | � � } t j |� � }n(t j | � � } t j |� � }| j dk s| j d | j d k rt d� � �|j dk s|j d |j d k rt d� � �| j |j k rt d� � �|�d}|dk rt
| |� � \ }}n,|d k rt | |� � \ }}nt d
|z � � �|r||fS |S )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 containg [[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
� r � z expected A to be a square matrixz expected E to be a square matrixz%expected A and E to be the same shapeN�SPS�blockEnlargezUnknown implementation %s)�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 �</usr/lib/python3/dist-packages/scipy/linalg/_expm_frechet.pyr r s> � �h � �� ��#�#��� ��#�#����J�q�M�M���J�q�M�M���v��{�{�a�g�a�j�A�G�A�J�.�.��;�<�<�<��v��{�{�a�g�a�j�A�G�A�J�.�.��;�<�<�<��w�!�'����@�A�A�A�
�~���
����"6�q�!�"<�"<����� �>� !� !�"<�Q��"B�"B������4�v�=�>�>�>�� ���&�&��� c �2 � | j d }t j t j | |g� � t j t j | � � | g� � g� � }t
j � |� � }|d|�d|�f |d|�|d�f fS )zh
This is a helper function, mostly for testing and profiling.
Return expm(A), frechet(A, E)
r N)r r
�vstack�hstack�
zeros_like�scipy�linalg�expm)r r �n�M�expm_Ms r r r v s� � �
���
�A�
� �
� �1�a�&���
� �2�=��#�#�Q�'�(�(�*� +� +�A� �\�
�
�q�
!�
!�F��"�1�"�b�q�b�&�>�6�"�1�"�a�b�b�&�>�)�)r )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'@c � � d}| � | � � }t j | |� � t j || � � z }| � |d |z |d |z z � � }|d |z |d |z z }| � |d |z � � |� |d |z |d |z z � � z }|d |z } |||| fS )N)g ^@g N@g (@� �?� r r r ��dotr
)
r r �ident�b�A2�M2�U�V�Lu�Lvs
r �_diff_pade3r2 � s� � ��A�
���q���B� ���1�����q�!��� $�B� ���a��d�2�g��!��U�
�"�#�#�A� �!��R��!�A�$�u�*��A�
���q��t�B�w���!�%�%��!��R��!�A�$�u�*� 4�5�5� 5�B�
�1��b��B��a��R�<�r c � � d}| � | � � }t j | |� � t j || � � z }t j ||� � }t j ||� � t j ||� � z }| � |d |z |d |z z |d |z z � � }|d |z |d |z z |d |z z } | � |d |z |d |z z � � |� |d |z |d |z z |d |z z � � z }
|d |z |d |z z }|| |
|fS )N)g ��@g ��@g @�@g @z@g >@r&