Luke is right that your best hope for a robust preconditioner is to
manually construct a geometric multigrid type hierarchy where the
matrix is implicitly defined at each level by a LinearOperator.
However, if you simply want to precondition fGMRES with GMRES, then
you'll have to construct a LinearOperator whose mat-vec routine is
defined by the action of GMRES. You'll then pass this new
LinearOperator in as the parameter M to fGMRES. Since it's somewhat
tricky, here's a code snippet showing exactly how to define such an M.
--------------------------------------------------------------------
--------------------------------------------------------------------
##
# Define your own matrix A and right-hand-side b
##
##
# GMRES parameters
zz = numpy.zeros_like(b)
gmres_tol = scipy.finfo(A.dtype).tiny
##
# Define GMRES precondtioner as a Linear Operator
# --> maxiter for GMRES will likely need to be tuned. I use
# maxiter=10 below as only a guess
def precon_matvec(x):
# Basically, GMRES approximates inverse(A) with a polynomial
# P(A) so that x = x0 + P(A)*r, where r is the residual. Thus in the
# call to GMRES, x0 is a zero vector and the right-hand-side is x.
return pyamg.krylov.gmres(A, x, x0=zz, tol=gmres_tol, maxiter=10)[0]
#
M=scipy.sparse.linalg.interface.LinearOperator(A.shape,precon_matvec)
##
# Now call fGMRES with the above M
##
--------------------------------------------------------------------
--------------------------------------------------------------------
Hope this helps,
Jacob
> --
> You received this message because you are subscribed to the Google Groups "pyamg-user" group.
> To post to this group, send email to pyamg...@googlegroups.com.
> To unsubscribe from this group, send email to pyamg-user+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/pyamg-user?hl=en.
>
>