403Webshell
Server IP : 217.160.0.135  /  Your IP : 216.73.217.37
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/optimize/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

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

d�c/<��x�dZddlZddlmZmZmZmZddlm	Z	m
Z
gd�Zdd�Zd	�Z
d
�Zd�ZGd�d
e
��ZdS)z2Nearly exact trust-region optimization subproblem.�N)�norm�get_lapack_funcs�solve_triangular�	cho_solve�)�_minimize_trust_region�BaseQuadraticSubproblem)�_minimize_trustregion_exact� estimate_smallest_singular_value�singular_leading_submatrix�IterativeSubproblem�c��|�td���t|��std���t||f|||td�|��S)a
    Minimization of scalar function of one or more variables using
    a nearly exact trust-region algorithm.

    Options
    -------
    initial_tr_radius : float
        Initial trust-region radius.
    max_tr_radius : float
        Maximum value of the trust-region radius. No steps that are longer
        than this value will be proposed.
    eta : float
        Trust region related acceptance stringency for proposed steps.
    gtol : float
        Gradient norm must be less than ``gtol`` before successful
        termination.
    Nz9Jacobian is required for trust region exact minimization.z?Hessian matrix is required for trust region exact minimization.)�args�jac�hess�
subproblem)�
ValueError�callablerr
)�fun�x0rrr�trust_region_optionss      �C/usr/lib/python3/dist-packages/scipy/optimize/_trustregion_exact.pyr
r

sv��(�{��/�0�0�	0��D�>�>�0��/�0�0�	0�!�#�r�:��#�D�-@�:�:�$8�:�:�:�c��tj|��}|j\}}||krtd���tj|��}tj|��}t
|��D]�}d||z
|j||fz}d||z
|j||fz}||dzd�|j|dzd�|f|zz}||dzd�|j|dzd�|f|zz}	t|��t|d��zt|��t|	d��zkr|||<|||dzd�<��|||<|	||dzd�<��t||��}
t|
��}t|��}||z}
|
|z}|
|fS)aZGiven upper triangular matrix ``U`` estimate the smallest singular
    value and the correspondent right singular vector in O(n**2) operations.

    Parameters
    ----------
    U : ndarray
        Square upper triangular matrix.

    Returns
    -------
    s_min : float
        Estimated smallest singular value of the provided matrix.
    z_min : ndarray
        Estimatied right singular vector.

    Notes
    -----
    The procedure is based on [1]_ and is done in two steps. First, it finds
    a vector ``e`` with components selected from {+1, -1} such that the
    solution ``w`` from the system ``U.T w = e`` is as large as possible.
    Next it estimate ``U v = w``. The smallest singular value is close
    to ``norm(w)/norm(v)`` and the right singular vector is close
    to ``v/norm(v)``.

    The estimation will be better more ill-conditioned is the matrix.

    References
    ----------
    .. [1] Cline, A. K., Moler, C. B., Stewart, G. W., Wilkinson, J. H.
           An estimate for the condition number of a matrix.  1979.
           SIAM Journal on Numerical Analysis, 16(2), 368-375.
    z.A square triangular matrix should be provided.r���N)�np�
atleast_2d�shaper�zeros�empty�range�T�absrr)�U�m�n�p�w�k�wp�wm�pp�pm�v�v_norm�w_norm�s_min�z_mins               rrr,s���D	�
�a���A��7�D�A�q��A�v�v��I�J�J�J�	�����A�
�����A��1�X�X������!��f���A�q�D�	�
!����1��g���Q��T��
"��
�q��s�t�t�W�q�s�1�Q�3�4�4��7�|�B��
&��
�q��s�t�t�W�q�s�1�Q�3�4�4��7�|�B��
&���r�7�7�T�"�a�[�[� �C��G�G�d�2�q�k�k�$9�9�9��A�a�D��A�a��c�d�d�G�G��A�a�D��A�a��c�d�d�G�G�	��A���A�
�!�W�W�F�
�!�W�W�F�
�V�O�E�
��J�E��%�<�rc��tj|��}tj|��}tjtj|��d���}tj||z|z
��}tj||z
|z��}||fS)a
    Given a square matrix ``H`` compute upper
    and lower bounds for its eigenvalues (Gregoshgorin Bounds).
    Defined ref. [1].

    References
    ----------
    .. [1] Conn, A. R., Gould, N. I., & Toint, P. L.
           Trust region methods. 2000. Siam. pp. 19.
    r)�axis)r�diagr$�sum�min�max)�H�H_diag�
H_diag_abs�
H_row_sums�lb�ubs      r�gershgorin_boundsr@{su���W�Q�Z�Z�F������J�����q�	�	��*�*�*�J�	����#�j�0�	1�	1�B�	����#�j�0�	1�	1�B�
�r�6�Mrc�R�tj|d|dz
�|dz
fdz��||dz
|dz
fz
}t|��}tj|��}d||dz
<|dkr;t	|d|dz
�d|dz
�f|d|dz
�|dz
f��|d|dz
�<||fS)a
    Compute term that makes the leading ``k`` by ``k``
    submatrix from ``A`` singular.

    Parameters
    ----------
    A : ndarray
        Symmetric matrix that is not positive definite.
    U : ndarray
        Upper triangular matrix resulting of an incomplete
        Cholesky decomposition of matrix ``A``.
    k : int
        Positive integer such that the leading k by k submatrix from
        `A` is the first non-positive definite leading submatrix.

    Returns
    -------
    delta : float
        Amount that should be added to the element (k, k) of the
        leading k by k submatrix of ``A`` to make it singular.
    v : ndarray
        A vector such that ``v.T B v = 0``. Where B is the matrix A after
        ``delta`` is added to its element (k, k).
    Nr�)rr7�lenr r)�Ar%r*�deltar'r/s      rrr�s���6
�F�1�T�a��c�T�1�Q�3�Y�<��?�#�#�a��!��Q�q�S��k�1�E��A���A�	�����A�
�A�a��c�F�	�A�v�v�"�1�T�a��c�T�4�A�a�C�4�Z�=�1�T�a��c�T�1�Q�3�Y�<�-�@�@��$�1�Q�3�$���!�8�Orc�b��eZdZdZdZeje��jZ			d	�fd�	Z
d�Zd�Z�xZ
S)
r
a�Quadratic subproblem solved by nearly exact iterative method.

    Notes
    -----
    This subproblem solver was based on [1]_, [2]_ and [3]_,
    which implement similar algorithms. The algorithm is basically
    that of [1]_ but ideas from [2]_ and [3]_ were also used.

    References
    ----------
    .. [1] A.R. Conn, N.I. Gould, and P.L. Toint, "Trust region methods",
           Siam, pp. 169-200, 2000.
    .. [2] J. Nocedal and  S. Wright, "Numerical optimization",
           Springer Science & Business Media. pp. 83-91, 2006.
    .. [3] J.J. More and D.C. Sorensen, "Computing a trust region step",
           SIAM Journal on Scientific and Statistical Computing, vol. 4(3),
           pp. 553-572, 1983.
    g{�G�z�?N皙�����?皙�����?c���t���||||��d|_d|_d|_||_||_td|jf��\|_	t|j��|_t|j��\|_
|_t|jt j��|_t|jd��|_|j|jz|jz|_dS)Nrr)�potrf�fro)�super�__init__�previous_tr_radius�	lambda_lb�niter�k_easy�k_hardrr�choleskyrC�	dimensionr@�hess_gershgorin_lb�hess_gershgorin_ubrr�Inf�hess_inf�hess_fro�EPS�
CLOSE_TO_ZERO)	�self�xrrr�hessprQrR�	__class__s	        �rrMzIterativeSubproblem.__init__�s����	������C��d�+�+�+�#%��������
�������
*�*�t�y�l�C�C���
��T�Y�����&7��	�&B�&B�	$����#��T�Y���/�/��
��T�Y��.�.��
�"�^�d�h�6���F����rc
��td|j|zt|j|j|j��z��}tdt|j�����|j|zt|j|j|j��z
��}||j	krt|j
|��}|dkrd}n3ttj||z��||j
||z
zz��}|||fS)z�Given a trust radius, return a good initial guess for
        the damping factor, the lower bound and the upper bound.
        The values were chosen accordingly to the guidelines on
        section 7.3.8 (p. 192) from [1]_.
        r)r9�jac_magr8rUrYrXr�diagonalrVrNrOr�sqrt�UPDATE_COEFF)r\�	tr_radius�	lambda_ubrO�lambda_initials     r�_initial_valuesz#IterativeSubproblem._initial_values�s����4�<�	�1�C��9P�8P�8<�
�8<�
�5G�5G�G�H�H�	�
��C��	� 2� 2� 4� 4�5�5�5���Y�.��T�5L�59�]�59�]�2D�2D�D�E�E�	��t�.�.�.��D�N�I�6�6�I���>�>��N�N� ����Y�)>�!?�!?�!*�T�->�	�)�@S�-T�!T�V�V�N��y�)�3�3rc�\�|�|��\}}}|j}d}d}d|_	|rd}n;|j|t	j|��zz}|�|ddd���\}	}
|xjdz
c_|
dk�r�|j|jk�r�t|	df|j
��}t|��}||kr
|dkrd}�n�t|	|d���}
t|
��}||zdz||z
z|z}||z}||k�r<t|	��\}}|�|||��\}}t||gt �	��}t	j|t	j||����}|dz|dzz|||dzzzz}||jkr
|||zz
}�n�|}t'|||dzz
��}|j|t	j|��zz}|�|ddd���\}}
|
dkr|}d}�n�t'||��}t't	j||z��||j||z
zz��}�nMt!||z
��|z}||jkr�n-|}|}�n%|
dkr�|j|jkr�|dkrt	j|��}d}n�t|	��\}}|}|dz|dzz|j|z|dzzkr||z}n�|}t'|||dzz
��}t't	j||z��||j||z
zz��}not1||	|
��\}}t|��}t'||||dzzz��}t't	j||z��||j||z
zz��}��h||_||_||_||fS)
zSolve quadratic subproblemTFr)�lower�overwrite_a�cleanrr#)�transrB)�key)rhrTrPrr�eyerSrar[rrrrr�get_boundaries_intersectionsr8r$�dotrRr9rcrdrQr rrO�lambda_currentrN)r\rerrrOrfr'�
hits_boundary�already_factorizedr:r%�infor(�p_normr)r1�delta_lambda�
lambda_newr2r3�ta�tb�step_len�quadratic_term�relative_error�crEr/r0s                            r�solvezIterativeSubproblem.solves���04�/C�/C�I�/N�/N�,��	�9��N���
�"����
�B	Z�"�
4�%*�"�"��I�n�R�V�A�Y�Y�6�6���-�-���49�.2�(�4�4���4�
�J�J�!�O�J�J��q�y�y�T�\�D�,>�>�>��q�%�j�4�8�)�4�4���a�����Y�&�&�>�Q�+>�+>�$)�M��%�Q���5�5�5���a����!'�v�
��1�V�I�5E�F�y�P��+�l�:�
��I�%�%�#C�A�#F�#F�L�E�5�!�>�>�q�%�?H�J�J�F�B�� #�B��8��5�5�5�H�&(�V�A�r�v�a��|�|�%<�%<�N�'/��k�E�1�H�&<��R`�aj�lm�am�Rm�Am�%n�N�%���4�4��X��-�-���!/�I� #�I�~��q��/H� I� I�I��	�J�r�v�a�y�y�$8�8�A�"�m�m�A�U�8=�26�,�8�8�G�A�t��q�y�y�)3��-1�*�*�%(�	�:�$>�$>�	�*-�R�W�Y��5J�-K�-K�-6��9J�I�V_�L_�9`�-`�*b�*b���
&)��)�);�%<�%<�y�%H�N�%���4�4��!/�I�&0�N�N�����t�|�t�/A�A�A�"�Q�&�&������A�$)�M��?��B�B���u�$���Q�;����)�T�[�>�-I�I�WX�L�-X�X�X� �5�(�A��+�	��	�>�E�1�H�+D�E�E�	�"%�R�W�Y��-B�%C�%C�%.��1B�I�i�DW�1X�%X�"Z�"Z���6�a��D�A�A���q��a���� �	�>�E�&�!�)�O�+K�L�L�	�"%�R�W�Y��-B�%C�%C�%.��1B�I�i�DW�1X�%X�"Z�"Z��CB	Z�H#���,���"+����-��r)NrGrH)�__name__�
__module__�__qualname__�__doc__rdr�finfo�float�epsrZrMrhr�
__classcell__)r_s@rr
r
�s����������,�L�
�"�(�5�/�/�
�C�04�$'�'G�'G�'G�'G�'G�'G�R4�4�4�>Q �Q �Q �Q �Q �Q �Q rr
)rNN)r��numpyr�scipy.linalgrrrr�_trustregionrr	�__all__r
rr@rr
rrr�<module>r�s��8�8�����%�%�%�%�%�%�%�%�%�%�%�%�K�K�K�K�K�K�K�K�"�"�"��:�:�:�:�>L�L�L�^���*'�'�'�Tt �t �t �t �t �1�t �t �t �t �t r

Youez - 2016 - github.com/yon3zu
LinuXploit