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