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