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

Jed Brown jed at 59A2.org
Wed Oct 28 11:39:44 CDT 2009


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 --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 261 bytes
Desc: OpenPGP digital signature
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20091028/7fc4c901/attachment.pgp>


More information about the petsc-users mailing list