ó
î&]\c           @` s  d  d l  m Z m Z m Z d Z g  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 „  Z d S(   i    (   t   divisiont   print_functiont   absolute_imports   restructuredtext en(   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?   lib/python2.7/site-packages/scipy/sparse/linalg/isolve/utils.pyt   coerce   s
    		c         C` s   |  S(   N(    (   R   (    (    s?   lib/python2.7/site-packages/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 †  } t |  d ƒ rå |  j j } n |  j ˆ  ƒ j j } t	 | ˆ  j j ƒ } t
 ˆ  d | ƒ‰  ˆ  j ƒ  ‰  | d k rNt | d | ƒ} nT t | d | ƒ} | j | d f k p„| j | f k s–t d	 ƒ ‚ n  | j ƒ  } | d k rMt | d
 ƒ rÉ| j }	 n t }	 t | d ƒ rê| j }
 n t }
 |	 t k r&|
 t k r&t d |  j d |  j ƒ } qzt |  j d |	 d |
 d |  j ƒ} n- t  | ƒ } |  j | j k rzt d ƒ ‚ n  |  | | ˆ  | f S(   s8  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

    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?   lib/python2.7/site-packages/scipy/sparse/linalg/isolve/utils.pyt   postprocessP   s    t   dtypes$   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   hasattrR   R   R   t   ravelt   NoneR   R   R   R   R   R   R
   (   t   At   Mt   x0R   t   A_t   NR   t   xtypeR   R   R   (    (   R   s?   lib/python2.7/site-packages/scipy/sparse/linalg/isolve/utils.pyt   make_system!   sL    ''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   numpyR   R   R   R   R   R   t   scipy.sparse.linalg.interfaceR	   R
   R   R   R   R   R,   (    (    (    s?   lib/python2.7/site-packages/scipy/sparse/linalg/isolve/utils.pyt   <module>   s   .
		