Actual source code: ex18.c
2: static char help[] = "Compares BLAS dots on different machines. Input\n\
3: arguments are\n\
4: -n <length> : local vector length\n\n";
6: #include <petscvec.h>
8: int main(int argc,char **argv)
9: {
10: PetscInt n = 15,i;
11: PetscScalar v;
12: Vec x,y;
14: PetscInitialize(&argc,&argv,(char*)0,help);
15: PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
16: if (n < 5) n = 5;
18: /* create two vectors */
19: VecCreateSeq(PETSC_COMM_SELF,n,&x);
20: VecCreateSeq(PETSC_COMM_SELF,n,&y);
22: for (i=0; i<n; i++) {
23: v = ((PetscReal)i) + 1.0/(((PetscReal)i) + .35);
24: VecSetValues(x,1,&i,&v,INSERT_VALUES);
25: v += 1.375547826473644376;
26: VecSetValues(y,1,&i,&v,INSERT_VALUES);
27: }
28: VecAssemblyBegin(y);
29: VecAssemblyEnd(y);
31: VecDot(x,y,&v);
32: PetscFPrintf(PETSC_COMM_WORLD,stdout,"Vector inner product %16.12e\n",(double)PetscRealPart(v));
34: VecDestroy(&x);
35: VecDestroy(&y);
37: PetscFinalize();
38: return 0;
39: }
41: /*TEST
43: test:
45: TEST*/