does anyone know what is wrong with this?
when i compile, i get the error:Code:int iteration; int i,j; double sum; for (iteration=0;iteration<20;iteration++) { /*x1[i] =1/a[i][i] *(b[i] -(sum on j, except j=i)a[i][j]*x0[j]) for i=0,...,4. (2b)*/ for (i=0;i<=4;i++) { sum=0; for (j=0;j<=4;j++) if (i!=j) sum+=a[i][j]*x0[j]; x1[i]=1.0/a[i][i]*(b[i]-sum); } printf("Iteration %d:\n",iteration); for (i=0;i<=4;i++) printf("%15.4e ",x1[i]); printf("\n"); //copy x1 to x- for the next iteration memcpy(x0,x1,4*sizeof(double)); } //compute and display residue for (i=0;i<=4;i++) residue[i]=b[i]-a[i][i]*x1[i]; printf("Residue:\n"); for (i=0;i<=4;i++) printf("%12.4e ",residue[i]); return; }
`residue' undeclared (first use in this function)
(Each undeclared identifier is reported only once
for each function it appears in.)
the line they are talking about is:
residue[i]=b[i]-a[i][i]*x1[i];



LinkBack URL
About LinkBacks


