Date: 2022-03-04T17:40:00+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;
     11:   PetscInt       n = 10000;

     13:   PetscInitialize(&argc,&argv,0,0);if (ierr) return ierr;
     14:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);

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

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