#include "pargrid.h" /*+ get_mat - Generate a sparse matrix from the given grid Input Parameters: grid - the given grid ncomp - the number of components per grid point procinfo - the usual procinfo stuff Returns: the sparse matrix +*/ BSspmat *get_mat3d(par_grid *grid, BSprocinfo *procinfo) { BSspmat *A; int i, j, k, l, m; int count, ncomp, nonsym, positive; point ***points = grid->points; int *rp, *cval; FLOAT *aval, fncomp, off_diag, sign; ncomp = grid->ncomp; nonsym = (!grid->symmetric); positive = grid->positive; /* allocate space for the sparse matrix */ rp = (int *) MALLOC((ncomp*grid->local_total+1)*sizeof(int)); cval = (int *) MALLOC((7*ncomp*ncomp*grid->local_total)*sizeof(int)); aval = (FLOAT *) MALLOC((7*ncomp*ncomp*grid->local_total)*sizeof(FLOAT)); grid->rp = rp; grid->cval = cval; grid->aval = aval; /* ****************************************************** */ /* now put values in the matrix */ /* ****************************************************** */ fncomp = (FLOAT) ncomp; off_diag = -(1.0/(6.0*fncomp)); count = 1; rp[0] = 0; sign = 1.0; srand48((long)(11311)); for (i=1;il_num_x+1;i++) { for (j=1;jl_num_y+1;j++) { for (k=1;kl_num_z+1;k++) { for (l=0;l= 0) { for (m=0;m= 0) { for (m=0;m= 0) { for (m=0;m= 0) { for (m=0;m= 0) { for (m=0;m= 0) { for (m=0;moffset,ncomp*grid->local_total, rp,cval,aval,procinfo); CHKERRN(0); return(A); }