00001 /* dla_gbrfsx_extended.f -- translated by f2c (version 20061008). 00002 You must link the resulting object file with libf2c: 00003 on Microsoft Windows system, link with libf2c.lib; 00004 on Linux or Unix systems, link with .../path/to/libf2c.a -lm 00005 or, if you install libf2c.a in a standard place, with -lf2c -lm 00006 -- in that order, at the end of the command line, as in 00007 cc *.o -lf2c -lm 00008 Source for libf2c is in /netlib/f2c/libf2c.zip, e.g., 00009 00010 http://www.netlib.org/f2c/libf2c.zip 00011 */ 00012 00013 #include "f2c.h" 00014 #include "blaswrap.h" 00015 00016 /* Table of constant values */ 00017 00018 static integer c__1 = 1; 00019 static doublereal c_b6 = -1.; 00020 static doublereal c_b8 = 1.; 00021 00022 /* Subroutine */ int dla_gbrfsx_extended__(integer *prec_type__, integer * 00023 trans_type__, integer *n, integer *kl, integer *ku, integer *nrhs, 00024 doublereal *ab, integer *ldab, doublereal *afb, integer *ldafb, 00025 integer *ipiv, logical *colequ, doublereal *c__, doublereal *b, 00026 integer *ldb, doublereal *y, integer *ldy, doublereal *berr_out__, 00027 integer *n_norms__, doublereal *err_bnds_norm__, doublereal * 00028 err_bnds_comp__, doublereal *res, doublereal *ayb, doublereal *dy, 00029 doublereal *y_tail__, doublereal *rcond, integer *ithresh, doublereal 00030 *rthresh, doublereal *dz_ub__, logical *ignore_cwise__, integer *info) 00031 { 00032 /* System generated locals */ 00033 integer ab_dim1, ab_offset, afb_dim1, afb_offset, b_dim1, b_offset, 00034 y_dim1, y_offset, err_bnds_norm_dim1, err_bnds_norm_offset, 00035 err_bnds_comp_dim1, err_bnds_comp_offset, i__1, i__2, i__3; 00036 doublereal d__1, d__2; 00037 char ch__1[1]; 00038 00039 /* Local variables */ 00040 doublereal dxratmax, dzratmax; 00041 integer i__, j, m; 00042 extern /* Subroutine */ int dla_gbamv__(integer *, integer *, integer *, 00043 integer *, integer *, doublereal *, doublereal *, integer *, 00044 doublereal *, integer *, doublereal *, doublereal *, integer *); 00045 logical incr_prec__; 00046 doublereal prev_dz_z__, yk, final_dx_x__; 00047 extern /* Subroutine */ int dla_wwaddw__(integer *, doublereal *, 00048 doublereal *, doublereal *); 00049 doublereal final_dz_z__, prevnormdx; 00050 integer cnt; 00051 doublereal dyk, eps, incr_thresh__, dx_x__, dz_z__; 00052 extern /* Subroutine */ int dla_lin_berr__(integer *, integer *, integer * 00053 , doublereal *, doublereal *, doublereal *); 00054 doublereal ymin; 00055 extern /* Subroutine */ int blas_dgbmv_x__(integer *, integer *, integer * 00056 , integer *, integer *, doublereal *, doublereal *, integer *, 00057 doublereal *, integer *, doublereal *, doublereal *, integer *, 00058 integer *); 00059 integer y_prec_state__; 00060 extern /* Subroutine */ int blas_dgbmv2_x__(integer *, integer *, integer 00061 *, integer *, integer *, doublereal *, doublereal *, integer *, 00062 doublereal *, doublereal *, integer *, doublereal *, doublereal *, 00063 integer *, integer *), dgbmv_(char *, integer *, integer *, 00064 integer *, integer *, doublereal *, doublereal *, integer *, 00065 doublereal *, integer *, doublereal *, doublereal *, integer *), dcopy_(integer *, doublereal *, integer *, doublereal *, 00066 integer *); 00067 doublereal dxrat, dzrat; 00068 extern /* Subroutine */ int daxpy_(integer *, doublereal *, doublereal *, 00069 integer *, doublereal *, integer *); 00070 char trans[1]; 00071 doublereal normx, normy; 00072 extern doublereal dlamch_(char *); 00073 extern /* Subroutine */ int dgbtrs_(char *, integer *, integer *, integer 00074 *, integer *, doublereal *, integer *, integer *, doublereal *, 00075 integer *, integer *); 00076 doublereal normdx; 00077 extern /* Character */ VOID chla_transtype__(char *, ftnlen, integer *); 00078 doublereal hugeval; 00079 integer x_state__, z_state__; 00080 00081 00082 /* -- LAPACK routine (version 3.2.1) -- */ 00083 /* -- Contributed by James Demmel, Deaglan Halligan, Yozo Hida and -- */ 00084 /* -- Jason Riedy of Univ. of California Berkeley. -- */ 00085 /* -- April 2009 -- */ 00086 00087 /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ 00088 /* -- Univ. of California Berkeley and NAG Ltd. -- */ 00089 00090 /* .. */ 00091 /* .. Scalar Arguments .. */ 00092 /* .. */ 00093 /* .. Array Arguments .. */ 00094 /* .. */ 00095 00096 /* Purpose */ 00097 /* ======= */ 00098 00099 /* DLA_GBRFSX_EXTENDED improves the computed solution to a system of */ 00100 /* linear equations by performing extra-precise iterative refinement */ 00101 /* and provides error bounds and backward error estimates for the solution. */ 00102 /* This subroutine is called by DGBRFSX to perform iterative refinement. */ 00103 /* In addition to normwise error bound, the code provides maximum */ 00104 /* componentwise error bound if possible. See comments for ERR_BNDS_NORM */ 00105 /* and ERR_BNDS_COMP for details of the error bounds. Note that this */ 00106 /* subroutine is only resonsible for setting the second fields of */ 00107 /* ERR_BNDS_NORM and ERR_BNDS_COMP. */ 00108 00109 /* Arguments */ 00110 /* ========= */ 00111 00112 /* PREC_TYPE (input) INTEGER */ 00113 /* Specifies the intermediate precision to be used in refinement. */ 00114 /* The value is defined by ILAPREC(P) where P is a CHARACTER and */ 00115 /* P = 'S': Single */ 00116 /* = 'D': Double */ 00117 /* = 'I': Indigenous */ 00118 /* = 'X', 'E': Extra */ 00119 00120 /* TRANS_TYPE (input) INTEGER */ 00121 /* Specifies the transposition operation on A. */ 00122 /* The value is defined by ILATRANS(T) where T is a CHARACTER and */ 00123 /* T = 'N': No transpose */ 00124 /* = 'T': Transpose */ 00125 /* = 'C': Conjugate transpose */ 00126 00127 /* N (input) INTEGER */ 00128 /* The number of linear equations, i.e., the order of the */ 00129 /* matrix A. N >= 0. */ 00130 00131 /* KL (input) INTEGER */ 00132 /* The number of subdiagonals within the band of A. KL >= 0. */ 00133 00134 /* KU (input) INTEGER */ 00135 /* The number of superdiagonals within the band of A. KU >= 0 */ 00136 00137 /* NRHS (input) INTEGER */ 00138 /* The number of right-hand-sides, i.e., the number of columns of the */ 00139 /* matrix B. */ 00140 00141 /* A (input) DOUBLE PRECISION array, dimension (LDA,N) */ 00142 /* On entry, the N-by-N matrix A. */ 00143 00144 /* LDA (input) INTEGER */ 00145 /* The leading dimension of the array A. LDA >= max(1,N). */ 00146 00147 /* AF (input) DOUBLE PRECISION array, dimension (LDAF,N) */ 00148 /* The factors L and U from the factorization */ 00149 /* A = P*L*U as computed by DGBTRF. */ 00150 00151 /* LDAF (input) INTEGER */ 00152 /* The leading dimension of the array AF. LDAF >= max(1,N). */ 00153 00154 /* IPIV (input) INTEGER array, dimension (N) */ 00155 /* The pivot indices from the factorization A = P*L*U */ 00156 /* as computed by DGBTRF; row i of the matrix was interchanged */ 00157 /* with row IPIV(i). */ 00158 00159 /* COLEQU (input) LOGICAL */ 00160 /* If .TRUE. then column equilibration was done to A before calling */ 00161 /* this routine. This is needed to compute the solution and error */ 00162 /* bounds correctly. */ 00163 00164 /* C (input) DOUBLE PRECISION array, dimension (N) */ 00165 /* The column scale factors for A. If COLEQU = .FALSE., C */ 00166 /* is not accessed. If C is input, each element of C should be a power */ 00167 /* of the radix to ensure a reliable solution and error estimates. */ 00168 /* Scaling by powers of the radix does not cause rounding errors unless */ 00169 /* the result underflows or overflows. Rounding errors during scaling */ 00170 /* lead to refining with a matrix that is not equivalent to the */ 00171 /* input matrix, producing error estimates that may not be */ 00172 /* reliable. */ 00173 00174 /* B (input) DOUBLE PRECISION array, dimension (LDB,NRHS) */ 00175 /* The right-hand-side matrix B. */ 00176 00177 /* LDB (input) INTEGER */ 00178 /* The leading dimension of the array B. LDB >= max(1,N). */ 00179 00180 /* Y (input/output) DOUBLE PRECISION array, dimension */ 00181 /* (LDY,NRHS) */ 00182 /* On entry, the solution matrix X, as computed by DGBTRS. */ 00183 /* On exit, the improved solution matrix Y. */ 00184 00185 /* LDY (input) INTEGER */ 00186 /* The leading dimension of the array Y. LDY >= max(1,N). */ 00187 00188 /* BERR_OUT (output) DOUBLE PRECISION array, dimension (NRHS) */ 00189 /* On exit, BERR_OUT(j) contains the componentwise relative backward */ 00190 /* error for right-hand-side j from the formula */ 00191 /* max(i) ( abs(RES(i)) / ( abs(op(A_s))*abs(Y) + abs(B_s) )(i) ) */ 00192 /* where abs(Z) is the componentwise absolute value of the matrix */ 00193 /* or vector Z. This is computed by DLA_LIN_BERR. */ 00194 00195 /* N_NORMS (input) INTEGER */ 00196 /* Determines which error bounds to return (see ERR_BNDS_NORM */ 00197 /* and ERR_BNDS_COMP). */ 00198 /* If N_NORMS >= 1 return normwise error bounds. */ 00199 /* If N_NORMS >= 2 return componentwise error bounds. */ 00200 00201 /* ERR_BNDS_NORM (input/output) DOUBLE PRECISION array, dimension */ 00202 /* (NRHS, N_ERR_BNDS) */ 00203 /* For each right-hand side, this array contains information about */ 00204 /* various error bounds and condition numbers corresponding to the */ 00205 /* normwise relative error, which is defined as follows: */ 00206 00207 /* Normwise relative error in the ith solution vector: */ 00208 /* max_j (abs(XTRUE(j,i) - X(j,i))) */ 00209 /* ------------------------------ */ 00210 /* max_j abs(X(j,i)) */ 00211 00212 /* The array is indexed by the type of error information as described */ 00213 /* below. There currently are up to three pieces of information */ 00214 /* returned. */ 00215 00216 /* The first index in ERR_BNDS_NORM(i,:) corresponds to the ith */ 00217 /* right-hand side. */ 00218 00219 /* The second index in ERR_BNDS_NORM(:,err) contains the following */ 00220 /* three fields: */ 00221 /* err = 1 "Trust/don't trust" boolean. Trust the answer if the */ 00222 /* reciprocal condition number is less than the threshold */ 00223 /* sqrt(n) * slamch('Epsilon'). */ 00224 00225 /* err = 2 "Guaranteed" error bound: The estimated forward error, */ 00226 /* almost certainly within a factor of 10 of the true error */ 00227 /* so long as the next entry is greater than the threshold */ 00228 /* sqrt(n) * slamch('Epsilon'). This error bound should only */ 00229 /* be trusted if the previous boolean is true. */ 00230 00231 /* err = 3 Reciprocal condition number: Estimated normwise */ 00232 /* reciprocal condition number. Compared with the threshold */ 00233 /* sqrt(n) * slamch('Epsilon') to determine if the error */ 00234 /* estimate is "guaranteed". These reciprocal condition */ 00235 /* numbers are 1 / (norm(Z^{-1},inf) * norm(Z,inf)) for some */ 00236 /* appropriately scaled matrix Z. */ 00237 /* Let Z = S*A, where S scales each row by a power of the */ 00238 /* radix so all absolute row sums of Z are approximately 1. */ 00239 00240 /* This subroutine is only responsible for setting the second field */ 00241 /* above. */ 00242 /* See Lapack Working Note 165 for further details and extra */ 00243 /* cautions. */ 00244 00245 /* ERR_BNDS_COMP (input/output) DOUBLE PRECISION array, dimension */ 00246 /* (NRHS, N_ERR_BNDS) */ 00247 /* For each right-hand side, this array contains information about */ 00248 /* various error bounds and condition numbers corresponding to the */ 00249 /* componentwise relative error, which is defined as follows: */ 00250 00251 /* Componentwise relative error in the ith solution vector: */ 00252 /* abs(XTRUE(j,i) - X(j,i)) */ 00253 /* max_j ---------------------- */ 00254 /* abs(X(j,i)) */ 00255 00256 /* The array is indexed by the right-hand side i (on which the */ 00257 /* componentwise relative error depends), and the type of error */ 00258 /* information as described below. There currently are up to three */ 00259 /* pieces of information returned for each right-hand side. If */ 00260 /* componentwise accuracy is not requested (PARAMS(3) = 0.0), then */ 00261 /* ERR_BNDS_COMP is not accessed. If N_ERR_BNDS .LT. 3, then at most */ 00262 /* the first (:,N_ERR_BNDS) entries are returned. */ 00263 00264 /* The first index in ERR_BNDS_COMP(i,:) corresponds to the ith */ 00265 /* right-hand side. */ 00266 00267 /* The second index in ERR_BNDS_COMP(:,err) contains the following */ 00268 /* three fields: */ 00269 /* err = 1 "Trust/don't trust" boolean. Trust the answer if the */ 00270 /* reciprocal condition number is less than the threshold */ 00271 /* sqrt(n) * slamch('Epsilon'). */ 00272 00273 /* err = 2 "Guaranteed" error bound: The estimated forward error, */ 00274 /* almost certainly within a factor of 10 of the true error */ 00275 /* so long as the next entry is greater than the threshold */ 00276 /* sqrt(n) * slamch('Epsilon'). This error bound should only */ 00277 /* be trusted if the previous boolean is true. */ 00278 00279 /* err = 3 Reciprocal condition number: Estimated componentwise */ 00280 /* reciprocal condition number. Compared with the threshold */ 00281 /* sqrt(n) * slamch('Epsilon') to determine if the error */ 00282 /* estimate is "guaranteed". These reciprocal condition */ 00283 /* numbers are 1 / (norm(Z^{-1},inf) * norm(Z,inf)) for some */ 00284 /* appropriately scaled matrix Z. */ 00285 /* Let Z = S*(A*diag(x)), where x is the solution for the */ 00286 /* current right-hand side and S scales each row of */ 00287 /* A*diag(x) by a power of the radix so all absolute row */ 00288 /* sums of Z are approximately 1. */ 00289 00290 /* This subroutine is only responsible for setting the second field */ 00291 /* above. */ 00292 /* See Lapack Working Note 165 for further details and extra */ 00293 /* cautions. */ 00294 00295 /* RES (input) DOUBLE PRECISION array, dimension (N) */ 00296 /* Workspace to hold the intermediate residual. */ 00297 00298 /* AYB (input) DOUBLE PRECISION array, dimension (N) */ 00299 /* Workspace. This can be the same workspace passed for Y_TAIL. */ 00300 00301 /* DY (input) DOUBLE PRECISION array, dimension (N) */ 00302 /* Workspace to hold the intermediate solution. */ 00303 00304 /* Y_TAIL (input) DOUBLE PRECISION array, dimension (N) */ 00305 /* Workspace to hold the trailing bits of the intermediate solution. */ 00306 00307 /* RCOND (input) DOUBLE PRECISION */ 00308 /* Reciprocal scaled condition number. This is an estimate of the */ 00309 /* reciprocal Skeel condition number of the matrix A after */ 00310 /* equilibration (if done). If this is less than the machine */ 00311 /* precision (in particular, if it is zero), the matrix is singular */ 00312 /* to working precision. Note that the error may still be small even */ 00313 /* if this number is very small and the matrix appears ill- */ 00314 /* conditioned. */ 00315 00316 /* ITHRESH (input) INTEGER */ 00317 /* The maximum number of residual computations allowed for */ 00318 /* refinement. The default is 10. For 'aggressive' set to 100 to */ 00319 /* permit convergence using approximate factorizations or */ 00320 /* factorizations other than LU. If the factorization uses a */ 00321 /* technique other than Gaussian elimination, the guarantees in */ 00322 /* ERR_BNDS_NORM and ERR_BNDS_COMP may no longer be trustworthy. */ 00323 00324 /* RTHRESH (input) DOUBLE PRECISION */ 00325 /* Determines when to stop refinement if the error estimate stops */ 00326 /* decreasing. Refinement will stop when the next solution no longer */ 00327 /* satisfies norm(dx_{i+1}) < RTHRESH * norm(dx_i) where norm(Z) is */ 00328 /* the infinity norm of Z. RTHRESH satisfies 0 < RTHRESH <= 1. The */ 00329 /* default value is 0.5. For 'aggressive' set to 0.9 to permit */ 00330 /* convergence on extremely ill-conditioned matrices. See LAWN 165 */ 00331 /* for more details. */ 00332 00333 /* DZ_UB (input) DOUBLE PRECISION */ 00334 /* Determines when to start considering componentwise convergence. */ 00335 /* Componentwise convergence is only considered after each component */ 00336 /* of the solution Y is stable, which we definte as the relative */ 00337 /* change in each component being less than DZ_UB. The default value */ 00338 /* is 0.25, requiring the first bit to be stable. See LAWN 165 for */ 00339 /* more details. */ 00340 00341 /* IGNORE_CWISE (input) LOGICAL */ 00342 /* If .TRUE. then ignore componentwise convergence. Default value */ 00343 /* is .FALSE.. */ 00344 00345 /* INFO (output) INTEGER */ 00346 /* = 0: Successful exit. */ 00347 /* < 0: if INFO = -i, the ith argument to DGBTRS had an illegal */ 00348 /* value */ 00349 00350 /* ===================================================================== */ 00351 00352 /* .. Local Scalars .. */ 00353 /* .. */ 00354 /* .. Parameters .. */ 00355 /* .. */ 00356 /* .. External Subroutines .. */ 00357 /* .. */ 00358 /* .. Intrinsic Functions .. */ 00359 /* .. */ 00360 /* .. Executable Statements .. */ 00361 00362 /* Parameter adjustments */ 00363 err_bnds_comp_dim1 = *nrhs; 00364 err_bnds_comp_offset = 1 + err_bnds_comp_dim1; 00365 err_bnds_comp__ -= err_bnds_comp_offset; 00366 err_bnds_norm_dim1 = *nrhs; 00367 err_bnds_norm_offset = 1 + err_bnds_norm_dim1; 00368 err_bnds_norm__ -= err_bnds_norm_offset; 00369 ab_dim1 = *ldab; 00370 ab_offset = 1 + ab_dim1; 00371 ab -= ab_offset; 00372 afb_dim1 = *ldafb; 00373 afb_offset = 1 + afb_dim1; 00374 afb -= afb_offset; 00375 --ipiv; 00376 --c__; 00377 b_dim1 = *ldb; 00378 b_offset = 1 + b_dim1; 00379 b -= b_offset; 00380 y_dim1 = *ldy; 00381 y_offset = 1 + y_dim1; 00382 y -= y_offset; 00383 --berr_out__; 00384 --res; 00385 --ayb; 00386 --dy; 00387 --y_tail__; 00388 00389 /* Function Body */ 00390 if (*info != 0) { 00391 return 0; 00392 } 00393 chla_transtype__(ch__1, (ftnlen)1, trans_type__); 00394 *(unsigned char *)trans = *(unsigned char *)&ch__1[0]; 00395 eps = dlamch_("Epsilon"); 00396 hugeval = dlamch_("Overflow"); 00397 /* Force HUGEVAL to Inf */ 00398 hugeval *= hugeval; 00399 /* Using HUGEVAL may lead to spurious underflows. */ 00400 incr_thresh__ = (doublereal) (*n) * eps; 00401 m = *kl + *ku + 1; 00402 i__1 = *nrhs; 00403 for (j = 1; j <= i__1; ++j) { 00404 y_prec_state__ = 1; 00405 if (y_prec_state__ == 2) { 00406 i__2 = *n; 00407 for (i__ = 1; i__ <= i__2; ++i__) { 00408 y_tail__[i__] = 0.; 00409 } 00410 } 00411 dxrat = 0.; 00412 dxratmax = 0.; 00413 dzrat = 0.; 00414 dzratmax = 0.; 00415 final_dx_x__ = hugeval; 00416 final_dz_z__ = hugeval; 00417 prevnormdx = hugeval; 00418 prev_dz_z__ = hugeval; 00419 dz_z__ = hugeval; 00420 dx_x__ = hugeval; 00421 x_state__ = 1; 00422 z_state__ = 0; 00423 incr_prec__ = FALSE_; 00424 i__2 = *ithresh; 00425 for (cnt = 1; cnt <= i__2; ++cnt) { 00426 00427 /* Compute residual RES = B_s - op(A_s) * Y, */ 00428 /* op(A) = A, A**T, or A**H depending on TRANS (and type). */ 00429 00430 dcopy_(n, &b[j * b_dim1 + 1], &c__1, &res[1], &c__1); 00431 if (y_prec_state__ == 0) { 00432 dgbmv_(trans, &m, n, kl, ku, &c_b6, &ab[ab_offset], ldab, &y[ 00433 j * y_dim1 + 1], &c__1, &c_b8, &res[1], &c__1); 00434 } else if (y_prec_state__ == 1) { 00435 blas_dgbmv_x__(trans_type__, n, n, kl, ku, &c_b6, &ab[ 00436 ab_offset], ldab, &y[j * y_dim1 + 1], &c__1, &c_b8, & 00437 res[1], &c__1, prec_type__); 00438 } else { 00439 blas_dgbmv2_x__(trans_type__, n, n, kl, ku, &c_b6, &ab[ 00440 ab_offset], ldab, &y[j * y_dim1 + 1], &y_tail__[1], & 00441 c__1, &c_b8, &res[1], &c__1, prec_type__); 00442 } 00443 /* XXX: RES is no longer needed. */ 00444 dcopy_(n, &res[1], &c__1, &dy[1], &c__1); 00445 dgbtrs_(trans, n, kl, ku, &c__1, &afb[afb_offset], ldafb, &ipiv[1] 00446 , &dy[1], n, info); 00447 00448 /* Calculate relative changes DX_X, DZ_Z and ratios DXRAT, DZRAT. */ 00449 00450 normx = 0.; 00451 normy = 0.; 00452 normdx = 0.; 00453 dz_z__ = 0.; 00454 ymin = hugeval; 00455 i__3 = *n; 00456 for (i__ = 1; i__ <= i__3; ++i__) { 00457 yk = (d__1 = y[i__ + j * y_dim1], abs(d__1)); 00458 dyk = (d__1 = dy[i__], abs(d__1)); 00459 if (yk != 0.) { 00460 /* Computing MAX */ 00461 d__1 = dz_z__, d__2 = dyk / yk; 00462 dz_z__ = max(d__1,d__2); 00463 } else if (dyk != 0.) { 00464 dz_z__ = hugeval; 00465 } 00466 ymin = min(ymin,yk); 00467 normy = max(normy,yk); 00468 if (*colequ) { 00469 /* Computing MAX */ 00470 d__1 = normx, d__2 = yk * c__[i__]; 00471 normx = max(d__1,d__2); 00472 /* Computing MAX */ 00473 d__1 = normdx, d__2 = dyk * c__[i__]; 00474 normdx = max(d__1,d__2); 00475 } else { 00476 normx = normy; 00477 normdx = max(normdx,dyk); 00478 } 00479 } 00480 if (normx != 0.) { 00481 dx_x__ = normdx / normx; 00482 } else if (normdx == 0.) { 00483 dx_x__ = 0.; 00484 } else { 00485 dx_x__ = hugeval; 00486 } 00487 dxrat = normdx / prevnormdx; 00488 dzrat = dz_z__ / prev_dz_z__; 00489 00490 /* Check termination criteria. */ 00491 00492 if (! (*ignore_cwise__) && ymin * *rcond < incr_thresh__ * normy 00493 && y_prec_state__ < 2) { 00494 incr_prec__ = TRUE_; 00495 } 00496 if (x_state__ == 3 && dxrat <= *rthresh) { 00497 x_state__ = 1; 00498 } 00499 if (x_state__ == 1) { 00500 if (dx_x__ <= eps) { 00501 x_state__ = 2; 00502 } else if (dxrat > *rthresh) { 00503 if (y_prec_state__ != 2) { 00504 incr_prec__ = TRUE_; 00505 } else { 00506 x_state__ = 3; 00507 } 00508 } else { 00509 if (dxrat > dxratmax) { 00510 dxratmax = dxrat; 00511 } 00512 } 00513 if (x_state__ > 1) { 00514 final_dx_x__ = dx_x__; 00515 } 00516 } 00517 if (z_state__ == 0 && dz_z__ <= *dz_ub__) { 00518 z_state__ = 1; 00519 } 00520 if (z_state__ == 3 && dzrat <= *rthresh) { 00521 z_state__ = 1; 00522 } 00523 if (z_state__ == 1) { 00524 if (dz_z__ <= eps) { 00525 z_state__ = 2; 00526 } else if (dz_z__ > *dz_ub__) { 00527 z_state__ = 0; 00528 dzratmax = 0.; 00529 final_dz_z__ = hugeval; 00530 } else if (dzrat > *rthresh) { 00531 if (y_prec_state__ != 2) { 00532 incr_prec__ = TRUE_; 00533 } else { 00534 z_state__ = 3; 00535 } 00536 } else { 00537 if (dzrat > dzratmax) { 00538 dzratmax = dzrat; 00539 } 00540 } 00541 if (z_state__ > 1) { 00542 final_dz_z__ = dz_z__; 00543 } 00544 } 00545 00546 /* Exit if both normwise and componentwise stopped working, */ 00547 /* but if componentwise is unstable, let it go at least two */ 00548 /* iterations. */ 00549 00550 if (x_state__ != 1) { 00551 if (*ignore_cwise__) { 00552 goto L666; 00553 } 00554 if (z_state__ == 3 || z_state__ == 2) { 00555 goto L666; 00556 } 00557 if (z_state__ == 0 && cnt > 1) { 00558 goto L666; 00559 } 00560 } 00561 if (incr_prec__) { 00562 incr_prec__ = FALSE_; 00563 ++y_prec_state__; 00564 i__3 = *n; 00565 for (i__ = 1; i__ <= i__3; ++i__) { 00566 y_tail__[i__] = 0.; 00567 } 00568 } 00569 prevnormdx = normdx; 00570 prev_dz_z__ = dz_z__; 00571 00572 /* Update soluton. */ 00573 00574 if (y_prec_state__ < 2) { 00575 daxpy_(n, &c_b8, &dy[1], &c__1, &y[j * y_dim1 + 1], &c__1); 00576 } else { 00577 dla_wwaddw__(n, &y[j * y_dim1 + 1], &y_tail__[1], &dy[1]); 00578 } 00579 } 00580 /* Target of "IF (Z_STOP .AND. X_STOP)". Sun's f77 won't EXIT. */ 00581 L666: 00582 00583 /* Set final_* when cnt hits ithresh. */ 00584 00585 if (x_state__ == 1) { 00586 final_dx_x__ = dx_x__; 00587 } 00588 if (z_state__ == 1) { 00589 final_dz_z__ = dz_z__; 00590 } 00591 00592 /* Compute error bounds. */ 00593 00594 if (*n_norms__ >= 1) { 00595 err_bnds_norm__[j + (err_bnds_norm_dim1 << 1)] = final_dx_x__ / ( 00596 1 - dxratmax); 00597 } 00598 if (*n_norms__ >= 2) { 00599 err_bnds_comp__[j + (err_bnds_comp_dim1 << 1)] = final_dz_z__ / ( 00600 1 - dzratmax); 00601 } 00602 00603 /* Compute componentwise relative backward error from formula */ 00604 /* max(i) ( abs(R(i)) / ( abs(op(A_s))*abs(Y) + abs(B_s) )(i) ) */ 00605 /* where abs(Z) is the componentwise absolute value of the matrix */ 00606 /* or vector Z. */ 00607 00608 /* Compute residual RES = B_s - op(A_s) * Y, */ 00609 /* op(A) = A, A**T, or A**H depending on TRANS (and type). */ 00610 00611 dcopy_(n, &b[j * b_dim1 + 1], &c__1, &res[1], &c__1); 00612 dgbmv_(trans, n, n, kl, ku, &c_b6, &ab[ab_offset], ldab, &y[j * 00613 y_dim1 + 1], &c__1, &c_b8, &res[1], &c__1); 00614 i__2 = *n; 00615 for (i__ = 1; i__ <= i__2; ++i__) { 00616 ayb[i__] = (d__1 = b[i__ + j * b_dim1], abs(d__1)); 00617 } 00618 00619 /* Compute abs(op(A_s))*abs(Y) + abs(B_s). */ 00620 00621 dla_gbamv__(trans_type__, n, n, kl, ku, &c_b8, &ab[ab_offset], ldab, & 00622 y[j * y_dim1 + 1], &c__1, &c_b8, &ayb[1], &c__1); 00623 dla_lin_berr__(n, n, &c__1, &res[1], &ayb[1], &berr_out__[j]); 00624 00625 /* End of loop for each RHS */ 00626 00627 } 00628 00629 return 0; 00630 } /* dla_gbrfsx_extended__ */