Actual source code: ex137.c

petsc-3.10.5 2019-03-28
Report Typos and Errors

  2: static char help[] = "Tests MatCreateMPISBAIJWithArrays().\n\n";

  4:  #include <petscmat.h>

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

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

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


 43: /*TEST

 45:    test:
 46:       nsize: 2

 48: TEST*/