Setting up a global distributed matrix

using modified sparse row format


          


gd_matrix(a,ija) {

   /* Assign rows to processors */
   rows_on_proc = 8
   if (proc == 0) rows[0 ... 7] = { 0, 1, 2, 3, 4, 5, 6, 9}
   else           rows[0 ... 7] = { 7, 8,10,11,12,13,14,15}

   /* Create matrix rows */
   ija[0] = rows_on_proc + 1
   for (i = 0 ; i < rows_on_proc ; i++ ) add_row(i,rows[i],4)
}

add_row(loc, row, n) {
   k = ija[loc]
   ija[k] = row + 1;      if (ija[k]%n !=   0) a[k++] = -1
   ija[k] = row - 1;      if (   row%n !=   0) a[k++] = -1
   ija[k] = row + n;      if (ija[k]   <  n*n) a[k++] = -1
   ija[k] = row - n;      if (ija[k]   >=   0) a[k++] = -1
   ija[loc+1] = k
   a[loc] = 4
}

 

The sparse matrix is now ready for solution by Aztec and the implementation is much easier than local distributed matrix code !!!