Does PETSc have some functions like A.*B, A./B in Matlab?

Matthew Knepley knepley at gmail.com
Wed Oct 28 12:46:13 CDT 2009


There is MatAXPY().

  Matt

On Wed, Oct 28, 2009 at 11: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
>
>
>


-- 
What most experimenters take for granted before they begin their experiments
is infinitely more interesting than any results to which their experiments
lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20091028/c15952f1/attachment.htm>


More information about the petsc-users mailing list