[petsc-users] Another question about MatAXPY

Barry Smith bsmith at mcs.anl.gov
Mon Jun 29 12:58:38 CDT 2015

> On Jun 29, 2015, at 10:49 AM, Michael Povolotskyi <mpovolot at purdue.edu> wrote:
> Dear developers,
> I have the following question:
> Imagine that I have two matrices A and B
> Both are created using MatCreateSeqAIJ(MPI_Comm comm,PetscInt m,PetscInt n,PetscInt nz,const PetscInt nnz[],Mat *A)
> with the same first 5 arguments.
> In addition, for both matrices I call
> After this I set some entries to both A and B matrices and assemble them.
> Question: can I use MatAXPY with SAME_NONZERO_PATTERN argument?

   Only if you KNOW that they have the exact same nonzero pattern. The MatAssembly "squeezes" out any "extra" space that was preallocated but was not actually used when calling MatSetValues() so even if two matrices have the same preallocation it doesn't mean they have the same nonzero pattern.


> Thank you,
> Michael.
> -- 
> Michael Povolotskyi, PhD
> Research Assistant Professor
> Network for Computational Nanotechnology
> Hall for Discover and Learning Research, Room 441
> West Lafayette, IN 47907
> Phone (765) 4949396

More information about the petsc-users mailing list