46 #define max(x,y) (( x > y ) ? x : y)
48 double *val,
int *indx,
49 double *xlocal,
double *x,
double *b)
51 int i, j, jbgn, jend, ione = 1;
52 double sum, norm_tmp = 0.0, norm_b = 0.0;
53 double scaled_res_norm, res_norm, *tmp, max_norm = 0.0;
68 tmp = (
double *) calloc(m,
sizeof(
double));
72 for (i = 0; i < m; i++)
73 tmp[i] = b[i] - val[i] * xlocal[i];
77 for (i = 0; i <m ; i++)
83 for (j = jbgn; j < jend; j++)
84 sum += val[j] * x[indx[j]];
87 max_norm =
max(fabs(tmp[i]),max_norm);
88 norm_tmp += tmp[i]*tmp[i];
92 res_norm = sqrt(norm_tmp);
93 printf(
"\n\nMax norm of residual = %12.4g\n",max_norm);
94 printf(
"Two norm of residual = %12.4g\n",res_norm);
97 scaled_res_norm = res_norm/sqrt(norm_b);
98 printf(
"Scaled two norm of residual = %12.4g\n",scaled_res_norm);
102 return(scaled_res_norm);
double smsrres(int m, int n, double *val, int *indx, double *xlocal, double *x, double *b)