16 int main(
int narg,
char* arg[])
28 world = MPI_COMM_WORLD;
29 MPI_Comm_size(world,&np);
37 n=
M+1;
if(
id==np-1) --
n;
39 for(i=0;i<
n;++
i) xid[i]=1+
id*
M+i;
40 nz=2*
M;
if(
id==np-1) --
nz;
43 for(i=0;i<
M;++
i) Ai[i]=i,Aj[i]=i,A[i]=2;
45 if(
id==np-1) A[n-1]=1;
46 for(i=M;i<
nz;++
i) Ai[i]=i-M,Aj[i]=i-M+1,A[i]=-1;
48 crs =
crs_setup(n,xid, nz,Ai,Aj,A, 1, &comm);
52 double tn = M*
np, mean = 1*(tn+1)/2;
53 double avg = 1*(tn-1)*(tn+1)/12;
54 for(i=0;i<
n;++
i) x[i]=(xid[i]-mean)*(xid[
i]-mean)-avg;
55 for(i=0;i<
n;++
i) b[i]=A[i]*x[i]
56 - (i>0 ||
id!=0 ? (xid[i]-1-mean)*(xid[
i]-1-mean)-avg : 0)
57 - (i+1<n ||
id!=np-1 ? (xid[
i]+1-mean)*(xid[i]+1-mean)-avg : 0);
58 if(
id!=np-1) b[n-1]=0;
66 double d=fabs(x[i]-x2[i])/(.1+fabs(x[i]));
69 printf(
"%d : max dif = %g\n",
id,dif);
71 free(A); free(Ai); free(x); free(xid);
77 if(
id==0) printf(
"test successful\n");
#define tmalloc(type, count)
int main(int narg, char *arg[])
static void comm_free(struct comm *c)
establishes some macros to establish naming conventions
static void comm_init(struct comm *c, comm_ext ce)