Actual source code: ex17.c
1: /*
2: Demonstrates the use of the "extra", polymorphic versions of many functions
3: */
4: #include petscsys.h
5: #include petscvec.h
9: int main(int argc,char **args)
10: {
12: Vec x;
13: PetscReal norm;
15: PetscScalar dot;
16: #endif
19: PetscInitialize(&argc,&args);
20: #else
21: PetscInitialize(&argc,&args,0,0);
22: #endif
25: PetscSequentialPhaseBegin();
26: PetscSequentialPhaseEnd();
27: #endif
30: VecCreate(&x);
31: #else
32: VecCreate(PETSC_COMM_SELF,&x);
33: #endif
34: VecSetSizes(x,2,2);
35: VecSetType(x,VECSEQ);
36: VecView(x,PETSC_VIEWER_STDOUT_SELF);
38: norm = VecNorm(x);
39: norm = VecNorm(x,NORM_2);
40: VecNormBegin(x,NORM_2);
41: norm = VecNormEnd(x,NORM_2);
42: VecDotBegin(x,x);
43: dot = VecDotEnd(x,x);
44: #else
45: VecNorm(x,NORM_2,&norm);
46: #endif
47: VecDestroy(x);
49: PetscFinalize();
50: return 0;
51: }