[petsc-users] MatSetValues vs. MatSetValue
Barry Smith
bsmith at mcs.anl.gov
Mon Nov 4 11:21:08 CST 2013
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
More information about the petsc-users
mailing list