Actual source code: ex15.c
2: static char help[] = "Tests VecSetValuesBlocked() on sequential vectors.\n\n";
4: #include petscvec.h
5: #include petscsys.h
9: int main(int argc,char **argv)
10: {
12: PetscMPIInt size;
13: PetscInt n = 9,bs = 3,indices[2],i;
14: PetscScalar values[6];
15: Vec x;
17: PetscInitialize(&argc,&argv,(char*)0,help);
18: MPI_Comm_size(PETSC_COMM_WORLD,&size);
20: if (size != 1) SETERRQ(1,"Must be run with one processor");
22: /* create vector */
23: VecCreateSeq(PETSC_COMM_SELF,n,&x);
24: VecSetBlockSize(x,bs);
26: for (i=0; i<6; i++) values[i] = 4.0*i;
27: indices[0] = 0; indices[1] = 2;
28: VecSetValuesBlocked(x,2,indices,values,INSERT_VALUES);
30: VecAssemblyBegin(x);
31: VecAssemblyEnd(x);
33: /*
34: Resulting vector should be 0 4 8 0 0 0 12 16 20
35: */
36: VecView(x,PETSC_VIEWER_STDOUT_WORLD);
38: VecDestroy(x);
40: PetscFinalize();
41: return 0;
42: }
43: