[petsc-users] Fwd: MatCreateSeqAIJ( ) Quesion

Jed Brown jedbrown at mcs.anl.gov
Sat Jul 20 14:08:06 CDT 2013


Lu Qiyue <luqiyue at gmail.com> writes:

> ---------- Forwarded message ----------
> From: Lu Qiyue <luqiyue at gmail.com>
> Date: Fri, Jul 19, 2013 at 3:39 PM
> Subject: Re: [petsc-users] MatCreateSeqAIJ( ) Quesion
> To: Barry Smith <bsmith at mcs.anl.gov>
>
>
> Thanks Barry.
> I am trying to premalloc the correct value for each row. Assume the matrix
> is in COO format and N is the dimension, NNZ is total non-zeros. My
> workflow is as below:
> 1) generating a file holding all the correct number of non-zeros for each
> row and read-in as cnt
>
> from
> http://www.mcs.anl.gov/petsc/petsc-current/src/mat/examples/tutorials/ex12.c.html
> It looks cnt should have N+1 dimension and the last value is the total
> non-zeros NNZ
> One question here is at line 45, why the dimension of matrix are set to be
> (n+1), should it be n ?
> In http://www.mcs.anl.gov/petsc/petsc-dev/src/mat/examples/tests/ex72.c.html
> they are just set to m, n

That example is creating a matrix with an extra row and column.

> For ex72.c, 

I don't know which ex72 you are looking at.

> the code copy the entries which not on the diagonal and make the
> symmetric COO matrix to be FULL.  But when we do the MatCreateSeqAIJ,
> the cnt should holding number of non-zeros per row of FULL matrix,
> right?
>
> In one word, what's the content(and dimension) of cnt array and how to set
> MatCreateSeqAIJ() assuming a N dimension matrix?

MatCreateSeqAIJ(PETSC_COMM_SELF,N,N,0,cnt,&A);

where cnt[] is an array of length N, with cnt[i] containing the number
of nonzeros in row i.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20130720/dad49db4/attachment.pgp>


More information about the petsc-users mailing list