Actual source code: ex7.c
petsc-3.8.4 2018-03-24
2: static char help[] = "Tests PetscSortIntWithPermutation().\n\n";
4: #include <petscsys.h>
6: int main(int argc,char **argv)
7: {
8: PetscInt i;
9: PetscInt x[] = {39, 9, 39, 39, 29},index[5];
10: PetscInt x2[] = {39, 9, 19, 39, 29, 39, 29, 39},index2[8];
13: PetscInitialize(&argc,&argv,(char*)0,help);if (ierr) return ierr;
14: PetscPrintf(PETSC_COMM_SELF,"1st test\n");
15: for (i=0; i<5; i++) index[i] = i;
16: PetscSortIntWithPermutation(5, x, index);
17: for (i=0; i<5; i++) {PetscPrintf(PETSC_COMM_SELF," %D %D %D\n",x[i], index[i],x[index[i]]);}
19: PetscPrintf(PETSC_COMM_SELF,"\n2nd test\n");
20: for (i=0; i<8; i++) index2[i] = i;
21: PetscSortIntWithPermutation(8, x2, index2);
22: for (i=0; i<8; i++) {PetscPrintf(PETSC_COMM_SELF," %D %D %D\n",x2[i], index2[i],x2[index2[i]]);}
23: PetscFinalize();
24: return ierr;
25: }
29: /*TEST
31: test:
34: TEST*/