ó
Ê½÷Xc           @` s  d  d l  m Z m Z m Z d Z g  Z d  d l m Z d  d l m	 Z	 m
 Z
 m Z m Z m Z m Z d  d l m Z m Z m Z i d d 6d d 6d d 6d	 d 6d d 6d d 6d	 d 6d	 d 6d d 6d	 d 6d d 6d	 d 6d	 d 6d	 d 6d	 d 6d	 d 6Z d
 „  Z d „  Z d d „ Z d S(   i    (   t   divisiont   print_functiont   absolute_imports   restructuredtext en(   t   warn(   t
   asanyarrayt   asarrayt   asmatrixt   arrayt   matrixt   zeros(   t   aslinearoperatort   LinearOperatort   IdentityOperatort   ft   dt   Ft   Dc         C` s8   |  d k r d }  n  | d k r* d } n  t  |  | f S(   Nt   fdFDR   (   t   _coerce_rules(   t   xt   y(    (    s?   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/linalg/isolve/utils.pyt   coerce   s
    		c         C` s   |  S(   N(    (   R   (    (    s?   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/linalg/isolve/utils.pyt   id   s    c         ` sß  |  } t  |  ƒ }  |  j d |  j d k rE t d |  j f ƒ ‚ n  |  j d } t ˆ  ƒ ‰  ˆ  j | d f k p‚ ˆ  j | f k s” t d ƒ ‚ n  ˆ  j j d k r¸ ˆ  j d ƒ ‰  n  ‡  f d †  } | d k rt |  d ƒ rñ |  j j } n |  j	 ˆ  ƒ j j } t
 | ˆ  j j ƒ } nC t d	 t ƒ | d k rFˆ  j j } n | d k rat d
 ƒ ‚ n  t ˆ  d | ƒ‰  ˆ  j ƒ  ‰  | d k r t | d | ƒ} nT t | d | ƒ} | j | d f k pÖ| j | f k sèt d ƒ ‚ n  | j ƒ  } | d k rŸt | d ƒ r| j }	 n t }	 t | d ƒ r<| j }
 n t }
 |	 t k rx|
 t k rxt d |  j d |  j ƒ } qÌt |  j d |	 d |
 d |  j ƒ} n- t  | ƒ } |  j | j k rÌt d ƒ ‚ n  |  | | ˆ  | f S(   s‡  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, None}
        initial guess to iterative method
    b : array_like
        right hand side
    xtype : {'f', 'd', 'F', 'D', None}, optional
        dtype of the x vector

    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)

    i    i   s(   expected square matrix, but got shape=%ss$   A and b have incompatible dimensionsR   R   c         ` s.   t  ˆ  t ƒ r t |  ƒ }  n  |  j ˆ  j ƒ S(   N(   t
   isinstanceR   R   t   reshapet   shape(   R   (   t   b(    s?   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/linalg/isolve/utils.pyt   postprocessS   s    t   dtypesT   Use of xtype argument is deprecated. Use LinearOperator( ... , dtype=xtype) instead.s#   xtype must be 'f', 'd', 'F', or 'D's$   A and x have incompatible dimensionst   psolvet   rpsolveR   t   matvect   rmatvecs/   matrix and preconditioner have different shapesN(   R
   R   t
   ValueErrorR   R   t   chart   astypet   Nonet   hasattrR   R   R   t   DeprecationWarningR   t   ravelR	   R   R   R   R   R   R   (   t   At   Mt   x0R   t   xtypet   A_t   NR   R   R   R   (    (   R   s?   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/linalg/isolve/utils.pyt   make_system"   sZ    !''N(   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   (   t
   __future__R    R   R   t   __docformat__t   __all__t   warningsR   t   numpyR   R   R   R   R   R	   t   scipy.sparse.linalg.interfaceR
   R   R   R   R   R   R$   R.   (    (    (    s?   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/linalg/isolve/utils.pyt   <module>   s   .
		