def get_preconditioner():
 diags_x = zeros((3, nx))
 diags_x[0, :] = ((1 / hx) / hx)
 diags_x[1, :] = (((-2) / hx) / hx)
 diags_x[2, :] = ((1 / hx) / hx)
 Lx = spdiags(diags_x, [(-1), 0, 1], nx, nx)
 diags_y = zeros((3, ny))
 diags_y[0, :] = ((1 / hy) / hy)
 diags_y[1, :] = (((-2) / hy) / hy)
 diags_y[2, :] = ((1 / hy) / hy)
 Ly = spdiags(diags_y, [(-1), 0, 1], ny, ny)
 J1 = (kron(Lx, eye(ny)) + kron(eye(nx), Ly))
 J1_ilu = spilu(J1)
 M = LinearOperator(shape=((nx * ny), (nx * ny)), matvec=J1_ilu.solve)
 return M

def get_preconditioner ( ) : diags_x = zeros ( ( 3 , nx ) ) diags_x [ 0 , : ] = ( ( 1 / hx ) / hx ) diags_x [ 1 , : ] = ( ( ( - 2 ) / hx ) / hx ) diags_x [ 2 , : ] = ( ( 1 / hx ) / hx ) Lx = spdiags ( diags_x , [ ( - 1 ) , 0 , 1 ] , nx , nx ) diags_y = zeros ( ( 3 , ny ) ) diags_y [ 0 , : ] = ( ( 1 / hy ) / hy ) diags_y [ 1 , : ] = ( ( ( - 2 ) / hy ) / hy ) diags_y [ 2 , : ] = ( ( 1 / hy ) / hy ) Ly = spdiags ( diags_y , [ ( - 1 ) , 0 , 1 ] , ny , ny ) J1 = ( kron ( Lx , eye ( ny ) ) + kron ( eye ( nx ) , Ly ) ) J1_ilu = spilu ( J1 ) M = LinearOperator ( shape = ( ( nx * ny ) , ( nx * ny ) ) , matvec = J1_ilu . solve ) return M
compute the preconditioner m .