U
    Æ»|e  ã                   @   sv   d Z g ZddlmZmZmZmZ ddlmZm	Z	m
Z
 dddddddddddddddddœZd	d
„ Zdd„ Zdd„ ZdS )zrestructuredtext ené    )Ú
asanyarrayÚasarrayÚarrayÚzeros)ÚaslinearoperatorÚLinearOperatorÚIdentityOperatorÚfÚdÚFÚD))r	   r	   )r	   r
   )r	   r   )r	   r   )r
   r	   )r
   r
   )r
   r   )r
   r   )r   r	   )r   r
   )r   r   )r   r   )r   r	   )r   r
   )r   r   )r   r   c                 C   s$   | dkrd} |dkrd}t | |f S )NÚfdFDr
   )Ú_coerce_rules)ÚxÚy© r   ú^/var/www/website-v5/atlas_env/lib/python3.8/site-packages/scipy/sparse/linalg/_isolve/utils.pyÚcoerce   s
    r   c                 C   s   | S ©Nr   ©r   r   r   r   Úid   s    r   c                 C   s  | }t | ƒ} | jd | jd kr2td| jf› �ƒ‚| jd }t|ƒ}|j|dfksx|j|fksxtd| j› d|j› d�ƒ‚|jjdkrŽ| d¡}d	d
„ }t| dƒrª| jj}n|  |¡jj}t	||jjƒ}t
||d�}| ¡ }|dk�rNt|dƒrö|j}nt}t|dƒ�r|j}	nt}	|tk�r8|	tk�r8t| j| jd�}nt| j||	| jd�}nt |ƒ}| j|jk�rltdƒ‚|dk�r„t||d�}
nvt|tƒ�r®|dk�rú| ¡ }| |¡}
nLt||d�}
|
j|dfk�sò|
j|fk�sòtd| j› d|
j› d�ƒ‚|
 ¡ }
| ||
||fS )aÊ  Make a linear system Ax=b

    Parameters
    ----------
    A : LinearOperator
        sparse or dense matrix (or any valid input to aslinearoperator)
    M : {LinearOperator, Nones}
        preconditioner
        sparse or dense matrix (or any valid input to aslinearoperator)
    x0 : {array_like, str, None}
        initial guess to iterative method.
        ``x0 = 'Mb'`` means using the nonzero initial guess ``M @ b``.
        Default is `None`, which means using the zero initial guess.
    b : array_like
        right hand side

    Returns
    -------
    (A, M, x, b, postprocess)
        A : LinearOperator
            matrix of the linear system
        M : LinearOperator
            preconditioner
        x : rank 1 ndarray
            initial guess
        b : rank 1 ndarray
            right hand side
        postprocess : function
            converts the solution vector to the appropriate
            type and dimensions (e.g. (N,1) matrix)

    r   é   z&expected square matrix, but got shape=zshapes of A z and b z are incompatibler   r
   c                 S   s   | S r   r   r   r   r   r   ÚpostprocessQ   s    z make_system.<locals>.postprocessÚdtype)r   NÚpsolveÚrpsolve)Úshaper   )ÚmatvecÚrmatvecr   z/matrix and preconditioner have different shapesÚMbz and x0 )r   r   Ú
ValueErrorr   r   ÚcharÚastypeÚhasattrr   r   r   Úravelr   r   r   r   r   r   Ú
isinstanceÚstrÚcopyr   )ÚAÚMÚx0ÚbÚA_ÚNr   Úxtyper   r   r   ZbCopyr   r   r   Úmake_system   sV    !






ÿ

r/   N)Ú__docformat__Ú__all__Únumpyr   r   r   r   Úscipy.sparse.linalg._interfacer   r   r   r   r   r   r/   r   r   r   r   Ú<module>   s*           û