[petsc-users] MatAYPX for dense and sparse matrices

Alexander Grayver agrayver at gfz-potsdam.de
Mon Mar 21 06:31:27 CDT 2011


On 21.03.2011 12:24, Jed Brown wrote:
> On Mon, Mar 21, 2011 at 12:14, Alexander Grayver 
> <agrayver at gfz-potsdam.de <mailto:agrayver at gfz-potsdam.de>> wrote:
>
>     I have two matrices L and J. L is the sparse with 2 nonzeros per
>     row maximum (quite often there are no values in a row at all) and
>     J is the dense matrix. I need to add matrix L to matrix J so that:
>
>     J = J + L
>
>     I try to use:
>     call MatAYPX(J,one,L,SUBSET_NONZERO_PATTERN,ierr)
>
>
> The dispatch for this is not set up for matrices of different type. 
> From C, you can
>
> #include <private/matimpl.h> /* declaration of MatAXPY_Basic */
> MatAXPY_Basic(J,1.0,L,SUBSET_NONZERO_PATTERN);
>
> There is not a Fortran binding for this function, but you could write 
> the wrapper (basically just copy from src/mat/utils/ftn-auto/axpyf.c).
Would I have to rebuild PETSc from scratch to make this wrapper working?

> Alternatively, the code for this is really simple, just iterate 
> through the rows of L and insert them into J.
Do you mean using MatGetOwnershipRange+MatGetSubMatrices+MatGetRow?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20110321/dafb1251/attachment.htm>


More information about the petsc-users mailing list