
    tKg                         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 Zd Zd Zy)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                 0    | dvrd} |dvrd}t         | |f   S )NfdFDr   )_coerce_rules)xys     e/home/alanp/www/video.onchill/myenv/lib/python3.12/site-packages/scipy/sparse/linalg/_isolve/utils.pycoercer      s)    1    c                     | S N r   s    r   idr      s    Hr   c                    | }t        |       } | j                  d   | j                  d   k7  rt        d| j                  f       | j                  d   }t        |      }|j                  |dfk(  s6|j                  |fk(  s&t        d| j                   d|j                   d      |j                  j
                  dvr|j                  d      }d	 }t        | d
      r| j                  j
                  }n%| j                  |      j                  j
                  }t        ||j                  j
                        }t        ||      }|j                         }|t        |d      r|j                  }nt        }t        |d      r|j                  }	nt        }	|t        u r*|	t        u r"t        | j                  | j                        }nSt!        | j                  ||	| j                        }n/t        |      }| j                  |j                  k7  rt        d      |t#        ||      }
nt%        |t&              r'|dk(  r|j)                         }|j                  |      }
ndt+        ||      }
|
j                  |dfk(  s6|
j                  |fk(  s&t        d| j                   d|
j                   d      |
j                         }
| |
||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   s    r   postprocessz make_system.<locals>.postprocessQ   s    r   dtype)r   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   bCopys               r   make_systemr6      sl   B 
BAwwqzQWWQZA177*NOO	
A1AGG!uA4<yy A( ( ) 	) 	ww||6!HHSM q!!&&5!'',,'EA		A 	y2hYYFF2i jjGGR<GrM qwwagg>Aqwwvw%&WW.A Q77aggNOO 
z!5!	B	:FFHEA"E"Aq6!QWW_|AGG9 5##$77)+<> ? ?GGIaA{""r   N)__docformat____all__numpyr   r   r   r   scipy.sparse.linalg._interfacer   r   r	   r   r   r   r6   r   r   r   <module>r;      s   %
 4 3  3  	#  y  3  )# /8 3  )# /8  3  !*#  09  3	  !*#	  09	 
 3 `#r   