Hi, Jeb<br><br>It looks MatGetRow() only can get the nonzero row values for sparse matrix. It is not suitable for A./B if there are different formats between A and B. Thanks.<br><br>Regards,<br>Yujie<br><br><div class="gmail_quote">
On Wed, Oct 28, 2009 at 10:39 AM, Jed Brown <span dir="ltr">&lt;<a href="mailto:jed@59a2.org">jed@59a2.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im"><a href="mailto:abhyshr@mcs.anl.gov">abhyshr@mcs.anl.gov</a> wrote:<br>
&gt; If A and B are vectors, then you can use VecPointwiseMult for A.*B and VecPointwiseDivide for A./B.<br>
&gt; For matrices,pointwise multiplication and division functions are not provided in Petsc. One possible way to do<br>
&gt; A.*B and A./B for matrices is to loop through the columns of the matrices,call MatGetColumnVector for each column of matrix A,B<br>
&gt; and then call VecPointwiseMult/VecPointwiseDivide.<br>
<br>
</div>This would be very inefficient because it produces dense output and<br>
PETSc matrices are row-aligned.  I would suggest using MatGetRow which<br>
is much faster and preserves sparsity.<br>
<font color="#888888"><br>
Jed<br>
</font><div><div></div><div class="h5"><br>
&gt;<br>
&gt; Shri<br>
&gt;<br>
&gt; ----- Original Message -----<br>
&gt; From: &quot;Yujie&quot; &lt;<a href="mailto:recrusader@gmail.com">recrusader@gmail.com</a>&gt;<br>
&gt; To: &quot;PETSc users list&quot; &lt;<a href="mailto:petsc-users@mcs.anl.gov">petsc-users@mcs.anl.gov</a>&gt;<br>
&gt; Sent: Wednesday, October 28, 2009 10:21:34 AM GMT -06:00 US/Canada Central<br>
&gt; Subject: Does PETSc have some functions like A.*B, A./B in Matlab?<br>
&gt;<br>
&gt; Dear PETSc Developers,<br>
&gt;<br>
&gt; Does PETSc provide some functions, like A.*B, A./B in Matlab? Thanks a lot.<br>
&gt;<br>
&gt; Regards,<br>
&gt; Yujie<br>
<br>
<br>
</div></div></blockquote></div><br>