o
    Ö­j  ã                   @   s´   d Z g ZddlmZmZmZmZ ddlmZm	Z	m
Z
 i dd“dd“dd	“d
d“dd“dd“dd“d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)Úfr	   r	   )r	   Údr
   )r	   ÚFr   )r	   ÚDr   )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vrd} |dvrd}t | |f S )NÚfdFDr
   )Ú_coerce_rules)ÚxÚy© r   ú^/var/www/html/CropPilot/venv/lib/python3.10/site-packages/scipy/sparse/linalg/_isolve/utils.pyÚcoerce   s
   r   c                 C   ó   | S ©Nr   ©r   r   r   r   Úid   ó   r   c                 C   sô  | }t | ƒ} | jd | jd krtd| jf› �ƒ‚| jd }t|ƒ}|j|dfks<|j|fks<td| j› d|j› d�ƒ‚|jjdvrG| d¡}d	d
„ }t| dƒrU| jj}n|  |¡jj}t	||jjƒ}t
||d�}| ¡ }|du r£t|dƒrz|j}nt}t|dƒr…|j}	nt}	|tu r˜|	tu r˜t| j| jd�}nt| j||	| jd�}nt |ƒ}| j|jkr±tdƒ‚|du r¼t||d�}
n7t|tƒrÏ|dkrÎ| ¡ }| |¡}
n$t||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   r   r   r   r   r   r   r   ÚpostprocessQ   r   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   ÚbCopyr   r   r   Úmake_system   s\   !






ÿ

€
ÿr2   N)Ú__docformat__Ú__all__Únumpyr   r   r   r   Úscipy.sparse.linalg._interfacer   r   r   r   r   r   r2   r   r   r   r   Ú<module>   sD    ÿÿÿþþþýýýüüüû