Actual source code: ex137.c


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

  4: #include <petscmat.h>

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

 13:   PetscInitialize(&argc,&args,(char*)0,help);
 14:   MPI_Comm_size(PETSC_COMM_WORLD,&size);
 15:   MPI_Comm_rank(PETSC_COMM_WORLD,&rank);

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

 41: /*TEST

 43:    test:
 44:       nsize: 2

 46: TEST*/