Hi, Jeb 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.
Regards, Yujie On Wed, Oct 28, 2009 at 10:39 AM, Jed Brown <jed at 59a2.org> wrote: > abhyshr at mcs.anl.gov wrote: > > If A and B are vectors, then you can use VecPointwiseMult for A.*B and > VecPointwiseDivide for A./B. > > For matrices,pointwise multiplication and division functions are not > provided in Petsc. One possible way to do > > 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 > > and then call VecPointwiseMult/VecPointwiseDivide. > > This would be very inefficient because it produces dense output and > PETSc matrices are row-aligned. I would suggest using MatGetRow which > is much faster and preserves sparsity. > > Jed > > > > > Shri > > > > ----- Original Message ----- > > From: "Yujie" <recrusader at gmail.com> > > To: "PETSc users list" <petsc-users at mcs.anl.gov> > > Sent: Wednesday, October 28, 2009 10:21:34 AM GMT -06:00 US/Canada > Central > > Subject: Does PETSc have some functions like A.*B, A./B in Matlab? > > > > Dear PETSc Developers, > > > > Does PETSc provide some functions, like A.*B, A./B in Matlab? Thanks a > lot. > > > > Regards, > > Yujie > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20100221/ec184c10/attachment.htm>
