Commit a2c0ce6e authored by Gaurav Kukreja's avatar Gaurav Kukreja

Offset Calculation

Signed-off-by: 's avatarGaurav Kukreja <mailme.gaurav@gmail.com>
parent eb2eef7a
...@@ -46,6 +46,7 @@ double relax_jacobi_return_residual( double *u, double *utmp, ...@@ -46,6 +46,7 @@ double relax_jacobi_return_residual( double *u, double *utmp,
{ {
int i, j, k, l=0; int i, j, k, l=0;
double unew, diff, sum=0.0; double unew, diff, sum=0.0;
unsigned long offset;
//MODIFIED: exchanged the outer and the inner loop //MODIFIED: exchanged the outer and the inner loop
for( i=1; i < sizey-2+Interleaving_Count; i++ ) for( i=1; i < sizey-2+Interleaving_Count; i++ )
...@@ -57,15 +58,17 @@ double relax_jacobi_return_residual( double *u, double *utmp, ...@@ -57,15 +58,17 @@ double relax_jacobi_return_residual( double *u, double *utmp,
if(k == 0) break; if(k == 0) break;
if(k > sizey-2) continue; if(k > sizey-2) continue;
offset = k*sizex + j;
//MODIFIED: storing the offset in a variable //MODIFIED: storing the offset in a variable
u[k*sizex + j] = utmp[k*sizex + j]; u[offset] = utmp[offset];
utmp[k*sizex + j]= 0.25 * (u[ k*sizex + j -1 ]+ // left-old utmp[offset]= 0.25 * (u[ offset -1 ]+ // left-old
utmp[ k*sizex + j +1 ]+ // right-new utmp[ offset +1 ]+ // right-new
u[ k*sizex + j - sizex ]+ // top-old u[ offset - sizex ]+ // top-old
utmp[ k*sizex + j + sizex ]); // bottom-new utmp[ offset + sizex ]); // bottom-new
if(k == i-Interleaving_Count+1) if(k == i-Interleaving_Count+1)
{ {
diff = utmp[k*sizex + j] - u[k*sizex + j]; diff = utmp[offset] - u[offset];
sum += diff * diff; sum += diff * diff;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment