# matrix free for linear solver

Matthew Knepley knepley at gmail.com
Mon Mar 3 12:22:25 CST 2008

```On Mon, Mar 3, 2008 at 12:16 PM, li pan <li76pan at yahoo.com> wrote:
> hi Matt,
>  I used to discuss with somebody about SNES for
>  nonlinear equation. One can use -snes_mf_operator for
>  matrix free calculation. As far as I know, SNES uses a
>  Newton-Kryplov Method. In each Newton, one has to
>  solve a linear equation, which is :
>  residual = Jacobian * delt_u
>  If I can solve the linear equation in a iterative way
>  in Kryplov space, then I only need to optimise
>  Jacobian*delt_u - residual
>  The matrix vector multiplication can be expressed
>  through the gradient calculation for residual. That's
>  why we can forget the Jacobian matrix. The method is
>  generally called Jacobian free Newton Kryplov mehtod
>  (JFNK). You must know it.
>  Actually, that's the way snes works with -snes_mf.
>  Here, we define the function SNESSetFunction(). And as
>  argument, we give the calculation of residual.
>  I wrote so much only because of the continuity of the
>  context.
>  Now my question is, if the SNES method includes a JFNK
>  method to solve the linear equation, why can't I use
>  it for my linear equation directly? And how?

The "matrix-free" you refer to above uses a finite difference
approximation to the Jacobian of a nonlinear function. If you
have a linear equation, the Jacobian is THE EQUATION ITSELF.
Thus, what you propose makes no sense to me at all. Again,
I recommend you look at MATSHELL since I think this is what
you want.

Matt

>  thanx
>
>  pan
>
>
>  --- Matthew Knepley <knepley at gmail.com> wrote:
>
>  > On Mon, Mar 3, 2008 at 11:05 AM, li pan
>  > <li76pan at yahoo.com> wrote:
>  > > Dear all,
>  > >  If I want to solve a linear equation in matrix
>  > free
>  > >  scheme, how is the command line argument? I only
>  > know
>  > >  for nonlinear solver it is _snes_mf
>  >
>  > What do you mean here? How do you have linear
>  > equations without
>  > a matrix? If you mean that you would only like to
>  > specify the action
>  > of the operator, you should use MATSHELL.
>  >
>  >   Matt
>  >
>  > >  thanx
>  > >
>  > >  pan
>  > >
>  > >
>  > >
>  > >
>  >
>  ____________________________________________________________________________________
>  > >  Looking for last minute shopping deals?
>  > >  Find them fast with Yahoo! Search.
>  >
>  http://tools.search.yahoo.com/newsearch/category.php?category=shopping
>  > >
>  > >
>  >
>  >
>  >
>  > --
>  > What most experimenters take for granted before they
>  > begin their
>  > experiments is infinitely more interesting than any
>  > results to which
>  > -- Norbert Wiener
>  >
>  >
>
>
>
>
>       ____________________________________________________________________________________
>  http://www.yahoo.com/r/hs
>
>

--
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which