Hello,<br><br>I&#39;m a bit confused regarding the efficiency of 
MatSetValues in Petsc and I was hoping for some help. I&#39;m using Petsc 
3.2-p6 on Fedora11.<br><br>I&#39;m attaching a simple code that displays the time needed for some simple cases using MatSetValues.<br>
<br>1st case: The matrix is composed by copying a different matrix and 
then MatSetValues is used to insert elements at the same nonzero pattern
 (diagonal) as the initial matrix (with defining the number of nonzeros 
per row).<br>
<br>2nd case: The matrix is composed by copying a different matrix and then 
MatSetValues is used to insert elements at a different nonzero pattern than 
the initial matrix (diagonal-1st off diagonal) (with defining the number of nonzeros per row).<br><br>3rd case: Same as 2nd but without defining the number of nonzeros per row.<br><br>It
 seems that only the 1st case gives good results in the sense that by 
increasing the size of the matrix you increase the time needed by 
MatSetValues linearly. Both the 2nd and the 3rd case give similar 
results, much worse than the 1st. I understand that the 1st case has the
 advantage because of accurate memory allocation but shouldn&#39;t the 
2ndcase be better than the 3rd since it at least defines the number of 
nonzeros per row so it again allocates memory more accurately?<br>
<br><br>Many thanks for any help,<br><br>Margarita<br><br>///////////////////////////////////////////////////////<br><div id=":2q">DPhil candidate<br>University of Oxford</div>