Actual source code: PetscVecNorm.c

petsc-3.3-p7 2013-05-11
  2: #include <petscvec.h>

  6: int main(int argc,char **argv)
  7: {
  8:   Vec            x;
  9:   PetscReal      norm;
 10:   PetscLogDouble t1,t2;
 11:   int            ierr,n = 10000;

 13:   PetscInitialize(&argc,&argv,0,0);
 14:   PetscOptionsGetInt(PETSC_NULL,"-n",&n,PETSC_NULL);

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

 20:   PetscPreLoadBegin(PETSC_TRUE,"VecNorm");
 21:   PetscGetTime(&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:   PetscGetTime(&t2);


 36:   fprintf(stdout,"%s : \n","VecNorm");
 37:   fprintf(stdout," Time %g\n",t2-t1);

 39:   PetscFinalize();
 40:   return(0);
 41: }