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/sparse/linalg/_isolve/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

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

d�cA=��d�dZdgZddlmZmZmZmZddlmZddl	m
Z
ddlmZddl
mZ		dd
�ZdS)a�
Copyright (C) 2010 David Fong and Michael Saunders

LSMR uses an iterative method.

07 Jun 2010: Documentation updated
03 Jun 2010: First release version in Python

David Chin-lung Fong            clfong@stanford.edu
Institute for Computational and Mathematical Engineering
Stanford University

Michael Saunders                saunders@stanford.edu
Systems Optimization Laboratory
Dept of MS&E, Stanford University.

�lsmr�)�zeros�infty�
atleast_1d�result_type)�norm)�sqrt)�aslinearoperator)�
_sym_ortho����ư>��חANFc	�
�t|��}t|��}|jdkr|���}d}	d}
d}d}d}
|j\}}t||g��}|�|}|�t
||t��}nt
|||t��}|rntd��td	��td
|�d|�d���td
|z��td||fz��td||fz��|}t|��}|�%t||��}|���}nHt|�����}||�|��z
}t|��}|dkr-d|z|z}|�
|��}t|��}nt||��}d}|dkrd|z|z}d}||z}|}d}d}d}d}|���}t||��} |}!d}"d}#d}$d}%d}&d}'||z}(d})d}*t|(��}+d},d}-d}.d}/|dkrd|z}/|}0||z}1|1dkr!|rt|	d��||.||0|1|+|,|-fS|dkrd|d<||.||0|1|+|,|-fS|rftd��t|
|��d}2||z}3d||dfz}4d|0|1fz}5d|2|3fz}6td�|4|5|6g����||k�rT|dz}||z}||�|��z
}t|��}|dkrC|d|zz}||z}||�
|��z
}t|��}|dkr|d|zz}t!||��\}7}8}9|}:t!|9|��\};}<}|<|z}=|;|z}|}>|&}?||z}@||z}At!||z|=��\}}}||z}&||z}| |@|z|:|>zzz} | |z
} ||&||zz| zz
}||=|zz}||z
}|7|!z}B|8|!z}C|;|Bz}D|<|Bz}!|%}Et!|#|@��\}F}G}H|G|z}%|F|z}#|G|"z|F|Dzz}"|?|E|$zz
|Hz}$|&|%|$zz
|#z}I|'|C|Czz}'t|'|"|Iz
dzz|!|!zz��}0|(||zz}(t|(��}+|(||zz}(t#|)|>��})|dkrt|*|>��}*t#|)|A��t|*|A��z},t%|��}1t|��}-|0|z}2|+|0zdkr	|1|+|0zz}3nt&}3d|,z}J|2d|+|-z|zzz}K|||+z|-z|zz}L||krd}.d|Jzdkrd}.d|3zdkrd}.d|Kzdkrd}.|J|/krd}.|3|krd}.|2|Lkrd}.|r�|dks9|dks3||dz
ks*|dzdks!|Jd|/zks|3d|zks|2d|Lzks|.dkrt|
|kr!d}
td��t|
|��|
dz}
d||dfz}4d|0|1fz}5d|2|3fz}6d|+|,fz}Mtd�|4|5|6|Mg����|.dkrn||k��T|r�td��td ��t|	|.��td!|.|0fz��td"|+|1fz��td#||,fz��td$|-z��t|4|5��t|6|M��||.||0|1|+|,|-fS)%a�Iterative solver for least-squares problems.

    lsmr solves the system of linear equations ``Ax = b``. If the system
    is inconsistent, it solves the least-squares problem ``min ||b - Ax||_2``.
    ``A`` is a rectangular matrix of dimension m-by-n, where all cases are
    allowed: m = n, m > n, or m < n. ``b`` is a vector of length m.
    The matrix A may be dense or sparse (usually sparse).

    Parameters
    ----------
    A : {sparse matrix, ndarray, LinearOperator}
        Matrix A in the linear system.
        Alternatively, ``A`` can be a linear operator which can
        produce ``Ax`` and ``A^H x`` using, e.g.,
        ``scipy.sparse.linalg.LinearOperator``.
    b : array_like, shape (m,)
        Vector ``b`` in the linear system.
    damp : float
        Damping factor for regularized least-squares. `lsmr` solves
        the regularized least-squares problem::

         min ||(b) - (  A   )x||
             ||(0)   (damp*I) ||_2

        where damp is a scalar.  If damp is None or 0, the system
        is solved without regularization. Default is 0.
    atol, btol : float, optional
        Stopping tolerances. `lsmr` continues iterations until a
        certain backward error estimate is smaller than some quantity
        depending on atol and btol.  Let ``r = b - Ax`` be the
        residual vector for the current approximate solution ``x``.
        If ``Ax = b`` seems to be consistent, `lsmr` terminates
        when ``norm(r) <= atol * norm(A) * norm(x) + btol * norm(b)``.
        Otherwise, `lsmr` terminates when ``norm(A^H r) <=
        atol * norm(A) * norm(r)``.  If both tolerances are 1.0e-6 (default),
        the final ``norm(r)`` should be accurate to about 6
        digits. (The final ``x`` will usually have fewer correct digits,
        depending on ``cond(A)`` and the size of LAMBDA.)  If `atol`
        or `btol` is None, a default value of 1.0e-6 will be used.
        Ideally, they should be estimates of the relative error in the
        entries of ``A`` and ``b`` respectively.  For example, if the entries
        of ``A`` have 7 correct digits, set ``atol = 1e-7``. This prevents
        the algorithm from doing unnecessary work beyond the
        uncertainty of the input data.
    conlim : float, optional
        `lsmr` terminates if an estimate of ``cond(A)`` exceeds
        `conlim`.  For compatible systems ``Ax = b``, conlim could be
        as large as 1.0e+12 (say).  For least-squares problems,
        `conlim` should be less than 1.0e+8. If `conlim` is None, the
        default value is 1e+8.  Maximum precision can be obtained by
        setting ``atol = btol = conlim = 0``, but the number of
        iterations may then be excessive. Default is 1e8.
    maxiter : int, optional
        `lsmr` terminates if the number of iterations reaches
        `maxiter`.  The default is ``maxiter = min(m, n)``.  For
        ill-conditioned systems, a larger value of `maxiter` may be
        needed. Default is False.
    show : bool, optional
        Print iterations logs if ``show=True``. Default is False.
    x0 : array_like, shape (n,), optional
        Initial guess of ``x``, if None zeros are used. Default is None.

        .. versionadded:: 1.0.0

    Returns
    -------
    x : ndarray of float
        Least-square solution returned.
    istop : int
        istop gives the reason for stopping::

          istop   = 0 means x=0 is a solution.  If x0 was given, then x=x0 is a
                      solution.
                  = 1 means x is an approximate solution to A@x = B,
                      according to atol and btol.
                  = 2 means x approximately solves the least-squares problem
                      according to atol.
                  = 3 means COND(A) seems to be greater than CONLIM.
                  = 4 is the same as 1 with atol = btol = eps (machine
                      precision)
                  = 5 is the same as 2 with atol = eps.
                  = 6 is the same as 3 with CONLIM = 1/eps.
                  = 7 means ITN reached maxiter before the other stopping
                      conditions were satisfied.

    itn : int
        Number of iterations used.
    normr : float
        ``norm(b-Ax)``
    normar : float
        ``norm(A^H (b - Ax))``
    norma : float
        ``norm(A)``
    conda : float
        Condition number of A.
    normx : float
        ``norm(x)``

    Notes
    -----

    .. versionadded:: 0.11.0

    References
    ----------
    .. [1] D. C.-L. Fong and M. A. Saunders,
           "LSMR: An iterative algorithm for sparse least-squares problems",
           SIAM J. Sci. Comput., vol. 33, pp. 2950-2971, 2011.
           :arxiv:`1006.0758`
    .. [2] LSMR Software, https://web.stanford.edu/group/SOL/software/lsmr/

    Examples
    --------
    >>> import numpy as np
    >>> from scipy.sparse import csc_matrix
    >>> from scipy.sparse.linalg import lsmr
    >>> A = csc_matrix([[1., 0.], [1., 1.], [0., 1.]], dtype=float)

    The first example has the trivial solution ``[0, 0]``

    >>> b = np.array([0., 0., 0.], dtype=float)
    >>> x, istop, itn, normr = lsmr(A, b)[:4]
    >>> istop
    0
    >>> x
    array([0., 0.])

    The stopping code `istop=0` returned indicates that a vector of zeros was
    found as a solution. The returned solution `x` indeed contains
    ``[0., 0.]``. The next example has a non-trivial solution:

    >>> b = np.array([1., 0., -1.], dtype=float)
    >>> x, istop, itn, normr = lsmr(A, b)[:4]
    >>> istop
    1
    >>> x
    array([ 1., -1.])
    >>> itn
    1
    >>> normr
    4.440892098500627e-16

    As indicated by `istop=1`, `lsmr` found a solution obeying the tolerance
    limits. The given solution ``[1., -1.]`` obviously solves the equation. The
    remaining return values include information about the number of iterations
    (`itn=1`) and the remaining difference of left and right side of the solved
    equation.
    The final example demonstrates the behavior in the case where there is no
    solution for the equation:

    >>> b = np.array([1., 0.01, -1.], dtype=float)
    >>> x, istop, itn, normr = lsmr(A, b)[:4]
    >>> istop
    2
    >>> x
    array([ 1.00333333, -0.99666667])
    >>> A.dot(x)-b
    array([ 0.00333333, -0.00333333,  0.00333333])
    >>> normr
    0.005773502691896255

    `istop` indicates that the system is inconsistent and thus `x` is rather an
    approximate solution to the corresponding least-squares problem. `normr`
    contains the minimal distance that was found.
    �)z9The exact solution is x = 0, or x = x0, if x0 was given  z:Ax - b is small enough, given atol, btol                  z:The least-squares solution is good enough, given atol     z:The estimate of cond(Abar) has exceeded conlim            z:Ax - b is small enough for this machine                   z:The least-squares solution is good enough for this machinez:Cond(Abar) seems to be too large for this machine         z:The iteration limit has been reached                      z(   itn      x(1)       norm r    norm Arz% compatible   LS      norm A   cond A�rN� z2LSMR            Least-squares solution of  Ax = b
zThe matrix A has z
 rows and z columnszdamp = %20.14e
z,atol = %8.2e                 conlim = %8.2e
z'btol = %8.2e             maxiter = %8g
g}Ô%�I�T�z
%6g %12.5ez %10.3e %10.3ez
  %8.1e %8.1e��������(�
g�������?z %8.1e %8.1ez
LSMR finishedzistop =%8g    normr =%8.1ez!    normA =%8.1e    normAr =%8.1ezitn   =%8g    condA =%8.1ez    normx =%8.1e)r
r�ndim�squeeze�shape�minr�float�printrr�copy�matvec�rmatvecr	�joinr�max�absr)N�A�b�damp�atol�btol�conlim�maxiter�show�x0�msg�hdg1�hdg2�pfreq�pcount�m�n�minDim�dtype�u�normb�x�beta�v�alpha�itn�zetabar�alphabar�rho�rhobar�cbar�sbar�h�hbar�betadd�betad�rhodold�tautildeold�
thetatilde�zeta�d�normA2�maxrbar�minrbar�normA�condA�normx�istop�ctol�normr�normar�test1�test2�str1�str2�str3�chat�shat�alphahat�rhoold�c�s�thetanew�	rhobarold�zetaold�thetabar�rhotemp�	betaacute�	betacheck�betahat�
thetatildeold�	ctildeold�	stildeold�rhotildeold�taud�test3�t1�rtol�str4sN                                                                              �B/usr/lib/python3/dist-packages/scipy/sparse/linalg/_isolve/lsmr.pyrrs	��P	����A��1�
�
�A��v��z�z�
�I�I�K�K��I�C�6�D�2�D��E�
�F��7�D�A�q��!�Q��[�[�F�����	�z��A�q�%�(�(����A�q�"�e�,�,���L�
�c�
�
�
�
�C�D�D�D�
�:�!�:�:�q�:�:�:�;�;�;�
� �D�)�*�*�*�
�=��v��N�O�O�O�
�8�D�'�?�J�K�K�K�	�A���G�G�E�	�z��!�U�O�O���z�z�|�|����r�w�w�y�y�!�!��
�������O���A�w�w���a�x�x�
��X��N��
�I�I�a�L�L���Q������!�U�O�O�����q�y�y�
��Y�!�O���C��d�l�G��H�
�C�
�F��D��D�	�����A���E�?�?�D��F�
�E��G��K��J��D�	�A��U�]�F��G��G���L�L�E�
�E�
�E�
�E��D�
��z�z��6�z���E��T�\�F�
��{�{��	��#�a�&�M�M�M��%��e�V�U�E�5�@�@���z�z���"���%��e�V�U�E�5�@�@��+�
�c�
�
�
�
�d�D�����������s�A�a�D�k�)���5�&�/�1���%���/��
�b�g�g�t�T�4�(�)�)�*�*�*���-�-��A�g��	
�e�V���	�Q�X�X�a�[�[����A�w�w���!�8�8�
�!�d�(�O�A�
�$��J�A�
����1����A���G�G�E��q�y�y��a�%�i� �� *�(�D�9�9���d�H����x��.�.�	��1�c��U�7���U�7���	����#�:����*��'��s�
�H�=�=���d�F��g�~���&�7�"��	
�8�c�>�V�i�%7�8�9�9����	��	�d�c�F�l�#�t�
+�+��	��3��
���	�Q���
�6�M�	��E�F�N�	��i�-����i���
#�
�,6�w��,I�,I�)�	�9�k���'�
��f�$����e�#�i�'�&9�9��
���!<�<��K���z�K�/�/�7�:��
�	�I�%�%���Q�%�$�,��*�*�V�f�_�<�=�=���$��+�%���V�����%�%�-�'���g�y�)�)����7�7��'�9�-�-�G��G�W�%�%��G�W�(=�(=�=��
�W�����Q����
��
���E�M�a����e�e�m�,�E�E��E��E�	��
�a�%�%�-�%�/�/�
0���d�U�l�U�*�U�2�2���'�>�>��E��u�9��>�>��E��u�9��>�>��E��r�6�Q�;�;��E��D�=�=��E��D�=�=��E��D�=�=��E��	9��R���S�B�Y�Y�C�7�R�<�,?�,?��b��A�
�
�5�C�$�J�#6�#6���t��#�#��#��*�)<�)<���
�
��U�?�?��F��#�J�J�J��$��%�%�%��!���#�s�A�a�D�k�1��'�5�&�/�9��&�%���7��%����6���b�g�g�t�T�4��6�7�7�8�8�8��1�9�9��o��-�-�v�	�
�c�
�
�
�
�o����
�c�%�j����
�*�e�U�^�;�<�<�<�
�1�U�F�O�C�D�D�D�
�*�c�5�\�9�:�:�:�
� �E�*�+�+�+�
�d�D����
�d�D�����e�S�%����u�<�<�)rr
r
rNFN)�__doc__�__all__�numpyrrrr�numpy.linalgr�mathr	�scipy.sparse.linalg._interfacer
� scipy.sparse.linalg._isolve.lsqrrrrrxrw�<module>r�s�����$�(��7�7�7�7�7�7�7�7�7�7�7�7�������������;�;�;�;�;�;�7�7�7�7�7�7�7:�&*�I=�I=�I=�I=�I=�I=rx

Youez - 2016 - github.com/yon3zu
LinuXploit