[petsc-users] Efficient computation of A'*A

Matthew Knepley knepley at gmail.com
Wed Jun 15 12:46:06 CDT 2011


On Wed, Jun 15, 2011 at 5:35 PM, Alexander Grayver
<agrayver at gfz-potsdam.de>wrote:

> Thanks Jed,
>
> Actually, I'm going to use this product as a part of the following
> expressions:
>
> v'*A'*A*v
> A'*A*v
>
> I need it many times with different v, but constant A.
>
> MatPtAP with unit matrix seems to be ok, I guess.
>

No, you do not need that at all for the above. Use

  MatMult(A, v, w)
  VecDot(w, w, &prod)             prod = v' A' A v
  MatMultTranspose(A, w, y)   y = A' A v

     Matt

Regards,
> Alexander
>
>
> On Wed, 15 Jun 2011 19:00:15 +0200
>  Jed Brown <jed at 59A2.org> wrote:
> > On Wed, Jun 15, 2011 at 18:54, Alexander Grayver
> ><agrayver at gfz-potsdam.de>wrote:
> >
> >> I've got simple question.
> >> What is the most efficient way to compute B = A'*A using
> >>petsc?
> >> Matrix A is sparse MPIAIJ.
> >>
> >
> > What are you going to do with B = A'*A?
> >
> > The most efficient thing is MatCreateTranspose() which
> >does no computation.
> >
> >
> http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-current/docs/manualpages/Mat/MatCreateTranspose.html
> >
> >
> > If you need B assembled, then create a diagonal matrix
> >and use MatPtAP()
> >
> >
> http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-current/docs/manualpages/Mat/MatPtAP.html
>
>


-- 
What most experimenters take for granted before they begin their experiments
is infinitely more interesting than any results to which their experiments
lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20110615/5bf6ad96/attachment.htm>


More information about the petsc-users mailing list