Actual source code: ex17.c
1: /*
2: Demonstrates the use of the "extra", polymorphic versions of many functions
3: */
4: #include petsc.h
5: #include petscvec.h
9: int main(int argc,char **args)
10: {
12: Vec x;
13: PetscReal norm;
14: PetscMap map;
15: #if defined(__cplusplus)
16: PetscInt s;
17: PetscMapType t;
18: PetscScalar dot;
19: #endif
21: #if defined(__cplusplus)
22: PetscInitialize(&argc,&args);
23: #else
24: PetscInitialize(&argc,&args,0,0);
25: #endif
27: #if defined(__cplusplus)
28: PetscSequentialPhaseBegin();
29: PetscSequentialPhaseEnd();
30: #endif
32: #if defined(__cplusplus)
33: VecCreate(&x);
34: #else
35: VecCreate(PETSC_COMM_SELF,&x);
36: #endif
37: VecSetSizes(x,2,2);
38: VecSetType(x,VECSEQ);
39: VecView(x,PETSC_VIEWER_STDOUT_SELF);
40: #if defined(__cplusplus)
41: norm = VecNorm(x);
42: norm = VecNorm(x,NORM_2);
43: VecNormBegin(x,NORM_2);
44: norm = VecNormEnd(x,NORM_2);
45: VecDotBegin(x,x);
46: dot = VecDotEnd(x,x);
47: #else
48: VecNorm(x,NORM_2,&norm);
49: #endif
50: VecDestroy(x);
52: #if defined(__cplusplus)
53: map = PetscMapCreate();
54: s = PetscMapGetLocalSize(map);
55: s = PetscMapGetSize(map);
56: t = PetscMapGetType(map);
57: #else
58: PetscMapCreate(PETSC_COMM_SELF,&map);
59: #endif
61: PetscMapDestroy(map);
62: PetscFinalize();
63: return 0;
64: }