[petsc-users] MatSetValues vs. MatSetValue
Qin Lu
lu_qin_2000 at yahoo.com
Mon Nov 4 16:04:08 CST 2013
Thanks for all your clarification!
Qin
On Monday, November 4, 2013 11:21 AM, Barry Smith <bsmith at mcs.anl.gov> wrote:
Normally one does not “generate” a single matrix entry at a time. For example with finite elements one generates an element stiffness which is a small dense block of values that need to be added to the global stiffness matrix. With finite differences one generates a row of the matrix entries at the time.
One should then call MatSetValues() to set this collection of entries that have been computed together. Since you have all this collection it would be silly to call MatSetValue() on each.
If, for some nonstandard uncommon situation one truly generates one matrix entry at a time then it would be fine to call MatSetValue() with that one entry.
Barry
On Nov 4, 2013, at 9:01 AM, Qin Lu <lu_qin_2000 at yahoo.com> wrote:
> Hello,
>
> I need to set values of a sparse matrix. Is setting coefficients row by row using MatSetValues more efficient than setting setting coefficient one by one using MatSetValue? Is MatSetValues implemented by looping over each entry of the input array calling MatSetValue?
>
> Thanks a lot for your help,
> Qin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20131104/4c1bd637/attachment-0001.html>
More information about the petsc-users
mailing list