[petsc-users] Why MatMult(A, x, Ax) != A*x?

Jed Brown jed at 59A2.org
Tue Nov 30 14:52:45 CST 2010


On Tue, Nov 30, 2010 at 21:42, Rongliang Chen <rongliang.chan at gmail.com>wrote:

> I know that I should call PetscViewerDestroy() when I have done with each
> viewer. But if I called this I just can view the last Matrix and vector.
> What I want
> to do is that I let it do three steps of SNES, view the jacobian of each
> step.
>

Maybe view it to different files.  The code you posted for viewing is
certainly not correct, especially if called in a loop.


> I found that A*x is correct at the first step and it's wrong for the second
> and
> third step.
> I also tried using the binary output and input, and it has the same
> results.
>

The problem is most likely that you are picking these pieces out of the
files differently than they are put in.  MatMult being incorrect is by far
the least likely scenario.  I don't know why you want to do this, but you
need to find a way to manage the files so that you can be certain that you
are reading (from Matlab) exactly what you think you are reading.  One way
to do this is to use a binary file that gets all three items together.

Jed
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20101130/d0161a3c/attachment.htm>


More information about the petsc-users mailing list