Date: 2022-03-31T04:49:09+00:00

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:   PetscInitialize(&argc,&argv,0,0);
     13:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);

     15:   VecCreate(PETSC_COMM_SELF,&x);
     16:   VecSetSizes(x,n,n);
     17:   VecSetFromOptions(x);

     19:   PetscPreLoadBegin(PETSC_TRUE,"VecNorm");
     20:   PetscTime(&t1);
     21:   VecNorm(x,NORM_2,&norm);
     22:   VecNorm(x,NORM_2,&norm);
     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:   PetscPreLoadEnd();
     32:   PetscTime(&t2);
     33:   fprintf(stdout,"%s : \n","VecNorm");
     34:   fprintf(stdout," Time %g\n",t2-t1);
     35:   PetscFinalize();
     36:   return 0;
     37: }