[petsc-users] zeros in sparse aij

Barry Smith bsmith at mcs.anl.gov
Thu Dec 1 20:59:00 CST 2011


On Dec 1, 2011, at 8:46 PM, Xiangdong Liang wrote:

> Thanks. If this is the case, will the option MAT_IGNORE_ZERO_ENTRIES be helpful?

   What do you mean by "be helpful"? Sometimes you do want those "zero" locations represented and sometimes you don't, so sometimes you would use the option and sometimes not. 

   For example, if you are going to refill the matrix a number of times with the union of the nonzero patterns then you don't want it to ignore the zero locations the first time. Otherwise the second time through when you put a true nonzero at that location it will be incredibly expensive.

   Barry

> 
> Xiangdong
> 
> On Thu, Dec 1, 2011 at 8:00 PM, Barry Smith <bsmith at mcs.anl.gov> wrote:
>> 
>> On Dec 1, 2011, at 6:44 PM, Xiangdong Liang wrote:
>> 
>>> Hello everyone,
>>> 
>>> I have a question about whether zeros will change the sparse pattern.
>>> Suppose I am generating two sparse matrices A and B. A is generated
>>> with exactly number of nonzeros, say 10 nnz per row. When I generate
>>> matrix B, I specify 12 nonzeros, but two of them are given zero values
>>> by MatSetValue. Will A and B have same sparsity patterns and
>>> performance ? In other words, will PETSc simply ignore these zeros
>>> entries?  I output these A and B in matlab, and it seems that these
>>> zeros entries are ignored. I just want to double check on this.
>>> 
>>> Is the option MAT_IGNORE_ZERO_ENTRIES on by default?
>> 
>>   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.
>> 
>> 
>>    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.
>>   Barry
>> 
>>> Thanks.
>>> 
>>> Best,
>>> Xiangdong
>> 
>> 



More information about the petsc-users mailing list