Actual source code: ex21.c
2: static char help[] = "Tests VecMax() with index.\n\
3: -n <length> : vector length\n\n";
5: #include <petscvec.h>
7: int main(int argc,char **argv)
8: {
10: PetscInt n = 5,idx;
11: PetscReal value,value2;
12: Vec x;
13: PetscScalar one = 1.0;
15: PetscInitialize(&argc,&argv,(char*)0,help);if (ierr) return ierr;
16: PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
18: /* create vector */
19: VecCreate(PETSC_COMM_WORLD,&x);
20: VecSetSizes(x,PETSC_DECIDE,n);
21: VecSetFromOptions(x);
23: VecSet(x,one);
24: VecSetValue(x,0,0.0,INSERT_VALUES);
25: VecSetValue(x,n-1,2.0,INSERT_VALUES);
26: VecAssemblyBegin(x);
27: VecAssemblyEnd(x);
28: VecView(x,PETSC_VIEWER_STDOUT_WORLD);
29: VecMax(x,&idx,&value);
30: VecMax(x,NULL,&value2);
31: PetscPrintf(PETSC_COMM_WORLD,"Maximum value %g index %D (no index %g)\n",(double)value,idx,(double)value2);
32: VecMin(x,&idx,&value);
33: VecMin(x,NULL,&value2);
34: PetscPrintf(PETSC_COMM_WORLD,"Minimum value %g index %D (no index %g)\n",(double)value,idx,(double)value2);
36: VecDestroy(&x);
38: PetscFinalize();
39: return ierr;
40: }
42: /*TEST
44: testset:
45: diff_args: -j
46: filter: grep -v type
47: output_file: output/ex21_1.out
49: test:
50: suffix: 1
52: test:
53: requires: cuda
54: suffix: 1_cuda
55: args: -vec_type cuda
57: test:
58: requires: kokkos_kernels
59: suffix: 1_kokkos
60: args: -vec_type kokkos
62: test:
63: requires: hip
64: suffix: 1_hip
65: args: -vec_type hip
67: testset:
68: diff_args: -j
69: filter: grep -v type
70: output_file: output/ex21_2.out
71: nsize: 2
73: test:
74: suffix: 2
76: test:
77: requires: cuda
78: suffix: 2_cuda
79: args: -vec_type cuda
81: test:
82: requires: kokkos_kernels
83: suffix: 2_kokkos
84: args: -vec_type kokkos
86: test:
87: requires: hip
88: suffix: 2_hip
89: args: -vec_type hip
91: TEST*/