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


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:55:29