Actual source code: PetscVecNorm.c
1: #include <petscvec.h>
2: #include <petsctime.h>
4: int main(int argc,char **argv)
5: {
6: Vec x;
7: PetscReal norm;
8: PetscLogDouble t1,t2;
9: PetscInt n = 10000;
11: PetscCall(PetscInitialize(&argc,&argv,0,0));
12: PetscCall(PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL));
14: PetscCall(VecCreate(PETSC_COMM_SELF,&x));
15: PetscCall(VecSetSizes(x,n,n));
16: PetscCall(VecSetFromOptions(x));
18: PetscPreLoadBegin(PETSC_TRUE,"VecNorm");
19: PetscCall(PetscTime(&t1));
20: PetscCall(VecNorm(x,NORM_2,&norm));
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: PetscPreLoadEnd();
31: PetscCall(PetscTime(&t2));
32: fprintf(stdout,"%s : \n","VecNorm");
33: fprintf(stdout," Time %g\n",t2-t1);
34: PetscCall(PetscFinalize());
35: return 0;
36: }