def aslinearoperator(A):
if isinstance(A, LinearOperator):<EOL><INDENT>return A<EOL><DEDENT>elif isinstance(A, np.ndarray) or isinstance(A, np.matrix):<EOL><INDENT>if A.ndim > <NUM_LIT:2>:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>A = np.atleast_2d(np.asarray(A))<EOL>return MatrixLinearOperator(A)<EOL><DEDENT>elif isspmatrix(A):<EOL><INDENT>return MatrixLinearOperator(A)<EOL><DEDENT>else:<EOL><INDENT>if hasattr(A, '<STR_LIT>') and hasattr(A, '<STR_LIT>'):<EOL><INDENT>rmatvec = None<EOL>dtype = None<EOL>if hasattr(A, '<STR_LIT>'):<EOL><INDENT>rmatvec = A.rmatvec<EOL><DEDENT>if hasattr(A, '<STR_LIT>'):<EOL><INDENT>dtype = A.dtype<EOL><DEDENT>return LinearOperator(A.shape, A.matvec,<EOL>rmatvec=rmatvec, dtype=dtype)<EOL><DEDENT>else:<EOL><INDENT>raise TypeError('<STR_LIT>')<EOL><DEDENT><DEDENT>
Return A as a LinearOperator.

    'A' may be any of the following types:
     - ndarray
     - matrix
     - sparse matrix (e.g. csr_matrix, lil_matrix, etc.)
     - LinearOperator
     - An object with .shape and .matvec attributes

    See the LinearOperator documentation for additional information.

    Examples
    --------
    >>> from scipy import matrix
    >>> M = matrix( [[1,2,3],[4,5,6]], dtype='int32' )
    >>> aslinearoperator( M )
    <2x3 LinearOperator with dtype=int32>