[petsc-users] zeros in sparse aij

Satish Balay balay at mcs.anl.gov
Wed Dec 7 11:07:06 CST 2011


On Wed, 7 Dec 2011, Xiangdong Liang wrote:

> >> >> Matrix Object:
> >> >> type=mpiaij, rows=10, cols=10
> >> >> total: nonzeros=20, allocated nonzeros=40
> >> >>   not using I-node (on process 0) routines
> >> >>
> >> >> Is there a way to have nonzeros=10, and allocated nonzeros=10, since
> >> >> the number of real nonzeros=10? Thanks.
> >> >
> >> >   Those "extra" nonzeros are not actually in the sparse matrix so they
> >> > do not cause extra multiples. You can safely ignore them.
> >>
> >> I am sorry I am still not clear.   Do "extra" nonzeros refer to
> >> “nonzeros=20” or "allocated nonzeros=40"? With or without
> >> MatSetOption(A,MAT_IGNORE_ZERO_ENTRIES,PETSC_TRUE), I see the same
> >> mat_view_info. How can I see the differences in the spare matrix
> >> generated With/Without this option? Thanks.
> >
> >
> > If there are 2 nonzeros per row, there are 20 nonzeros not 10 in the matrix.
> > According to
> > the output, you allocated 40 nonzeros for the matrix.
> 
> Now, I understand the "allocated nonzeros=40". How can I bring the
> other one " total nonzero=20" down to " total nonzero=10", since 10
> out of 20 values are 0.0? Thanks.

As indicated call "MatSetOption(A,MAT_IGNORE_ZERO_ENTRIES,PETSC_TRUE)
- before any calls to MatSetValue/s()

And verify with MatView()

Satish


More information about the petsc-users mailing list