Thanks for all your clarification!
 
Qin


On Monday, November 4, 2013 11:21 AM, Barry Smith <[email protected]> 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 <[email protected]> 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

Reply via email to