On Sep 27, 2010, at 11:30 AM, Jed Brown wrote:

> On Mon, Sep 27, 2010 at 18:24, Barry Smith <bsmith at mcs.anl.gov> wrote:
>> 
>>  We need an efficient MatAXPY() that works well for any combination of 
>> nonzero patterns. This is not terribly difficult to write.  Basically for 
>> each row create a linked list of the nonzeros in it from the first matrix 
>> and then merge in the nonzeros from the second matrix for that row, much 
>> like in the LU symbolic factorizations. This will give you row counts, then 
>> preallocate the correct nonzero matrix and do the MatSetValues() for the 
>> first matrix first row then the second matrix first row etc. Finally swap in 
>> the new matrix body into the current matrix.
> 
> I don't see why you'd need a linked list for this, you have two sorted
> arrays (one for each row) and just need to count the number of unique
> elements.  It's one loop.

   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. 


   Barry

> 
> Jed

Reply via email to