<div class="gmail_quote">2011/5/20 Dürrwang, Jürgen <span dir="ltr"><<a href="mailto:Juergen.Duerrwang@iosb.fraunhofer.de">Juergen.Duerrwang@iosb.fraunhofer.de</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<span lang="EN-US">MatSetValues(A,n,prow,nz,pcol,pval,INSERT_VALUES);</span></blockquote></div><br><div>This function inserts logically dense blocks. You would loop over rows:</div><div><br></div><div>for (row=0; row<n; row++) {</div>
<div> PetscInt ncol = prow[row+1] - prow[row];</div><div> PetscInt offset = prow[row];</div><div> MatSetValues(A,1,&row,ncol,&pcol[offset],&pval[offset],INSERT_VALUES);</div><div>}</div><div><br></div><div>
You should preallocate if at all possible. If your format is exactly as described here and you want the matrix to use your memory, look at:</div><div><br></div><div><a href="http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-dev/docs/manualpages/Mat/MatCreateSeqAIJWithArrays.html">http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-dev/docs/manualpages/Mat/MatCreateSeqAIJWithArrays.html</a></div>