[petsc-users] Does PETSc have some functions like A.*B, A./B in Matlab?

Yujie recrusader at gmail.com
Sun Feb 21 14:19:48 CST 2010


It is not only for A./B. If one wants to do A.*B, it is not necessary to
guarantee the nonzeros of B. Generally, I think MatGetValues() will be good
choice although you need to judge whether the entries are zero when doing
A./B.

Yujie

On Sun, Feb 21, 2010 at 2:17 PM, Jed Brown <jed at 59a2.org> wrote:

> On Sun, 21 Feb 2010 13:48:09 -0600, Yujie <recrusader at gmail.com> wrote:
> > 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.
>
> Of course, but note that B must have at least all the nonzeros of A,
> otherwise you divide by 0.  If you really need to do A./B where A was
> not preallocated to match B (it is a strict subset), then MatDuplicate B
> (call it C), loop over rows inserting rows of A into C, then perform the
> division with MatGetArray B and C (you'll have to work with the
> off-diagonal blocks separately in parallel).
>
> But you would be *much* better off to find a way to assemble the matrix
> you want rather than these other matrices with inequivalent nonzero
> patterns.
>
> Jed
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20100221/a8af5952/attachment.htm>


More information about the petsc-users mailing list