On Wed, Jun 15, 2011 at 5:35 PM, Alexander Grayver <span dir="ltr">&lt;<a href="mailto:agrayver@gfz-potsdam.de">agrayver@gfz-potsdam.de</a>&gt;</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&#39;m going to use this product as a part
of the following expressions:<br><br>v&#39;*A&#39;*A*v<br>A&#39;*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, &amp;prod)             prod = v&#39; A&#39; A v</div>
<div>  MatMultTranspose(A, w, y)   y = A&#39; 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 &lt;jed@59A2.org&gt;
wrote:<br>&gt; On Wed, Jun 15, 2011 at 18:54, Alexander Grayver <br>&gt;&lt;<a href="mailto:agrayver@gfz-potsdam.de" target="_blank">agrayver@gfz-potsdam.de</a>&gt;wrote:<br>&gt; <br>&gt;&gt; I&#39;ve got simple
question.<br>&gt;&gt; What is the most efficient way to compute B = A&#39;*A using <br>&gt;&gt;petsc?<br>&gt;&gt; Matrix A is sparse
MPIAIJ.<br>&gt;&gt;<br>&gt; <br>&gt; What are you going to do with B = A&#39;*A?<br>&gt; <br>&gt; The most efficient thing is MatCreateTranspose() which
<br>&gt;does no computation.<br>&gt; <br>&gt; <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>
&gt;
<br>&gt; <br>&gt; If you need B assembled, then create a diagonal matrix <br>&gt;and use MatPtAP()<br>&gt; <br>&gt;
<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>