On Thu, Apr 7, 2011 at 8:04 AM, Bartłomiej W <span dir="ltr">&lt;<a href="mailto:bartlomiej.wach@yahoo.pl">bartlomiej.wach@yahoo.pl</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<table cellspacing="0" cellpadding="0" border="0"><tbody><tr><td valign="top" style="font:inherit">Hello,<br><br>Wheather I use<br><br>  ierr = MatCreate(PETSC_COMM_WORLD,&amp;L);CHKERRQ(ierr);<br>  ierr = MatSetSizes(L,PETSC_DECIDE,PETSC_DECIDE,n,n);CHKERRQ(ierr);<br>
             MatSeqAIJSetPreallocation(L,PETSC_NULL,nnz);<br>  ierr = MatSetFromOptions(L);CHKERRQ(ierr);<br></td></tr></tbody></table></blockquote><div><br></div><div>Move SetPreallocation() after SetFromOptions(). Here is what happens:</div>
<div><br></div><div>  SetFromOptions() will give the matrix a type, since it does not have one already</div><div><br></div><div>  Since the matrix had no type before SetPreallocation(), the call was ignored</div><div><br>
</div><div>     Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><table cellspacing="0" cellpadding="0" border="0"><tbody><tr><td valign="top" style="font:inherit">
or<br><br>  <br>  ierr = MatCreateSeqAIJ(PETSC_COMM_WORLD,n,n,PETSC_DEFAULT,nnz,&amp;L);CHKERRQ(ierr);<br>  ierr = MatSetFromOptions(L);CHKERRQ(ierr);<br> <br>Gives me <br><br>   Number of mallocs during MatSetValues() is  X <br>
<br>On matrix assembly, where X is positive<br>Is this indicating the preallocation or should it be zero and I&#39;m missing something?<br><br>Moreover, using MatCreateSeqAIJ lowers the performance of MatSetValues<br><br>
Is my code
 improper?<br><br>Regards <br>Bartłomiej Wach<br></td></tr></tbody></table></blockquote></div><br><br clear="all"><br>-- <br>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
-- Norbert Wiener<br>