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

Shri abhyshr at mcs.anl.gov
Wed Sep 29 13:39:08 CDT 2010


Boyce,
      I've added the MPIAIJ version of MatAXPY to petsc-dev which does the preallocation before doing the addition. Please test it with your code and report any problems if you have.

Thanks,
Shri

----- Shri <abhyshr at mcs.anl.gov> wrote:
> 
> ----- Boyce Griffith <griffith at cims.nyu.edu> 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. 
>   My apologies,the above code snippet is incorrect. Jed has already pushed a fix for this and i'm working on it too. Sorry about the confusion.
> 
> Shri
>  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?
> > 
> > -- Boyce
> 




More information about the petsc-dev mailing list