def make_system(A, M, x0, b, xtype=None):
A_ = A<EOL>A = aslinearoperator(A)<EOL>if A.shape[<NUM_LIT:0>] != A.shape[<NUM_LIT:1>]:<EOL><INDENT>raise ValueError('<STR_LIT>' % (A.shape,))<EOL><DEDENT>N = A.shape[<NUM_LIT:0>]<EOL>b = asanyarray(b)<EOL>if not (b.shape == (N,<NUM_LIT:1>) or b.shape == (N,)):<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>if b.dtype.char not in '<STR_LIT>':<EOL><INDENT>b = b.astype('<STR_LIT:d>')  <EOL><DEDENT>def postprocess(x):<EOL><INDENT>if isinstance(b,matrix):<EOL><INDENT>x = asmatrix(x)<EOL><DEDENT>return x.reshape(b.shape)<EOL><DEDENT>if xtype is None:<EOL><INDENT>if hasattr(A,'<STR_LIT>'):<EOL><INDENT>xtype = A.dtype.char<EOL><DEDENT>else:<EOL><INDENT>xtype = A.matvec(b).dtype.char<EOL><DEDENT>xtype = coerce(xtype, b.dtype.char)<EOL><DEDENT>else:<EOL><INDENT>warn('<STR_LIT>'<EOL>'<STR_LIT>',<EOL>DeprecationWarning)<EOL>if xtype == <NUM_LIT:0>:<EOL><INDENT>xtype = b.dtype.char<EOL><DEDENT>else:<EOL><INDENT>if xtype not in '<STR_LIT>':<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT><DEDENT><DEDENT>b = asarray(b,dtype=xtype)  <EOL>b = b.ravel()<EOL>if x0 is None:<EOL><INDENT>x = zeros(N, dtype=xtype)<EOL><DEDENT>else:<EOL><INDENT>x = array(x0, dtype=xtype)<EOL>if not (x.shape == (N,<NUM_LIT:1>) or x.shape == (N,)):<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>x = x.ravel()<EOL><DEDENT>if M is None:<EOL><INDENT>if hasattr(A_,'<STR_LIT>'):<EOL><INDENT>psolve = A_.psolve<EOL><DEDENT>else:<EOL><INDENT>psolve = id<EOL><DEDENT>if hasattr(A_,'<STR_LIT>'):<EOL><INDENT>rpsolve = A_.rpsolve<EOL><DEDENT>else:<EOL><INDENT>rpsolve = id<EOL><DEDENT>if psolve is id and rpsolve is id:<EOL><INDENT>M = IdentityOperator(shape=A.shape, dtype=A.dtype)<EOL><DEDENT>else:<EOL><INDENT>M = LinearOperator(A.shape, matvec=psolve, rmatvec=rpsolve,<EOL>dtype=A.dtype)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>M = aslinearoperator(M)<EOL>if A.shape != M.shape:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT><DEDENT>return A, M, x, b, postprocess<EOL>
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}
        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)