[petsc-users] MatAYPX for dense and sparse matrices

Jed Brown jed at 59A2.org
Mon Mar 21 06:24:51 CDT 2011


On Mon, Mar 21, 2011 at 12:14, Alexander Grayver <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).
Alternatively, the code for this is really simple, just iterate through the
rows of L and insert them into J.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20110321/5d095f48/attachment.htm>


More information about the petsc-users mailing list