I was always wondering how difficult it would be to define a constant say, ZERO_DROP_TOLERANCE so that when the matrix is setup, MatAssemblyBegin()/End(), it automatically ignores the values below this threshold? <div>I understand the for the matrices that might change in successive iterations, that might not be a good idea since the memory reallocation could be very slow, but for a lot of cases which a constant matrix, that could be simply helpful. </div>
<div><br></div><div>Best, </div><div>Mohamad</div><div><br><div><br><div><br></div><div><br><br><div class="gmail_quote">On Thu, Dec 1, 2011 at 5:00 PM, Barry Smith <span dir="ltr"><<a href="mailto:bsmith@mcs.anl.gov">bsmith@mcs.anl.gov</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="HOEnZb"><div class="h5"><br>
On Dec 1, 2011, at 6:44 PM, Xiangdong Liang wrote:<br>
<br>
> Hello everyone,<br>
><br>
> I have a question about whether zeros will change the sparse pattern.<br>
> Suppose I am generating two sparse matrices A and B. A is generated<br>
> with exactly number of nonzeros, say 10 nnz per row. When I generate<br>
> matrix B, I specify 12 nonzeros, but two of them are given zero values<br>
> by MatSetValue. Will A and B have same sparsity patterns and<br>
> performance ? In other words, will PETSc simply ignore these zeros<br>
> entries? I output these A and B in matlab, and it seems that these<br>
> zeros entries are ignored. I just want to double check on this.<br>
><br>
> Is the option MAT_IGNORE_ZERO_ENTRIES on by default?<br>
<br>
</div></div> No, by default PETSc will insert the zero values thus increasing the nonzero pattern. If you set that option to the matrix then inserting values it will not introduce an increase in the pattern.<br>
<br>
<br>
BTW: if you then load the matrix via a binary file to MATLAB it may be that MATLAB silently removes those locations so you don't see them.<br>
Barry<br>
<br>
> Thanks.<br>
><br>
> Best,<br>
> Xiangdong<br>
<br>
</blockquote></div><br></div></div></div>