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