Re: how do you access the nonzero elements in SeqAIJ matrices
On Mon, Aug 4, 2008 at 10:53 PM, Ahmed El Zein <[email protected]> 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().
participants (1)
-
Zi-Hao Wei