U
    Ç»|eÊv  ã                
   @   s8  d Z ddddddgZddlZdd	lmZ ddlZd
dlmZ ddl	m
Z
 d
dlmZ ddlmZ ddlmZ dddddœZdZdZdd„ Zdd„ Zd3dd„Zedd d!d"�eƒ d4d$d„ƒƒZed%d&d'd"�eƒ d5d(d„ƒƒZed)d*d+d"�eƒ d6d,d„ƒƒZed-d.d/d"�eƒ d7d0d„ƒƒZeƒ d8d1d„ƒZeƒ d9d2d„ƒZdS ):z,Iterative methods for solving linear systemsÚbicgÚbicgstabÚcgÚcgsÚgmresÚqmré    N)Údedenté   )Ú
_iterative)ÚLinearOperator)Úmake_system)Ú_aligned_zeros)Únon_reentrantÚsÚdÚcÚz)Úfr   ÚFÚDzC
Parameters
----------
A : {sparse matrix, ndarray, LinearOperator}aX  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.
tol, atol : float, optional
    Tolerances for convergence, ``norm(residual) <= max(tol*norm(b), atol)``.
    The default for ``atol`` is ``'legacy'``, which emulates
    a different legacy behavior.

    .. warning::

       The default value for `atol` will be changed in a future release.
       For future compatibility, specify `atol` explicitly.
maxiter : integer
    Maximum number of iterations.  Iteration will stop after maxiter
    steps even if the specified tolerance has not been achieved.
M : {sparse matrix, 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.
c                 C   s(   t j | ¡}||kr|dfS |dfS dS )z;
    Successful termination condition for the solvers.
    r	   r   N©ÚnpÚlinalgÚnorm)ZresidualÚatolÚresid© r   úb/var/www/website-v5/atlas_env/lib/python3.8/site-packages/scipy/sparse/linalg/_isolve/iterative.pyÚ	_stoptestC   s    r   c                 C   sz   |dkr$t jdj|d�tdd� d}t| ƒ} |dkr`|ƒ }|| krFdS |dkrR| S | t|ƒ S ntt|ƒ| t|ƒ ƒS dS )	až  
    Parse arguments for absolute tolerance in termination condition.

    Parameters
    ----------
    tol, atol : object
        The arguments passed into the solver routine by user.
    bnrm2 : float
        2-norm of the rhs vector.
    get_residual : callable
        Callable ``get_residual()`` that returns the initial value of
        the residual.
    routine_name : str
        Name of the routine.
    Na	  scipy.sparse.linalg.{name} called without specifying `atol`. The default value will be changed in a future release. For compatibility, specify a value for `atol` explicitly, e.g., ``{name}(..., atol=0)``, or to retain the old behavior ``{name}(..., atol='legacy')``)Únameé   ©ÚcategoryÚ
stacklevelÚlegacyÚexitr   )ÚwarningsÚwarnÚformatÚDeprecationWarningÚfloatÚmax)Útolr   Úbnrm2Úget_residualÚroutine_namer   r   r   r   Ú	_get_atolN   s"    ü ûr0   Ú Ú0c                    s   ‡ ‡‡fdd„}|S )Nc              	      s*   d  ˆtdˆ  dd¡ ttˆƒf¡| _| S )NÚ
z    z
    )ÚjoinÚcommon_doc1ÚreplaceÚcommon_doc2r   Ú__doc__)Úfn©ÚAinfoÚfooterÚheaderr   r   Úcombinex   s     þzset_docstring.<locals>.combiner   )r=   r;   r<   Zatol_defaultr>   r   r:   r   Úset_docstringw   s    r?   z7Use BIConjugate Gradient iteration to solve ``Ax = b``.zÁThe real or complex N-by-N matrix of the linear system.
Alternatively, ``A`` can be a linear operator which can
produce ``Ax`` and ``A^T x`` using, e.g.,
``scipy.sparse.linalg.LinearOperator``.a1                 Examples
               --------
               >>> import numpy as np
               >>> from scipy.sparse import csc_matrix
               >>> from scipy.sparse.linalg import bicg
               >>> A = csc_matrix([[3, 2, 0], [1, -1, 0], [0, 5, 1]], dtype=float)
               >>> b = np.array([2, 4, -1], dtype=float)
               >>> x, exitCode = bicg(A, b)
               >>> print(exitCode)            # 0 indicates successful convergence
               0
               >>> np.allclose(A.dot(x), b)
               True

               )r<   çñhãˆµøä>c              
      s¤  t | ||ˆ ƒ\} }‰‰ }tˆ ƒ}	|d kr0|	d }| j| j ‰}
|j|j }}tˆjj }tt|d ƒ}‡ ‡‡fdd„}t	||t
j ˆ ¡|dƒ}|dkr¢|ˆƒdfS |}d}d	}td
|	 ˆjd�}d}d}d}|}|}|ˆ ˆ|||||||ƒ	\	‰}}}}}}}}|d k	�r||k�r|ˆƒ t|d |d |	 ƒ}t|d |d |	 ƒ}|d	k�rj|d k	�rv|ˆƒ �qv�n|dk�r¢||  |9  < ||  |ˆ|| ƒ 7  < nÎ|dk�rÚ||  |9  < ||  ||
|| ƒ 7  < n–|dk�rö||| ƒ||< nz|dk�r||| ƒ||< n^|dk�rF||  |9  < ||  |ˆˆƒ 7  < n*|d
k�rp|�r^d	}d}t|| |ƒ\}}d}qÐ|dk�r˜||k�r˜||k�s˜|}|ˆƒ|fS )Né
   Z
bicgrevcomc                      s   t j ˆˆƒˆ  ¡S ©Nr   r   ©ÚbÚmatvecÚxr   r   Ú<lambda>¢   ó    zbicg.<locals>.<lambda>r   r%   r   r	   éÿÿÿÿé   ©ÚdtypeTé   é   r    é   F)r   ÚlenrE   ÚrmatvecÚ
_type_convrL   ÚcharÚgetattrr
   r0   r   r   r   r   Úslicer   )ÚArD   Úx0r,   ÚmaxiterÚMÚcallbackr   ÚpostprocessÚnrQ   ÚpsolveÚrpsolveÚltrÚrevcomr.   r   Úndx1Úndx2ÚworkÚijobÚinfoÚftflagÚiter_ÚolditerÚsclr1Úsclr2Úslice1Úslice2r   rC   r   r   €   sj    ÿ







zBUse BIConjugate Gradient STABilized iteration to solve ``Ax = b``.z³The real or complex 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``.a¹                 Examples
               --------
               >>> import numpy as np
               >>> from scipy.sparse import csc_matrix
               >>> from scipy.sparse.linalg import bicgstab
               >>> R = np.array([[4, 2, 0, 1],
               ...               [3, 0, 0, 2],
               ...               [0, 1, 1, 1],
               ...               [0, 2, 1, 0]])
               >>> A = csc_matrix(R)
               >>> b = np.array([-1, -0.5, -1, 2])
               >>> x, exit_code = bicgstab(A, b)
               >>> print(exit_code)  # 0 indicates successful convergence
               0
               >>> np.allclose(A.dot(x), b)
               True
               c              
      s>  t | ||ˆ ƒ\} }‰‰ }tˆ ƒ}	|d kr0|	d }| j‰|j}
tˆjj }tt|d ƒ}‡ ‡‡fdd„}t||t	j
 ˆ ¡|dƒ}|dkr’|ˆƒdfS |}d}d	}td
|	 ˆjd�}d}d}d}|}|}|ˆ ˆ|||||||ƒ	\	‰}}}}}}}}|d k	�r
||k�r
|ˆƒ t|d |d |	 ƒ}t|d |d |	 ƒ}|d	k�rX|d k	�r|ˆƒ �qn²|dk�r�||  |9  < ||  |ˆ|| ƒ 7  < nz|dk�r¬|
|| ƒ||< n^|dk�rà||  |9  < ||  |ˆˆƒ 7  < n*|dk�r
|�rød	}d}t|| |ƒ\}}d}qÀ|dk�r2||k�r2||k�s2|}|ˆƒ|fS )NrA   Zbicgstabrevcomc                      s   t j ˆˆƒˆ  ¡S rB   r   r   rC   r   r   rG   ü   rH   zbicgstab.<locals>.<lambda>r   r%   r   r	   rI   é   rK   TrM   rN   r    F©r   rP   rE   rR   rL   rS   rT   r
   r0   r   r   r   r   rU   r   ©rV   rD   rW   r,   rX   rY   rZ   r   r[   r\   r]   r_   r`   r.   r   ra   rb   rc   rd   re   rf   rg   rh   ri   rj   rk   rl   r   rC   r   r   ×   s`    ÿ





z5Use Conjugate Gradient iteration to solve ``Ax = b``.zïThe real or complex N-by-N matrix of the linear system.
``A`` must represent a hermitian, positive definite matrix.
Alternatively, ``A`` can be a linear operator which can
produce ``Ax`` using, e.g.,
``scipy.sparse.linalg.LinearOperator``.a°                 Examples
               --------
               >>> import numpy as np
               >>> from scipy.sparse import csc_matrix
               >>> from scipy.sparse.linalg import cg
               >>> P = np.array([[4, 0, 1, 0],
               ...               [0, 5, 0, 0],
               ...               [1, 0, 3, 2],
               ...               [0, 0, 2, 4]])
               >>> A = csc_matrix(P)
               >>> b = np.array([-1, -0.5, -1, 2])
               >>> x, exit_code = cg(A, b)
               >>> print(exit_code)    # 0 indicates successful convergence
               0
               >>> np.allclose(A.dot(x), b)
               True

               c              
      st  t | ||ˆ ƒ\} }‰‰ }tˆ ƒ}	|d kr0|	d }| j‰|j}
tˆjj }tt|d ƒ}‡ ‡‡fdd„}t||t	j
 ˆ ¡|dƒ}|dkr’|ˆƒdfS |}d}d	}td
|	 ˆjd�}d}d}d}|}|}|ˆ ˆ|||||||ƒ	\	‰}}}}}}}}|d k	�r
||k�r
|ˆƒ t|d |d |	 ƒ}t|d |d |	 ƒ}|d	k�rX|d k	�rF|ˆƒ �qFnè|dk�r�||  |9  < ||  |ˆ|| ƒ 7  < n°|dk�r¬|
|| ƒ||< n”|dk�rà||  |9  < ||  |ˆˆƒ 7  < n`|d
k�r@|�rød	}d}t|| |ƒ\}}|dk�r@|dk�r@ˆ ˆˆƒ ||< t|| |ƒ\}}d}qÀ|dk�rh||k�rh||k�sh|}|ˆƒ|fS )NrA   Zcgrevcomc                      s   t j ˆˆƒˆ  ¡S rB   r   r   rC   r   r   rG   R  rH   zcg.<locals>.<lambda>r   r%   r   r	   rI   r    rK   TrM   rN   Frn   ro   r   rC   r   r   ,  sf    ÿ





z=Use Conjugate Gradient Squared iteration to solve ``Ax = b``.z¯The real-valued 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``.a¯                 Examples
               --------
               >>> import numpy as np
               >>> from scipy.sparse import csc_matrix
               >>> from scipy.sparse.linalg import cgs
               >>> R = np.array([[4, 2, 0, 1],
               ...               [3, 0, 0, 2],
               ...               [0, 1, 1, 1],
               ...               [0, 2, 1, 0]])
               >>> A = csc_matrix(R)
               >>> b = np.array([-1, -0.5, -1, 2])
               >>> x, exit_code = cgs(A, b)
               >>> print(exit_code)  # 0 indicates successful convergence
               0
               >>> np.allclose(A.dot(x), b)
               True
               c              
      sž  t | ||ˆ ƒ\} }‰‰ }tˆ ƒ}	|d kr0|	d }| j‰|j}
tˆjj }tt|d ƒ}‡ ‡‡fdd„}t||t	j
 ˆ ¡|dƒ}|dkr’|ˆƒdfS |}d}d	}td
|	 ˆjd�}d}d}d}|}|}|ˆ ˆ|||||||ƒ	\	‰}}}}}}}}|d k	�r
||k�r
|ˆƒ t|d |d |	 ƒ}t|d |d |	 ƒ}|d	k�rX|d k	�rF|ˆƒ �qFnè|dk�r�||  |9  < ||  |ˆ|| ƒ 7  < n°|dk�r¬|
|| ƒ||< n”|dk�rà||  |9  < ||  |ˆˆƒ 7  < n`|dk�r@|�rød	}d}t|| |ƒ\}}|dk�r@|dk�r@ˆ ˆˆƒ ||< t|| |ƒ\}}d}qÀ|dk�rptˆ ˆˆƒ |ƒ\}}|�rpd}|dk�r’||k�r’||k�s’|}|ˆƒ|fS )NrA   Z	cgsrevcomc                      s   t j ˆˆƒˆ  ¡S rB   r   r   rC   r   r   rG   ¬  rH   zcgs.<locals>.<lambda>r   r%   r   r	   rI   rm   rK   TrM   rN   r    Fiöÿÿÿrn   )rV   rD   rW   r,   rX   rY   rZ   r   r[   r\   r]   r_   r`   r.   r   ra   rb   rc   rd   re   rf   rg   rh   ri   rj   rk   rl   Úokr   rC   r   r   ‡  sn    ÿ






c           )         s&  |dkr|}n&|dk	r t dƒ‚nd}tj|tdd� |dk	rT|
dkrTtjdtdd� |
dkr`d	}
|
d
krvt d |
¡ƒ‚|dkr‚d}
t| ||ˆ ƒ\} }‰‰ }tˆ ƒ}|dkr²|d }|dkr¾d}t||ƒ}| j‰|j}t	ˆj
j }tt|d ƒ}tj ˆ ¡}tj |ˆ ƒ¡}‡ ‡‡fdd„}t||	||dƒ}	|	dk�r@|ˆƒdfS |dk�rV|ˆ ƒdfS d}|t||	| ƒ }tj}tj}d}d}td| | ˆj
d�}t|d d| d  ˆj
d�}d}d}d}|}|} d}!d}"d}#|}$|ˆ ˆ||||||||||ƒ\	‰}}}}}}%}&}|
dk�r$||$k�r$|ˆƒ t|d |d | ƒ}'t|d |d | ƒ}(|dk�r’|
dk�rx|"�rŠ||| ƒ n|
dk�r|ˆƒ �q�nH|dk�rÈ||(  |&9  < ||(  |%ˆˆƒ 7  < �n|dk�rü|||( ƒ||'< |!�sö| dk�röd}"d}!nÞ|dk�r\||(  |&9  < ||(  |%ˆ||' ƒ 7  < |"�rÚ|
dk�rN||| ƒ d}"|#d }#n~|dk�rÚ|�rtd}d}t||' |	ƒ\}}|�s–||k�r¦tdd| ƒ}ntd d!| ƒ}|dk�rÒ|t||	| ƒ }n|| }|} d}|
d	k�rÔ|#|k�rÔ|}�q�qÔ|dk�r||	k�s|}|ˆƒ|fS )"aá  
    Use Generalized Minimal RESidual iteration to solve ``Ax = b``.

    Parameters
    ----------
    A : {sparse matrix, ndarray, LinearOperator}
        The real or complex 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 : int
        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 (a vector of zeros by default).
    tol, atol : float, optional
        Tolerances for convergence, ``norm(residual) <= max(tol*norm(b), atol)``.
        The default for ``atol`` is ``'legacy'``, which emulates
        a different legacy behavior.

        .. warning::

           The default value for `atol` will be changed in a future release.
           For future compatibility, specify `atol` explicitly.
    restart : int, optional
        Number of iterations between restarts. Larger values increase
        iteration cost, but may be necessary for convergence.
        Default is 20.
    maxiter : int, optional
        Maximum number of iterations (restart cycles).  Iteration will stop
        after maxiter steps even if the specified tolerance has not been
        achieved.
    M : {sparse matrix, ndarray, LinearOperator}
        Inverse of the preconditioner of A.  M should approximate the
        inverse of A and be easy to solve for (see Notes).  Effective
        preconditioning dramatically improves the rate of convergence,
        which implies that fewer iterations are needed to reach a given
        error tolerance.  By default, no preconditioner is used.
    callback : function
        User-supplied function to call after each iteration.  It is called
        as `callback(args)`, where `args` are selected by `callback_type`.
    callback_type : {'x', 'pr_norm', 'legacy'}, optional
        Callback function argument requested:
          - ``x``: current iterate (ndarray), called on every restart
          - ``pr_norm``: relative (preconditioned) residual norm (float),
            called on every inner iteration
          - ``legacy`` (default): same as ``pr_norm``, but also changes the
            meaning of 'maxiter' to count inner iterations instead of restart
            cycles.
    restrt : int, optional, deprecated

        .. deprecated:: 0.11.0
           `gmres` keyword argument `restrt` is deprecated infavour of
           `restart` and will be removed in SciPy 1.12.0.

    See Also
    --------
    LinearOperator

    Notes
    -----
    A preconditioner, P, is chosen such that P is close to A but easy to solve
    for. The preconditioner parameter required by this routine is
    ``M = P^-1``. The inverse should preferably not be calculated
    explicitly.  Rather, use the following template to produce M::

      # Construct a linear operator that computes P^-1 @ x.
      import scipy.sparse.linalg as spla
      M_x = lambda x: spla.spsolve(P, x)
      M = spla.LinearOperator((n, n), M_x)

    Examples
    --------
    >>> import numpy as np
    >>> from scipy.sparse import csc_matrix
    >>> from scipy.sparse.linalg import gmres
    >>> A = csc_matrix([[3, 2, 0], [1, -1, 0], [0, 5, 1]], dtype=float)
    >>> b = np.array([2, 4, -1], dtype=float)
    >>> x, exitCode = gmres(A, b)
    >>> print(exitCode)            # 0 indicates successful convergence
    0
    >>> np.allclose(A.dot(x), b)
    True
    NzOCannot specify both restart and restrt keywords. Preferably use 'restart' only.zj'gmres' keyword argument 'restrt' is deprecated infavour of 'restart' and will be removed in SciPy 1.12.0.rM   )r#   a4  scipy.sparse.linalg.gmres called without specifying `callback_type`. The default value will be changed in a future release. For compatibility, specify a value for `callback_type` explicitly, e.g., ``{name}(..., callback_type='pr_norm')``, or to retain the old behavior ``{name}(..., callback_type='legacy')``rN   r!   r$   )rF   Úpr_normr$   zUnknown callback_type: {!r}ÚnonerA   é   Zgmresrevcomc                      s   t j ˆˆƒˆ  ¡S rB   r   r   rC   r   r   rG   z  rH   zgmres.<locals>.<lambda>r   r%   r   g      ð?r	   rI   rJ   rK   TFrF   )rq   r$   r    g      ø?g¼‰Ø—²Òœ<g      Ð?)Ú
ValueErrorr&   r'   r)   r(   r   rP   ÚminrE   rR   rL   rS   rT   r
   r   r   r   r0   Únanr   rU   r   r+   ))rV   rD   rW   r,   ZrestartrX   rY   rZ   Zrestrtr   Zcallback_typeÚmsgr[   r\   r]   r_   r`   r-   ZMb_nrm2r.   Zptol_max_factorZptolr   Zpresidra   rb   rc   Zwork2rd   re   rf   rg   Zold_ijobZ
first_passZresid_readyZiter_numrh   ri   rj   rk   rl   r   rC   r   r   ç  sÌ    e
 û


ÿ











c	           !   
      sj  ˆ ‰t ˆ d|ˆƒ\‰ }	‰‰}
|dkr°|dkr°tˆdƒrˆ‡fdd„}‡fdd„}‡fdd„}‡fd	d
„}tˆ j||d�}tˆ j||d�}n(dd„ }tˆ j||d�}tˆ j||d�}tˆƒ}|dkrÈ|d }tˆjj }tt	|d ƒ}‡ ‡‡fdd„}t
||tj ˆ¡|dƒ}|dk�r |
ˆƒdfS |}d}d}td| ˆjƒ}d}d}d}|}|}|ˆˆ|||||||ƒ	\	‰}}}}}}}}|dk	�r–||k�r–|ˆƒ t|d |d | ƒ}t|d |d | ƒ} |dk�ræ|dk	�r<|ˆƒ �q<�nN|dk�r"||   |9  < ||   |ˆ  || ¡ 7  < �n|dk�r\||   |9  < ||   |ˆ  || ¡ 7  < nØ|dk�rz| ||  ¡||< nº|dk�r˜| ||  ¡||< nœ|dk�r¶| ||  ¡||< n~|dk�rÔ| ||  ¡||< n`|dk�r
||   |9  < ||   |ˆ  ˆ¡ 7  < n*|dk�r4|�r"d}d }t|| |ƒ\}}d}�qL|dk�r^||k�r^||k�s^|}|
ˆƒ|fS )!a	  Use Quasi-Minimal Residual iteration to solve ``Ax = b``.

    Parameters
    ----------
    A : {sparse matrix, ndarray, LinearOperator}
        The real-valued N-by-N matrix of the linear system.
        Alternatively, ``A`` can be a linear operator which can
        produce ``Ax`` and ``A^T x`` 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.
    tol, atol : float, optional
        Tolerances for convergence, ``norm(residual) <= max(tol*norm(b), atol)``.
        The default for ``atol`` is ``'legacy'``, which emulates
        a different legacy behavior.

        .. warning::

           The default value for `atol` will be changed in a future release.
           For future compatibility, specify `atol` explicitly.
    maxiter : integer
        Maximum number of iterations.  Iteration will stop after maxiter
        steps even if the specified tolerance has not been achieved.
    M1 : {sparse matrix, ndarray, LinearOperator}
        Left preconditioner for A.
    M2 : {sparse matrix, ndarray, LinearOperator}
        Right preconditioner for A. Used together with the left
        preconditioner M1.  The matrix M1@A@M2 should have better
        conditioned than A alone.
    callback : function
        User-supplied function to call after each iteration.  It is called
        as callback(xk), where xk is the current solution vector.

    See Also
    --------
    LinearOperator

    Examples
    --------
    >>> import numpy as np
    >>> from scipy.sparse import csc_matrix
    >>> from scipy.sparse.linalg import qmr
    >>> A = csc_matrix([[3, 2, 0], [1, -1, 0], [0, 5, 1]], dtype=float)
    >>> b = np.array([2, 4, -1], dtype=float)
    >>> x, exitCode = qmr(A, b)
    >>> print(exitCode)            # 0 indicates successful convergence
    0
    >>> np.allclose(A.dot(x), b)
    True
    Nr]   c                    s   ˆ   | d¡S ©NÚleft©r]   ©rD   ©ÚA_r   r   Úleft_psolve!  s    zqmr.<locals>.left_psolvec                    s   ˆ   | d¡S ©NÚrightrz   r{   r|   r   r   Úright_psolve$  s    zqmr.<locals>.right_psolvec                    s   ˆ   | d¡S rx   ©r^   r{   r|   r   r   Úleft_rpsolve'  s    zqmr.<locals>.left_rpsolvec                    s   ˆ   | d¡S r   r‚   r{   r|   r   r   Úright_rpsolve*  s    zqmr.<locals>.right_rpsolve)rE   rQ   c                 S   s   | S rB   r   r{   r   r   r   Úid/  s    zqmr.<locals>.idrA   Z	qmrrevcomc                      s   t j ˆ  ˆ¡ˆ ¡S rB   )r   r   r   rE   r   )rV   rD   rF   r   r   rG   ;  rH   zqmr.<locals>.<lambda>r   r%   r   r	   rI   é   TrM   rN   r    rO   rJ   rm   é   F)r   Úhasattrr   ÚshaperP   rR   rL   rS   rT   r
   r0   r   r   r   r   rU   rE   rQ   r   )!rV   rD   rW   r,   rX   ZM1ZM2rZ   r   rY   r[   r~   r�   rƒ   r„   r…   r\   r_   r`   r.   r   ra   rb   rc   rd   re   rf   rg   rh   ri   rj   rk   rl   r   )rV   r}   rD   rF   r   r   Ø  s†    D

ÿ


"
 





)r1   r2   )Nr@   NNNN)Nr@   NNNN)Nr@   NNNN)Nr@   NNNN)	Nr@   NNNNNNN)Nr@   NNNNN)r8   Ú__all__r&   Útextwrapr   Únumpyr   r1   r
   Zscipy.sparse.linalg._interfacer   Úutilsr   Úscipy._lib._utilr   Zscipy._lib._threadsafetyr   rR   r5   r7   r   r0   r?   r   r   r   r   r   r   r   r   r   r   Ú<module>   sh   ÿÿ))
	ûAú<úAûG      ÿ q  ÿ