[petsc-users] preallocate space for matrices if only the global number of nonzeros is known

Stefano Zampini stefano.zampini at gmail.com
Mon Apr 16 14:03:36 CDT 2018


Yes if you use the SBAIJ format. If you use the AIJ format, you should
provide the nonzeros for the entire row

Il Lun 16 Apr 2018, 21:55 Klaus Burkart <k_burkart at yahoo.com> ha scritto:

> For a symmetric matrix:
>
> I assume, I should compute the number of nonzeros per row just for the
> upper triangle?
>
>
> Am Montag, 16. April 2018, 14:23:19 MESZ hat Jed Brown <jed at jedbrown.org>
> Folgendes geschrieben:
>
>
> Klaus Burkart <k_burkart at yahoo.com> writes:
>
> > Hi,
> > How can I preallocate space for matrices (some symmetric, others
> > asymmetric) if I have the global number of nonzeros (NNZ) but not the
> > number of nonzeros per row?
>
> Unfortunately, this is not enough for efficient assembly.  It is more
> efficient to over-estimate.
>
>
> > I could compute the NNZ for the upper or lower part separately if this
> > would be useful for symmetric matrices.
> >
> > I create the matrix this way:
> >     MatCreate(PETSC_COMM_WORLD, &M);
> >     MatSetSizes(M, PETSC_DECIDE, PETSC_DECIDE, N, N);
> >     MatSetFromOptions(M);
> > Klaus
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20180416/9595e98f/attachment.html>


More information about the petsc-users mailing list