Actual source code: ex182.c
petsc-3.12.0 2019-09-29
2: static char help[] = "Tests using MatShift() to create a constant diagonal matrix\n\n";
4: #include <petscmat.h>
6: int main(int argc,char **argv)
7: {
8: Mat A,F;
9: MatFactorInfo info;
11: PetscInt m = 10;
12: IS perm;
13: PetscMPIInt size;
14: PetscBool issbaij;
16: PetscInitialize(&argc,&argv,(char*) 0,help);if (ierr) return ierr;
17: MPI_Comm_size(PETSC_COMM_WORLD,&size);
19: MatCreate(PETSC_COMM_WORLD,&A);
20: MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,m,m);
21: MatSetFromOptions(A);
22: MatSetUp(A);
23: MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);
24: MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);
26: MatShift(A,1.0);
28: PetscObjectTypeCompare((PetscObject)A,MATSEQSBAIJ,&issbaij);
29: if (size == 1 && !issbaij) {
30: MatGetFactor(A,MATSOLVERPETSC,MAT_FACTOR_LU,&F);
31: MatFactorInfoInitialize(&info);
32: ISCreateStride(PETSC_COMM_SELF,m,0,1,&perm);
33: MatLUFactorSymbolic(F,A,perm,perm,&info);
34: MatLUFactorNumeric(F,A,&info);
35: MatDestroy(&F);
36: ISDestroy(&perm);
37: }
38: MatDestroy(&A);
39: PetscFinalize();
40: return ierr;
41: }
43: /*TEST
45: test:
46: requires: define(PETSC_USE_INFO)
47: args: -info
48: filter: grep malloc | sort -b
50: test:
51: suffix: 2
52: nsize: 2
53: requires: define(PETSC_USE_INFO)
54: args: -info ex182info
55: filter: grep -h malloc "ex182info.0" | sort -b
57: test:
58: suffix: 3
59: requires: define(PETSC_USE_INFO)
60: args: -info -mat_type baij
61: filter: grep malloc | sort -b
63: test:
64: suffix: 4
65: nsize: 2
66: requires: define(PETSC_USE_INFO)
67: args: -info ex182info -mat_type baij
68: filter: grep -h malloc "ex182info.1" | sort -b
70: test:
71: suffix: 5
72: requires: define(PETSC_USE_INFO)
73: args: -info -mat_type sbaij
74: filter: grep malloc | sort -b
76: test:
77: suffix: 6
78: nsize: 2
79: requires: define(PETSC_USE_INFO)
80: args: -info ex182info -mat_type sbaij
81: filter: grep -h malloc "ex182info.0" | sort -b
83: TEST*/