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

abhyshr at mcs.anl.gov abhyshr at mcs.anl.gov
Thu Oct 29 11:53:07 CDT 2009


Jed is right.MatGetRow will be efficient than MatGetColumnVector.Don't know about MatAXPY() though.From the description it looks like it does Matrix + scalar*Matrix operation.

Shri

----- Original Message -----
From: "Matthew Knepley" <knepley at gmail.com>
To: "PETSc users list" <petsc-users at mcs.anl.gov>
Sent: Wednesday, October 28, 2009 12:46:13 PM GMT -06:00 US/Canada Central
Subject: Re: Does PETSc have some functions like A.*B, A./B in Matlab?

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 


More information about the petsc-users mailing list