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

Boyce Griffith griffith at cims.nyu.edu
Mon Sep 27 16:37:35 CDT 2010



On 9/27/10 5:36 PM, Boyce Griffith wrote:
>
>
> On 9/27/10 5:28 PM, Shri wrote:
>> Barry,
>> I've modified MatAXPY_SeqAIJ as follows when
>> DIFFERENT_NONZERO_STRUCTURE flag is true (i) create a new matrix and
>> do preallocation for it. For determining the number of nonzeros per
>> row in the new matrix, i've used the number of nonzeros in the
>> original two matrices. This is the piece of code which computes the
>> nnz per row in the new matrix
>> for(i = 0;i< m;i++) {
>> nzx = xi[i+1] - xi[i]; nzy = yi[i+1] - yi[i];
>> if (nzx> nzy) nnz[i] = nzy + (nzx - nzy);
>> else nnz[i] = nzx + (nzy - nzx);
>> }
>
> I don't understand why this is the right thing to do. It seems like this
> either sets nnz in the new matrix to be nzx or nzy, whichever is
> smaller. Am I misreading this code snippet?

Errr, and by smaller, I mean bigger.

>
> -- Boyce
>



More information about the petsc-dev mailing list