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];

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

 19:   if (rank == 0) {
 20:     ii[0] = 0;
 21:     ii[1] = 2;
 22:     ii[2] = 5;
 23:     ii[3] = 7;
 24:     ii[4] = 7;
 25:     jj[0] = 0;
 26:     jj[1] = 1;
 27:     jj[2] = 1;
 28:     jj[3] = 2;
 29:     jj[4] = 6;
 30:     jj[5] = 3;
 31:     jj[6] = 7;
 32:     aa[0] = 0;
 33:     aa[1] = 1;
 34:     aa[2] = 2;
 35:     aa[3] = 3;
 36:     aa[4] = 4;
 37:     aa[5] = 5;
 38:     aa[6] = 6;
 39:     /*  0 1
 40:           1  2       6
 41:              3          7 */
 42:   } else {
 43:     ii[0] = 0;
 44:     ii[1] = 2;
 45:     ii[2] = 4;
 46:     ii[3] = 6;
 47:     ii[4] = 7;
 48:     jj[0] = 4;
 49:     jj[1] = 5;
 50:     jj[2] = 5;
 51:     jj[3] = 7;
 52:     jj[4] = 6;
 53:     jj[5] = 7;
 54:     jj[6] = 7;
 55:     aa[0] = 8;
 56:     aa[1] = 9;
 57:     aa[2] = 10;
 58:     aa[3] = 11;
 59:     aa[4] = 12;
 60:     aa[5] = 13;
 61:     aa[6] = 14;
 62:     /*    4  5
 63:              5   7
 64:                6 7
 65:                  7 */
 66:   }
 67:   MatCreateMPISBAIJWithArrays(PETSC_COMM_WORLD, bs, m, m, PETSC_DECIDE, PETSC_DECIDE, ii, jj, aa, &A);
 68:   MatView(A, PETSC_VIEWER_STDOUT_WORLD);
 69:   MatDestroy(&A);
 70:   PetscFinalize();
 71:   return 0;
 72: }

 74: /*TEST

 76:    test:
 77:       nsize: 2

 79: TEST*/