Actual source code: PetscVecNorm.c
2: #include <petscvec.h>
3: #include <petsctime.h>
5: int main(int argc,char **argv)
6: {
7: Vec x;
8: PetscReal norm;
9: PetscLogDouble t1,t2;
10: PetscInt n = 10000;
12: PetscCall(PetscInitialize(&argc,&argv,0,0));
13: PetscCall(PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL));
15: PetscCall(VecCreate(PETSC_COMM_SELF,&x));
16: PetscCall(VecSetSizes(x,n,n));
17: PetscCall(VecSetFromOptions(x));
19: PetscPreLoadBegin(PETSC_TRUE,"VecNorm");
20: PetscCall(PetscTime(&t1));
21: PetscCall(VecNorm(x,NORM_2,&norm));
22: PetscCall(VecNorm(x,NORM_2,&norm));
23: PetscCall(VecNorm(x,NORM_2,&norm));
24: PetscCall(VecNorm(x,NORM_2,&norm));
25: PetscCall(VecNorm(x,NORM_2,&norm));
26: PetscCall(VecNorm(x,NORM_2,&norm));
27: PetscCall(VecNorm(x,NORM_2,&norm));
28: PetscCall(VecNorm(x,NORM_2,&norm));
29: PetscCall(VecNorm(x,NORM_2,&norm));
30: PetscCall(VecNorm(x,NORM_2,&norm));
31: PetscPreLoadEnd();
32: PetscCall(PetscTime(&t2));
33: fprintf(stdout,"%s : \n","VecNorm");
34: fprintf(stdout," Time %g\n",t2-t1);
35: PetscCall(PetscFinalize());
36: return 0;
37: }