how do you access the nonzero elements in SeqAIJ matrices

Ahmed El Zein ahmed at azein.com
Mon Aug 4 12:55:40 CDT 2008


On Mon, 2008-08-04 at 11:14 -0500, Barry Smith wrote:
> Send us the code. This is suppose to be easy stuff.
> 
I have attached the code.

Ahmed 
>     Barry
> 
> On Aug 4, 2008, at 11:09 AM, Ahmed El Zein wrote:
> 
> > On Mon, 2008-08-04 at 23:13 +0800, Zi-Hao Wei wrote:
> >> On Mon, Aug 4, 2008 at 10:53 PM, Ahmed El Zein <ahmed at azein.com>  
> >> wrote:
> >>> my code looks like:
> >>>   ierr = MatCreate(PETSC_COMM_WORLD,&A); CHKERRQ(ierr);
> >>>   ierr = MatSetSizes(A,M,N,M,N); CHKERRQ(ierr);
> >>>   ierr = MatSetType(A, MATSEQAIJ); CHKERRQ(ierr);
> >>>   ierr =  MatAssemblyBegin(A, MAT_FINAL_ASSEMBLY); CHKERRQ(ierr);
> >>>   [...lots of MatSetValue() calls...]
> >>>   ierr = MatAssemblyEnd(A, MAT_FINAL_ASSEMBLY); CHKERRQ(ierr);
> >>
> >> I think that the code should be
> >>  ierr = MatCreate(PETSC_COMM_WORLD,&A); CHKERRQ(ierr);
> >>  ierr = MatSetSizes(A,M,N,M,N); CHKERRQ(ierr);
> >>  ierr = MatSetType(A, MATSEQAIJ); CHKERRQ(ierr);
> >>  [...lots of MatSetValue() calls...]
> >>  ierr = MatAssemblyBegin(A, MAT_FINAL_ASSEMBLY); CHKERRQ(ierr);
> >>  ierr = MatAssemblyEnd(A, MAT_FINAL_ASSEMBLY); CHKERRQ(ierr);
> >>
> >> The routines MatAssemblyBegin and MatAssemblyEnd should be called
> >> after completing all calls to MatSetValues().
> > You are right of course. But if these 2 calls are meant to be right
> > after each other, why isn't there just one MatAssembly() call versus a
> > Begin and End call?
> >
> > btw fixing this did not affect the problem I had.
> >
> > Ahmed
> >
-------------- next part --------------
A non-text attachment was scrubbed...
Name: petsc.cpp
Type: text/x-c++src
Size: 2440 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20080805/437efab9/attachment.bin>


More information about the petsc-dev mailing list