On Wed, Jun 15, 2011 at 5:35 PM, Alexander Grayver <span dir="ltr"><<a href="mailto:agrayver@gfz-potsdam.de">agrayver@gfz-potsdam.de</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div style="font:10pt arial,helvetica,sans-serif">Thanks Jed,<br><br>Actually, I'm going to use this product as a part
of the following expressions:<br><br>v'*A'*A*v<br>A'*A*v<br><br>I need it many times with different v, but constant A.<br><br>MatPtAP with unit matrix
seems to be ok, I guess.<br></div></blockquote><div><br></div><div>No, you do not need that at all for the above. Use</div><div><br></div><div> MatMult(A, v, w)</div><div> VecDot(w, w, &prod) prod = v' A' A v</div>
<div> MatMultTranspose(A, w, y) y = A' A v</div><div><br></div><div> Matt</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div style="font:10pt arial,helvetica,sans-serif">
Regards,<br>Alexander<br><br><br>On Wed, 15 Jun 2011 19:00:15 +0200<br> Jed Brown <jed@59A2.org>
wrote:<br>> On Wed, Jun 15, 2011 at 18:54, Alexander Grayver <br>><<a href="mailto:agrayver@gfz-potsdam.de" target="_blank">agrayver@gfz-potsdam.de</a>>wrote:<br>> <br>>> I've got simple
question.<br>>> What is the most efficient way to compute B = A'*A using <br>>>petsc?<br>>> Matrix A is sparse
MPIAIJ.<br>>><br>> <br>> What are you going to do with B = A'*A?<br>> <br>> The most efficient thing is MatCreateTranspose() which
<br>>does no computation.<br>> <br>> <a href="http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-current/docs/manualpages/Mat/MatCreateTranspose.html" target="_blank">http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-current/docs/manualpages/Mat/MatCreateTranspose.html</a><br>
>
<br>> <br>> If you need B assembled, then create a diagonal matrix <br>>and use MatPtAP()<br>> <br>>
<a href="http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-current/docs/manualpages/Mat/MatPtAP.html" target="_blank">http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-current/docs/manualpages/Mat/MatPtAP.html</a><br>
<br></div>
</blockquote></div><br><br clear="all"><br>-- <br>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener<br>