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;
15: PetscInitialize(&argc, &argv, (char *)0, help);
16: PetscOptionsGetInt(NULL, NULL, "-n", &n, NULL);
17: if (n < 5) n = 5;
19: /* create two vectors */
20: VecCreateSeq(PETSC_COMM_SELF, n, &x);
21: VecCreateSeq(PETSC_COMM_SELF, n, &y);
23: for (i = 0; i < n; i++) {
24: v = ((PetscReal)i) + 1.0 / (((PetscReal)i) + .35);
25: VecSetValues(x, 1, &i, &v, INSERT_VALUES);
26: v += 1.375547826473644376;
27: VecSetValues(y, 1, &i, &v, INSERT_VALUES);
28: }
29: VecAssemblyBegin(y);
30: VecAssemblyEnd(y);
32: VecDot(x, y, &v);
33: PetscFPrintf(PETSC_COMM_WORLD, stdout, "Vector inner product %16.12e\n", (double)PetscRealPart(v));
35: VecDestroy(&x);
36: VecDestroy(&y);
38: PetscFinalize();
39: return 0;
40: }
42: /*TEST
44: test:
46: TEST*/