46 #define max(x,y) (( x > y ) ? x : y)
48 double *val,
int *indx,
int *pntr,
51 int i, j, ibgn, iend, ione = 1;
52 double 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++)
77 for (j = 0; j < n ; j++)
82 for (i = ibgn; i < iend; i++)
84 tmp[indx[i]] -= val[i] * x[j];
85 if (indx[i] != j && isym) tmp[j] -= val[i]*x[indx[i]];
88 for (i = 0; i < m; i++)
90 max_norm =
max(fabs(tmp[i]),max_norm);
91 norm_tmp += tmp[i]*tmp[i];
95 res_norm = sqrt(norm_tmp);
96 printf(
"\n\nMax norm of residual = %12.4g\n",max_norm);
97 printf(
"Two norm of residual = %12.4g\n",res_norm);
100 scaled_res_norm = res_norm/sqrt(norm_b);
101 printf(
"Scaled two norm of residual = %12.4g\n",scaled_res_norm);
106 return(scaled_res_norm);
double scscres(int isym, int m, int n, double *val, int *indx, int *pntr, double *x, double *b)