§
    fŠtjn*  ã            	       ób   — d dl mZmZmZmZ d dlmZ d dlmZ ddl	m
Z
 dgZddd	dddd
d
dœd„ZdS )é    )ÚinnerÚzerosÚinfÚfinfo)Únorm)Úsqrté   )Úmake_systemÚminresNgñhãˆµøä>g        F)ÚrtolÚshiftÚmaxiterÚMÚcallbackÚshowÚcheckc                ó^  — t          | |||¦  «        \  } }}
}| j        }|j        }d}d}| j        d         }|€d|z  }g d¢}|rTt          |dz   ¦  «         t          |d|d	›d
|d›�z   ¦  «         t          |d|d	›d|d›�z   ¦  «         t          ¦   «          d}d}d}d}d}d}|
j        }t          |¦  «        j        }|€|                     ¦   «         }n|| |
z  z
  } ||¦  «        }t          ||¦  «        }|dk     rt          d¦  «        ‚|dk    r|
dfS t          |¦  «        }|dk    r|}
|
dfS t          |¦  «        }|	rÅ ||¦  «        } ||¦  «        }t          ||¦  «        }t          ||¦  «        } t          || z
  ¦  «        }!||z   |dz  z  }"|!|"k    rt          d¦  «        ‚ ||¦  «        }t          ||¦  «        }t          ||¦  «        } t          || z
  ¦  «        }!||z   |dz  z  }"|!|"k    rt          d¦  «        ‚d}#|}$d}%d}&|}'|}(|})d}*d}+d},t          |¦  «        j        }-d}.d}/t          ||¬¦  «        }t          ||¬¦  «        }0|}|r+t          ¦   «          t          ¦   «          t          d¦  «         ||k     �r|dz  }d|$z  }||z  }1 ||1¦  «        }|||1z  z
  }|dk    r||$|#z  |z  z
  }t          |1|¦  «        }2||2|$z  |z  z
  }|}|} ||¦  «        }|$}#t          ||¦  «        }$|$dk     rt          d¦  «        ‚t          |$¦  «        }$|+|2dz  |#dz  z   |$dz  z   z  }+|dk    r|$|z  d|z  k    rd}|&}3|.|%z  |/|2z  z   }4|/|%z  |.|2z  z
  }5|/|$z  }&|. |$z  }%t          |5|%g¦  «        }6|(|6z  }7t          |5|$g¦  «        }8t          |8|¦  «        }8|5|8z  }.|$|8z  }/|.|(z  }9|/|(z  }(d|8z  }:|0};|}0|1|3|;z  z
  |4|0z  z
  |:z  }|
|9|z  z   }
t          |,|8¦  «        },t          |-|8¦  «        }-|)|8z  }!|*|4|!z  z
  })|& |!z  }*t          |+¦  «        }t          |
¦  «        }||z  }"||z  |z  }<||z  |z  }=|5}>|>dk    r|"}>|(}'|'}|dk    s|dk    rt           }?n|||z  z  }?|dk    rt           }@n|6|z  }@|,|-z  }|dk    rEd|?z   }Ad|@z   }B|Bdk    rd}|Adk    rd}||k    rd}|d|z  k    rd}|<|k    rd}|@|k    rd}|?|k    rd}d}C|dk    rd }C|dk    rd }C||dz
  k    rd }C|dz  dk    rd }C|'d|<z  k    rd }C|'d|=z  k    rd }C|d!|z  k    rd }C|dk    rd }C|rX|CrV|d"›d#|
d         d$›d#|?d%›�}Dd#|@d%›�}Ed#|d&›d#|d&›d#|5|z  d&›�}Ft          |D|Ez   |Fz   ¦  «         |dz  dk    rt          ¦   «          |� ||
¦  «         |dk    rn||k     �°|r�t          ¦   «          t          |d'|d	›d(|d)›�z   ¦  «         t          |d*|d+›d,|d+›�z   ¦  «         t          |d-|d+›d.|d+›�z   ¦  «         t          |d/|7d+›�z   ¦  «         t          |||dz            z   ¦  «         |dk    r|}Gnd}G|
|GfS )0aç  
    Solve ``Ax = b`` with the MINimum RESidual method, for a symmetric `A`.

    MINRES minimizes norm(Ax - b) for a real symmetric matrix A.  Unlike
    the Conjugate Gradient method, A can be indefinite or singular.

    If shift != 0 then the method solves (A - shift*I)x = b

    Parameters
    ----------
    A : {sparse array, ndarray, LinearOperator}
        The real symmetric N-by-N matrix of the linear system
        Alternatively, ``A`` can be a linear operator which can
        produce ``Ax`` using, e.g.,
        ``scipy.sparse.linalg.LinearOperator``.
    b : ndarray
        Right hand side of the linear system. Has shape (N,) or (N,1).

    Returns
    -------
    x : ndarray
        The converged solution.
    info : integer
        Provides convergence information:
            0  : successful exit
            >0 : convergence to tolerance not achieved, number of iterations
            <0 : illegal input or breakdown

    Other Parameters
    ----------------
    x0 : ndarray
        Starting guess for the solution.
    shift : float
        Value to apply to the system ``(A - shift * I)x = b``. Default is 0.
    rtol : float
        Tolerance to achieve. The algorithm terminates when the relative
        residual is below ``rtol``.
    maxiter : integer
        Maximum number of iterations.  Iteration will stop after maxiter
        steps even if the specified tolerance has not been achieved.
    M : {sparse array, ndarray, LinearOperator}
        Preconditioner for A.  The preconditioner should approximate the
        inverse of A.  Effective preconditioning dramatically improves the
        rate of convergence, which implies that fewer iterations are needed
        to reach a given error tolerance.
    callback : function
        User-supplied function to call after each iteration.  It is called
        as callback(xk), where xk is the current solution vector.
    show : bool
        If ``True``, print out a summary and metrics related to the solution
        during iterations. Default is ``False``.
    check : bool
        If ``True``, run additional input validation to check that `A` and
        `M` (if specified) are symmetric. Default is ``False``.

    Examples
    --------
    >>> import numpy as np
    >>> from scipy.sparse import csc_array
    >>> from scipy.sparse.linalg import minres
    >>> A = csc_array([[3, 2, 0], [1, -1, 0], [0, 5, 1]], dtype=float)
    >>> A = A + A.T
    >>> b = np.array([2, 4, -1], dtype=float)
    >>> x, exitCode = minres(A, b)
    >>> print(exitCode)            # 0 indicates successful convergence
    0
    >>> np.allclose(A.dot(x), b)
    True

    References
    ----------
    Solution of sparse indefinite systems of linear equations,
        C. C. Paige and M. A. Saunders (1975),
        SIAM J. Numer. Anal. 12(4), pp. 617-629.
        https://web.stanford.edu/group/SOL/software/minres/

    This file is a translation of the following MATLAB implementation:
        https://web.stanford.edu/group/SOL/software/minres/minres-matlab.zip

    zEnter minres.   zExit  minres.   r   Né   )z3 beta2 = 0.  If M = I, b and x are eigenvectors    z/ beta1 = 0.  The exact solution is x0          z3 A solution to Ax = b was found, given rtol        z3 A least-squares solution was found, given rtol    z3 Reasonable accuracy achieved, given eps           z3 x has converged to an eigenvector                 z3 acond has exceeded 0.1/eps                        z3 The iteration limit was reached                   z3 A  does not define a symmetric matrix             z3 M  does not define a symmetric matrix             z3 M  does not define a pos-def preconditioner       zSolution of symmetric Ax = bz
n      =  Ú3gz     shift  =  z23.14ez
itnlim =  z     rtol   =  z11.2ezindefinite preconditionergUUUUUUÕ?znon-symmetric matrixznon-symmetric preconditioneréÿÿÿÿ)ÚdtypezD   Itn     x(1)     Compatible    LS       norm(A)  cond(A) gbar/|A|r	   g      ð?é   é
   é   gš™™™™™¹?é   é   Fé(   Tg{®Gáz„?Ú6gú z12.5ez10.3ez8.1ez istop   =  z               itn   =Ú5gz Anorm   =  z12.4ez      Acond =  z rnorm   =  z      ynorm =  z Arnorm  =  )r
   ÚmatvecÚshapeÚprintr   r   ÚepsÚcopyr   Ú
ValueErrorr   r   ÚabsÚmaxr   Úminr   )HÚAÚbÚx0r   r   r   r   r   r   r   Úxr!   ÚpsolveÚfirstÚlastÚnÚmsgÚistopÚitnÚAnormÚAcondÚrnormÚynormÚxtyper$   Úr1ÚyÚbeta1ÚbnormÚwÚr2ÚsÚtÚzÚepsaÚoldbÚbetaÚdbarÚepslnÚqrnormÚphibarÚrhs1Úrhs2Útnorm2ÚgmaxÚgminÚcsÚsnÚw2ÚvÚalfaÚoldepsÚdeltaÚgbarÚrootÚArnormÚgammaÚphiÚdenomÚw1ÚepsxÚepsrÚdiagÚtest1Útest2Út1Út2ÚprntÚstr1Ústr2Ústr3ÚinfosH                                                                           ú`/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/scipy/sparse/linalg/_isolve/minres.pyr   r   
   s°  € õd ˜Q  2 qÑ)Ô)�J€A€qˆ!ˆQàŒX€FØŒX€Fà€EØ€Dà	Œ�Œ
€Aà€Ø�a‘%ˆð
Cð 
Cð 
C€Cð ð ÝˆeÐ4Ñ4Ñ5Ô5Ð5ÝˆeÐF 1ÐFÐFÐF¸ÐFÐFÐFÑFÑGÔGÐGÝˆeÐJ 7ÐJÐJÐJ¸dÐJÐJÐJÑJÑKÔKÐKÝ‰Œˆà€EØ
€CØ€EØ€EØ€EØ€EàŒG€Eå
�‰,Œ,Ô
€Cð 
€zØ�VŠV‰XŒXˆˆà��1‘‰WˆØˆˆr‰
Œ
€Aå�"�a‰LŒL€Eàˆq‚y€yÝÐ4Ñ5Ô5Ð5Ø	�!ŠˆØ�1ˆvˆå�‰GŒG€EØ�‚z€zØˆØ�1ˆvˆå�‰KŒK€Eàð =ð ˆF�1‰IŒIˆØˆV�A‰YŒYˆÝ�!�A‰JŒJˆÝ�!�B‰KŒKˆÝ��A‘‰JŒJˆØ�C‘˜3 ™>Ñ)ˆØˆtŠ8ˆ8ÝÐ3Ñ4Ô4Ð4ð ˆV�A‰YŒYˆÝ�!�A‰JŒJˆÝ�"�R‰LŒLˆÝ��A‘‰JŒJˆØ�C‘˜3 ™>Ñ)ˆØˆtŠ8ˆ8ÝÐ;Ñ<Ô<Ð<ð €DØ€DØ€DØ€EØ€FØ€FØ€DØ€DØ€FØ€DÝ�‰<Œ<Ô€DØ	€BØ	
€BÝˆa�uÐÑÔ€AÝ	ˆq˜Ð	Ñ	Ô	€BØ	€Bàð VÝ‰ŒˆÝ‰ŒˆÝÐTÑUÔUÐUà
�Š-‰-Øˆq‰ˆà�‰HˆØˆa‰CˆàˆF�1‰IŒIˆØ�˜‘	‰Mˆà�!Š8ˆ8Ø�T˜$‘Y ‘NÑ"ˆAå�Q�q‰zŒzˆØ��d‘˜B‘ÑˆØˆØˆØˆF�2‰JŒJˆØˆÝ�R˜‰{Œ{ˆØ�!Š8ˆ8ÝÐ3Ñ4Ô4Ð4Ý�D‰zŒzˆØ�$˜‘'˜D !™GÑ# d¨A¡gÑ-Ñ-ˆà�!Š8ˆ8Ø�E‰z˜R ™VÒ#Ð#Ø�ð ˆØ�T‘	˜B ™IÑ%ˆØ�D‰y˜2 ™9Ñ$ˆØ�T‘	ˆØˆt�d‰{ˆÝ�T˜4�LÑ!Ô!ˆØ˜$‘ˆõ �d˜D�\Ñ"Ô"ˆÝ�E˜3‘”ˆØ�E‰\ˆØ�E‰\ˆØ�6‰kˆØ�f‘ˆð �E‘	ˆØˆØˆØ�˜‘‰]˜U 2™XÑ%¨Ñ.ˆØ��A‘‰Iˆõ �4˜ÑÔˆÝ�4˜ÑÔˆØ�5‰LˆØ�e˜A‘g‰~ˆØˆw�q‰yˆõ �V‘”ˆÝ�Q‘”ˆØ�s‰{ˆØ�u‰}˜sÑ"ˆØ�u‰}˜tÑ#ˆØˆà�1Š9ˆ9ØˆDàˆØˆØ�AŠ:ˆ:˜ !š˜ÝˆEˆEà˜U 5™[Ñ)ˆEØ�AŠ:ˆ:ÝˆEˆEà˜5‘LˆEð �T‘	ˆð
 �AŠ:ˆ:Ø�U‘ˆBØ�U‘ˆBØ�QŠwˆwØ�Ø�QŠwˆwØ�à�gŠ~ˆ~Ø�Ø˜˜C™ÒÐØ�Ø�uŠ}ˆ}Ø�ð ˜Š}ˆ}Ø�Ø˜Š}ˆ}Ø�ð ˆØ�Š7ˆ7ØˆDØ�"Š9ˆ9ØˆDØ�'˜"‘*ÒÐØˆDØ�‰8�qŠ=ˆ=ØˆDØ�R˜‘WÒÐØˆDØ�R˜‘WÒÐØˆDØ�D˜‘HÒÐØˆDØ�AŠ:ˆ:ØˆDàð 	�Dð 	ØÐ9Ð9Ð9˜q œtÐ9Ð9Ð9¨EÐ9Ð9Ð9ˆDØ$�uÐ$Ð$Ð$ˆDØB�uÐBÐBÐB EÐBÐBÐB°°e±ÐBÐBÐBˆDå�$˜‘+ Ñ$Ñ%Ô%Ð%à�R‰x˜1Š}ˆ}Ý‘”�àÐØˆH�Q‰KŒKˆKà�AŠ:ˆ:Øðu �Š-‰-ðx ð #Ý‰ŒˆÝˆdÐL EÐLÐLÐLÀCÐLÐLÐLÑLÑMÔMÐMÝˆdÐM EÐMÐMÐMÀÐMÐMÐMÑMÑNÔNÐNÝˆdÐM EÐMÐMÐMÀÐMÐMÐMÑMÑNÔNÐNÝˆdÐ2 FÐ2Ð2Ð2Ñ2Ñ3Ô3Ð3Ýˆd�S˜˜q™”\Ñ!Ñ"Ô"Ð"à�‚z€zØˆˆàˆàˆdˆ8€Oó    )N)Únumpyr   r   r   r   Únumpy.linalgr   Úmathr   Úutilsr
   Ú__all__r   © rj   ri   ú<module>rq      s¥   ðØ *Ð *Ð *Ð *Ð *Ð *Ð *Ð *Ð *Ð *Ð *Ð *Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð à Ð Ð Ð Ð Ð àˆ*€ðj $¨c¸4Ø˜D u°Eðjð jð jð jð jð jð jrj   