Actual source code: ex137.c

petsc-3.6.4 2016-04-12
Report Typos and Errors
  2: static char help[] = "Tests MatCreateMPISBAIJWithArrays().\n\n";

  4: #include <petscmat.h>

  8: int main(int argc,char **args)
  9: {
 10:   Mat            A;
 12:   PetscInt       m = 4, bs = 1,ii[5],jj[7];
 13:   PetscMPIInt    size,rank;
 14:   PetscScalar    aa[7];

 16:   PetscInitialize(&argc,&args,(char*)0,help);
 17:   MPI_Comm_size(PETSC_COMM_WORLD,&size);
 18:   MPI_Comm_rank(PETSC_COMM_WORLD,&rank);
 19:   if (size != 2) SETERRQ(PETSC_COMM_WORLD,PETSC_ERR_SUP,"Only for two processes");

 21:   if (!rank) {
 22:     ii[0] = 0; ii[1] = 2; ii[2] = 5; ii[3] = 7; ii[4] = 7;
 23:     jj[0] = 0; jj[1] = 1; jj[2] = 1; jj[3] = 2; jj[4] = 6; jj[5] = 3; jj[6] = 7;
 24:     aa[0] = 0; aa[1] = 1; aa[2] = 2; aa[3] = 3; aa[4] = 4; aa[5] = 5; aa[6] = 6;
 25:     /*  0 1
 26:           1  2       6
 27:              3          7 */
 28:   } else {
 29:     ii[0] = 0; ii[1] = 2; ii[2] = 4; ii[3] = 6; ii[4] = 7;
 30:     jj[0] = 4; jj[1] = 5; jj[2] = 5; jj[3] = 7; jj[4] = 6; jj[5] = 7; jj[6] = 7;
 31:     aa[0] = 8; aa[1] = 9; aa[2] = 10; aa[3] = 11; aa[4] = 12; aa[5] = 13; aa[6] = 14;
 32:     /*    4  5
 33:              5   7
 34:                6 7
 35:                  7 */
 36:   }
 37:   MatCreateMPISBAIJWithArrays(PETSC_COMM_WORLD,bs,m,m,PETSC_DECIDE,PETSC_DECIDE,ii,jj,aa,&A);
 38:   MatView(A,PETSC_VIEWER_STDOUT_WORLD);
 39:   MatDestroy(&A);
 40:   PetscFinalize();
 41:   return 0;
 42: }