[petsc-users] matrix-matrix addition

Jed Brown jed at 59A2.org
Mon Sep 27 11:39:30 CDT 2010


On Mon, Sep 27, 2010 at 18:36, Barry Smith <bsmith at mcs.anl.gov> wrote:
>   You need to merge the two arrays, don't you? I was suggested the linked list to do the merge, but I am sure you are correct there are other better ways to do merges.

Why do you need to actually merge them?  You need to count the number
in the diagonal and off-diagonal part, but then aren't you going to
build a matrix using MatSetValues(...,ADD_VALUES)?  You could of
course merge them in a temporary buffer (trivial as long as it has
been allocated large enough) to get one MatSetValues for the whole
row, instead of one for the row from A and another for the row from B.
 The rows are both sorted, so they can be merged into a buffer in a
single pass.

Jed


More information about the petsc-users mailing list