o
    g                     @   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   _/home/ubuntu/cloudmapper/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 rt|drz|j}nt}t|dr|j}	nt}	|tu r|	tu rt| j| jd}nt| j||	| jd}nt |}| j|jkrtd|du rt||d}
n7t|tr|dkr| }||}
n$t||d}
|
j|dfks|
j|fkst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    