[petsc-dev] [petsc-users] matrix-matrix addition

Boyce Griffith griffith at cims.nyu.edu
Mon Sep 27 14:00:24 CDT 2010


Hi, Barry et al. --

I'm moving this over to petsc-dev, since that seems like the more 
appropriate place.

I'm attaching my stab at implementing MatAXPY for pairs of sequantial 
AIJ matrices.  I've done only very minimal testing, but it appears to 
work for my application.

In the implementation, I create a new matrix W to store the result of 
computing a*X+Y.  Instead of swapping out the innards of W and Y, my 
implementation "returns" the newly allocated matrix W.  (I didn't see a 
function to swap out matrices.  Is there one that could be used here?)

-- Boyce

On 9/27/10 1:06 PM, Barry Smith wrote:
>
> On Sep 27, 2010, at 12:04 PM, Jed Brown wrote:
>
>> On Mon, Sep 27, 2010 at 19:01, Barry Smith<bsmith at mcs.anl.gov>  wrote:
>>> If you do not merge the column indices from A and B but simply count them all you will get over allocation, at worst a factor of two, though usually it would just be a little.
>>
>> You count the number of *unique* entries.  You have two indices that
>> run through the arrays aj and bj, counting duplicates only once.  This
>> is easy to do since they are both sorted.
>
>     Yes, sounds like it could work and definitely better than my suggestion.
>
>    Shri, can you try this?
>
>     Barry
>
>>
>> Jed
>
>
>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: MatAXPY_SeqAIJ.c
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20100927/f0bb0be9/attachment.c>


More information about the petsc-dev mailing list