Looks fine to me. I removed the gratuitous C++ and changed #include <private/matimpl.h> to #include <src/mat/impls/aij/seq/aij.h>
Do the PETSc examples work? Barry anlext2wls165:ksp/examples/tutorials] bsmith% ./ex1 -mat_view |& more row 0: (1, 0.1) (5, 0.5) (7, 0.7) row 1: (3, 1.1) (4, 1.2) row 2: (1, 1.7) (3, 1.9) (6, 2.2) row 3: (2, 2.6) (5, 2.9) (7, 3.1) row 4: (3, 3.5) (5, 3.7) row 5: (0, 4) (4, 4.4) (6, 4.6) row 6: (1, 4.9) (5, 5.3) (7, 5.5) row 7: (3, 5.9) (5, 6.1) ptr[0] = 0 ptr[1] = 3 ptr[2] = 5 ptr[3] = 8 ptr[4] = 11 ptr[5] = 13 ptr[6] = 16 ptr[7] = 19 ind[0] = 1 ind[1] = 5 ind[2] = 7 ind[3] = 3 ind[4] = 4 ind[5] = 1 ind[6] = 3 ind[7] = 6 ind[8] = 2 ind[9] = 5 ind[10] = 7 ind[11] = 3 ind[12] = 5 ind[13] = 0 ind[14] = 4 ind[15] = 6 ind[16] = 1 ind[17] = 5 ind[18] = 7 ind[19] = 3 ind[20] = 5 val[0]] = 0.100000 val[1]] = 0.500000 val[2]] = 0.700000 val[3]] = 1.100000 val[4]] = 1.200000 val[5]] = 1.700000 val[6]] = 1.900000 val[7]] = 2.200000 val[8]] = 2.600000 val[9]] = 2.900000 val[10]] = 3.100000 val[11]] = 3.500000 val[12]] = 3.700000 val[13]] = 4.000000 val[14]] = 4.400000 val[15]] = 4.600000 val[16]] = 4.900000 val[17]] = 5.300000 val[18]] = 5.500000 val[19]] = 5.900000 val[20]] = 6.100000 On Aug 4, 2008, at 12:55 PM, Ahmed El Zein wrote: > 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 >>> > <petsc.cpp>