Skip to content
Snippets Groups Projects
Commit 0ad4f01c authored by Daniel Maier's avatar Daniel Maier
Browse files

nussinov: fix calc_error

parent 48b330f5
No related branches found
No related tags found
No related merge requests found
...@@ -75,28 +75,31 @@ static ...@@ -75,28 +75,31 @@ static
void calc_error(int n, void calc_error(int n,
DATA_TYPE POLYBENCH_2D(table,N,N,n,n)) DATA_TYPE POLYBENCH_2D(table,N,N,n,n))
{ {
int i; int i, j;
int num = n*n; int cnt = 0;
double err = 0; double err = 0;
int *accurate = &_binary_data_bin_start; int *accurate = &_binary_data_bin_start;
int *test = &(table[0][0]); int *test = &(table[0][0]);
for(i = 0; i < num; i++) { for (i = 0; i < n; i++) {
if(fabs((double)(accurate[i]) - test[i]) > 0.0) { for (j = i; j < n; j++) {
double e; if(fabs((double)(accurate[i*n+j]) - test[i*n+j]) > 0.0) {
if(fabs((double)(accurate[i])) > 0.0) { double e;
e = fabs(((double)(accurate[i]) - test[i])/accurate[i]); if(fabs((double)(accurate[i*n+j])) > 0.0) {
e = fabs(((double)(accurate[i*n+j]) - test[i*n+j])/accurate[i*n+j]);
}
else {
e = fabs((double)(accurate[i*n+j]) - test[i*n+j]);
}
/* clamp error to max 1 */
if(e > 1)
e = 1;
err += e;
} }
else { cnt++;
e = fabs((double)(accurate[i]) - test[i]);
}
/* clamp error to max 1 */
if(e > 1)
e = 1;
err += e;
} }
} }
err /= num; err /= cnt;
printf("error: %f\n", err); printf("error: %f\n", err);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment