Actual source code: ex232.c
petsc-3.12.5 2020-03-29
2: /* tests MatSeqSBAIJSetPreallocationCSR() and MatMPISBAIJSetPreallocationCSR() */
4: #include <petsc.h>
6: int main(int argc, char **args)
7: {
8: PetscInt ia[3] = { 0, 2, 4};
9: PetscInt ja[4] = { 0, 1, 0, 1};
10: PetscScalar c[16] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
11: Mat ssbaij;
12: Mat msbaij;
15: PetscInitialize(&argc,&args,(char*)0,(char*)0);if (ierr) return ierr;
17: MatCreate(PETSC_COMM_SELF, &ssbaij);
18: MatCreate(PETSC_COMM_SELF, &msbaij);
19: MatSetType(ssbaij, MATSEQSBAIJ);
20: MatSetType(msbaij, MATMPISBAIJ);
21: MatSetBlockSize(ssbaij, 2);
22: MatSetSizes(ssbaij, 4, 4, 4, 4);
23: MatSetBlockSize(msbaij, 2);
24: MatSetSizes(msbaij, 4, 4, 4, 4);
25: MatSeqSBAIJSetPreallocationCSR(ssbaij, 2, ia, ja, c);
26: MatMPISBAIJSetPreallocationCSR(msbaij, 2, ia, ja, c);
27: MatView(ssbaij, PETSC_VIEWER_STDOUT_(PETSC_COMM_SELF));
28: MatView(msbaij, PETSC_VIEWER_STDOUT_(PETSC_COMM_SELF));
29: MatDestroy(&ssbaij);
30: MatDestroy(&msbaij);
31: PetscFinalize();
32: return ierr;
33: }
35: /*TEST
37: test:
38: filter: sed "s?\.??g"
40: TEST*/