'Check that QMR works with left and right preconditioners'

def test_leftright_precond(self):

    from scipy.sparse.linalg.dsolve import splu
    from scipy.sparse.linalg.interface import LinearOperator
    n = 100
    dat = ones(n)
    A = spdiags([((-2) * dat), (4 * dat), (- dat)], [(-1), 0, 1], n, n)
    b = arange(n, dtype='d')
    L = spdiags([((- dat) / 2), dat], [(-1), 0], n, n)
    U = spdiags([(4 * dat), (- dat)], [0, 1], n, n)
    with suppress_warnings() as sup:
        sup.filter(SparseEfficiencyWarning, 'splu    requires    CSC    matrix    format')
        L_solver = splu(L)
        U_solver = splu(U)
    def L_solve(b):
        return L_solver.solve(b)
    def U_solve(b):
        return U_solver.solve(b)
    def LT_solve(b):
        return L_solver.solve(b, 'T')
    def UT_solve(b):
        return U_solver.solve(b, 'T')
    M1 = LinearOperator((n, n), matvec=L_solve, rmatvec=LT_solve)
    M2 = LinearOperator((n, n), matvec=U_solve, rmatvec=UT_solve)
    (x, info) = qmr(A, b, tol=1e-08, maxiter=15, M1=M1, M2=M2)
    assert_equal(info, 0)
    assert_normclose((A * x), b, tol=1e-08)
