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"><<a href="mailto:jed@59a2.org">jed@59a2.org</a>></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>
> If A and B are vectors, then you can use VecPointwiseMult for A.*B and VecPointwiseDivide for A./B.<br>
> For matrices,pointwise multiplication and division functions are not provided in Petsc. One possible way to do<br>
> 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>
> 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>
><br>
> Shri<br>
><br>
> ----- Original Message -----<br>
> From: "Yujie" <<a href="mailto:recrusader@gmail.com">recrusader@gmail.com</a>><br>
> To: "PETSc users list" <<a href="mailto:petsc-users@mcs.anl.gov">petsc-users@mcs.anl.gov</a>><br>
> Sent: Wednesday, October 28, 2009 10:21:34 AM GMT -06:00 US/Canada Central<br>
> Subject: Does PETSc have some functions like A.*B, A./B in Matlab?<br>
><br>
> Dear PETSc Developers,<br>
><br>
> Does PETSc provide some functions, like A.*B, A./B in Matlab? Thanks a lot.<br>
><br>
> Regards,<br>
> Yujie<br>
<br>
<br>
</div></div></blockquote></div><br>