cla_gerfsx_extended.c
Go to the documentation of this file.
00001 /* cla_gerfsx_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_gerfsx_extended__(integer *prec_type__, integer *
00024         trans_type__, integer *n, integer *nrhs, complex *a, integer *lda, 
00025         complex *af, integer *ldaf, integer *ipiv, logical *colequ, real *c__,
00026          complex *b, integer *ldb, complex *y, integer *ldy, real *berr_out__,
00027          integer *n_norms__, real *errs_n__, real *errs_c__, complex *res, 
00028         real *ayb, complex *dy, complex *y_tail__, real *rcond, integer *
00029         ithresh, real *rthresh, real *dz_ub__, logical *ignore_cwise__, 
00030         integer *info)
00031 {
00032     /* System generated locals */
00033     integer a_dim1, a_offset, af_dim1, af_offset, b_dim1, b_offset, y_dim1, 
00034             y_offset, errs_n_dim1, errs_n_offset, errs_c_dim1, errs_c_offset, 
00035             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;
00045     extern /* Subroutine */ int cla_geamv__(integer *, integer *, integer *, 
00046             real *, complex *, integer *, complex *, integer *, real *, real *
00047             , 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_cgemv_x__(integer *, integer *, integer *
00059             , complex *, complex *, integer *, complex *, integer *, complex *
00060             , complex *, integer *, integer *);
00061     integer y_prec_state__;
00062     extern /* Subroutine */ int blas_cgemv2_x__(integer *, integer *, integer 
00063             *, complex *, complex *, integer *, complex *, complex *, integer 
00064             *, complex *, complex *, integer *, integer *), cgemv_(char *, 
00065             integer *, integer *, complex *, complex *, integer *, complex *, 
00066             integer *, complex *, complex *, integer *), ccopy_(
00067             integer *, complex *, integer *, complex *, integer *);
00068     real dxrat, dzrat;
00069     extern /* Subroutine */ int caxpy_(integer *, complex *, complex *, 
00070             integer *, complex *, integer *);
00071     char trans[1];
00072     real normx, normy;
00073     extern doublereal slamch_(char *);
00074     extern /* Subroutine */ int cgetrs_(char *, integer *, integer *, complex 
00075             *, integer *, integer *, complex *, integer *, integer *);
00076     real normdx;
00077     extern /* Character */ VOID chla_transtype__(char *, ftnlen, integer *);
00078     real 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 /*  CLA_GERFSX_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 CGERFSX 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 /*     NRHS           (input) INTEGER */
00132 /*     The number of right-hand-sides, i.e., the number of columns of the */
00133 /*     matrix B. */
00134 
00135 /*     A              (input) COMPLEX array, dimension (LDA,N) */
00136 /*     On entry, the N-by-N matrix A. */
00137 
00138 /*     LDA            (input) INTEGER */
00139 /*     The leading dimension of the array A.  LDA >= max(1,N). */
00140 
00141 /*     AF             (input) COMPLEX array, dimension (LDAF,N) */
00142 /*     The factors L and U from the factorization */
00143 /*     A = P*L*U as computed by CGETRF. */
00144 
00145 /*     LDAF           (input) INTEGER */
00146 /*     The leading dimension of the array AF.  LDAF >= max(1,N). */
00147 
00148 /*     IPIV           (input) INTEGER array, dimension (N) */
00149 /*     The pivot indices from the factorization A = P*L*U */
00150 /*     as computed by CGETRF; row i of the matrix was interchanged */
00151 /*     with row IPIV(i). */
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) REAL 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 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 array, dimension (LDY,NRHS) */
00175 /*     On entry, the solution matrix X, as computed by CGETRS. */
00176 /*     On exit, the improved solution matrix Y. */
00177 
00178 /*     LDY            (input) INTEGER */
00179 /*     The leading dimension of the array Y.  LDY >= max(1,N). */
00180 
00181 /*     BERR_OUT       (output) REAL array, dimension (NRHS) */
00182 /*     On exit, BERR_OUT(j) contains the componentwise relative backward */
00183 /*     error for right-hand-side j from the formula */
00184 /*         max(i) ( abs(RES(i)) / ( abs(op(A_s))*abs(Y) + abs(B_s) )(i) ) */
00185 /*     where abs(Z) is the componentwise absolute value of the matrix */
00186 /*     or vector Z. This is computed by CLA_LIN_BERR. */
00187 
00188 /*     N_NORMS        (input) INTEGER */
00189 /*     Determines which error bounds to return (see ERR_BNDS_NORM */
00190 /*     and ERR_BNDS_COMP). */
00191 /*     If N_NORMS >= 1 return normwise error bounds. */
00192 /*     If N_NORMS >= 2 return componentwise error bounds. */
00193 
00194 /*     ERR_BNDS_NORM  (input/output) REAL array, dimension (NRHS, N_ERR_BNDS) */
00195 /*     For each right-hand side, this array contains information about */
00196 /*     various error bounds and condition numbers corresponding to the */
00197 /*     normwise relative error, which is defined as follows: */
00198 
00199 /*     Normwise relative error in the ith solution vector: */
00200 /*             max_j (abs(XTRUE(j,i) - X(j,i))) */
00201 /*            ------------------------------ */
00202 /*                  max_j abs(X(j,i)) */
00203 
00204 /*     The array is indexed by the type of error information as described */
00205 /*     below. There currently are up to three pieces of information */
00206 /*     returned. */
00207 
00208 /*     The first index in ERR_BNDS_NORM(i,:) corresponds to the ith */
00209 /*     right-hand side. */
00210 
00211 /*     The second index in ERR_BNDS_NORM(:,err) contains the following */
00212 /*     three fields: */
00213 /*     err = 1 "Trust/don't trust" boolean. Trust the answer if the */
00214 /*              reciprocal condition number is less than the threshold */
00215 /*              sqrt(n) * slamch('Epsilon'). */
00216 
00217 /*     err = 2 "Guaranteed" error bound: The estimated forward error, */
00218 /*              almost certainly within a factor of 10 of the true error */
00219 /*              so long as the next entry is greater than the threshold */
00220 /*              sqrt(n) * slamch('Epsilon'). This error bound should only */
00221 /*              be trusted if the previous boolean is true. */
00222 
00223 /*     err = 3  Reciprocal condition number: Estimated normwise */
00224 /*              reciprocal condition number.  Compared with the threshold */
00225 /*              sqrt(n) * slamch('Epsilon') to determine if the error */
00226 /*              estimate is "guaranteed". These reciprocal condition */
00227 /*              numbers are 1 / (norm(Z^{-1},inf) * norm(Z,inf)) for some */
00228 /*              appropriately scaled matrix Z. */
00229 /*              Let Z = S*A, where S scales each row by a power of the */
00230 /*              radix so all absolute row sums of Z are approximately 1. */
00231 
00232 /*     This subroutine is only responsible for setting the second field */
00233 /*     above. */
00234 /*     See Lapack Working Note 165 for further details and extra */
00235 /*     cautions. */
00236 
00237 /*     ERR_BNDS_COMP  (input/output) REAL array, dimension (NRHS, N_ERR_BNDS) */
00238 /*     For each right-hand side, this array contains information about */
00239 /*     various error bounds and condition numbers corresponding to the */
00240 /*     componentwise relative error, which is defined as follows: */
00241 
00242 /*     Componentwise relative error in the ith solution vector: */
00243 /*                    abs(XTRUE(j,i) - X(j,i)) */
00244 /*             max_j ---------------------- */
00245 /*                         abs(X(j,i)) */
00246 
00247 /*     The array is indexed by the right-hand side i (on which the */
00248 /*     componentwise relative error depends), and the type of error */
00249 /*     information as described below. There currently are up to three */
00250 /*     pieces of information returned for each right-hand side. If */
00251 /*     componentwise accuracy is not requested (PARAMS(3) = 0.0), then */
00252 /*     ERR_BNDS_COMP is not accessed.  If N_ERR_BNDS .LT. 3, then at most */
00253 /*     the first (:,N_ERR_BNDS) entries are returned. */
00254 
00255 /*     The first index in ERR_BNDS_COMP(i,:) corresponds to the ith */
00256 /*     right-hand side. */
00257 
00258 /*     The second index in ERR_BNDS_COMP(:,err) contains the following */
00259 /*     three fields: */
00260 /*     err = 1 "Trust/don't trust" boolean. Trust the answer if the */
00261 /*              reciprocal condition number is less than the threshold */
00262 /*              sqrt(n) * slamch('Epsilon'). */
00263 
00264 /*     err = 2 "Guaranteed" error bound: The estimated forward error, */
00265 /*              almost certainly within a factor of 10 of the true error */
00266 /*              so long as the next entry is greater than the threshold */
00267 /*              sqrt(n) * slamch('Epsilon'). This error bound should only */
00268 /*              be trusted if the previous boolean is true. */
00269 
00270 /*     err = 3  Reciprocal condition number: Estimated componentwise */
00271 /*              reciprocal condition number.  Compared with the threshold */
00272 /*              sqrt(n) * slamch('Epsilon') to determine if the error */
00273 /*              estimate is "guaranteed". These reciprocal condition */
00274 /*              numbers are 1 / (norm(Z^{-1},inf) * norm(Z,inf)) for some */
00275 /*              appropriately scaled matrix Z. */
00276 /*              Let Z = S*(A*diag(x)), where x is the solution for the */
00277 /*              current right-hand side and S scales each row of */
00278 /*              A*diag(x) by a power of the radix so all absolute row */
00279 /*              sums of Z are approximately 1. */
00280 
00281 /*     This subroutine is only responsible for setting the second field */
00282 /*     above. */
00283 /*     See Lapack Working Note 165 for further details and extra */
00284 /*     cautions. */
00285 
00286 /*     RES            (input) COMPLEX array, dimension (N) */
00287 /*     Workspace to hold the intermediate residual. */
00288 
00289 /*     AYB            (input) REAL array, dimension (N) */
00290 /*     Workspace. */
00291 
00292 /*     DY             (input) COMPLEX array, dimension (N) */
00293 /*     Workspace to hold the intermediate solution. */
00294 
00295 /*     Y_TAIL         (input) COMPLEX array, dimension (N) */
00296 /*     Workspace to hold the trailing bits of the intermediate solution. */
00297 
00298 /*     RCOND          (input) REAL */
00299 /*     Reciprocal scaled condition number.  This is an estimate of the */
00300 /*     reciprocal Skeel condition number of the matrix A after */
00301 /*     equilibration (if done).  If this is less than the machine */
00302 /*     precision (in particular, if it is zero), the matrix is singular */
00303 /*     to working precision.  Note that the error may still be small even */
00304 /*     if this number is very small and the matrix appears ill- */
00305 /*     conditioned. */
00306 
00307 /*     ITHRESH        (input) INTEGER */
00308 /*     The maximum number of residual computations allowed for */
00309 /*     refinement. The default is 10. For 'aggressive' set to 100 to */
00310 /*     permit convergence using approximate factorizations or */
00311 /*     factorizations other than LU. If the factorization uses a */
00312 /*     technique other than Gaussian elimination, the guarantees in */
00313 /*     ERR_BNDS_NORM and ERR_BNDS_COMP may no longer be trustworthy. */
00314 
00315 /*     RTHRESH        (input) REAL */
00316 /*     Determines when to stop refinement if the error estimate stops */
00317 /*     decreasing. Refinement will stop when the next solution no longer */
00318 /*     satisfies norm(dx_{i+1}) < RTHRESH * norm(dx_i) where norm(Z) is */
00319 /*     the infinity norm of Z. RTHRESH satisfies 0 < RTHRESH <= 1. The */
00320 /*     default value is 0.5. For 'aggressive' set to 0.9 to permit */
00321 /*     convergence on extremely ill-conditioned matrices. See LAWN 165 */
00322 /*     for more details. */
00323 
00324 /*     DZ_UB          (input) REAL */
00325 /*     Determines when to start considering componentwise convergence. */
00326 /*     Componentwise convergence is only considered after each component */
00327 /*     of the solution Y is stable, which we definte as the relative */
00328 /*     change in each component being less than DZ_UB. The default value */
00329 /*     is 0.25, requiring the first bit to be stable. See LAWN 165 for */
00330 /*     more details. */
00331 
00332 /*     IGNORE_CWISE   (input) LOGICAL */
00333 /*     If .TRUE. then ignore componentwise convergence. Default value */
00334 /*     is .FALSE.. */
00335 
00336 /*     INFO           (output) INTEGER */
00337 /*       = 0:  Successful exit. */
00338 /*       < 0:  if INFO = -i, the ith argument to CGETRS had an illegal */
00339 /*             value */
00340 
00341 /*  ===================================================================== */
00342 
00343 /*     .. Local Scalars .. */
00344 /*     .. */
00345 /*     .. Parameters .. */
00346 /*     .. */
00347 /*     .. External Subroutines .. */
00348 /*     .. */
00349 /*     .. Intrinsic Functions .. */
00350 /*     .. */
00351 /*     .. Statement Functions .. */
00352 /*     .. */
00353 /*     .. Statement Function Definitions .. */
00354 /*     .. */
00355 /*     .. Executable Statements .. */
00356 
00357     /* Parameter adjustments */
00358     errs_c_dim1 = *nrhs;
00359     errs_c_offset = 1 + errs_c_dim1;
00360     errs_c__ -= errs_c_offset;
00361     errs_n_dim1 = *nrhs;
00362     errs_n_offset = 1 + errs_n_dim1;
00363     errs_n__ -= errs_n_offset;
00364     a_dim1 = *lda;
00365     a_offset = 1 + a_dim1;
00366     a -= a_offset;
00367     af_dim1 = *ldaf;
00368     af_offset = 1 + af_dim1;
00369     af -= af_offset;
00370     --ipiv;
00371     --c__;
00372     b_dim1 = *ldb;
00373     b_offset = 1 + b_dim1;
00374     b -= b_offset;
00375     y_dim1 = *ldy;
00376     y_offset = 1 + y_dim1;
00377     y -= y_offset;
00378     --berr_out__;
00379     --res;
00380     --ayb;
00381     --dy;
00382     --y_tail__;
00383 
00384     /* Function Body */
00385     if (*info != 0) {
00386         return 0;
00387     }
00388     chla_transtype__(ch__1, (ftnlen)1, trans_type__);
00389     *(unsigned char *)trans = *(unsigned char *)&ch__1[0];
00390     eps = slamch_("Epsilon");
00391     hugeval = slamch_("Overflow");
00392 /*     Force HUGEVAL to Inf */
00393     hugeval *= hugeval;
00394 /*     Using HUGEVAL may lead to spurious underflows. */
00395     incr_thresh__ = (real) (*n) * eps;
00396 
00397     i__1 = *nrhs;
00398     for (j = 1; j <= i__1; ++j) {
00399         y_prec_state__ = 1;
00400         if (y_prec_state__ == 2) {
00401             i__2 = *n;
00402             for (i__ = 1; i__ <= i__2; ++i__) {
00403                 i__3 = i__;
00404                 y_tail__[i__3].r = 0.f, y_tail__[i__3].i = 0.f;
00405             }
00406         }
00407         dxrat = 0.f;
00408         dxratmax = 0.f;
00409         dzrat = 0.f;
00410         dzratmax = 0.f;
00411         final_dx_x__ = hugeval;
00412         final_dz_z__ = hugeval;
00413         prevnormdx = hugeval;
00414         prev_dz_z__ = hugeval;
00415         dz_z__ = hugeval;
00416         dx_x__ = hugeval;
00417         x_state__ = 1;
00418         z_state__ = 0;
00419         incr_prec__ = FALSE_;
00420         i__2 = *ithresh;
00421         for (cnt = 1; cnt <= i__2; ++cnt) {
00422 
00423 /*         Compute residual RES = B_s - op(A_s) * Y, */
00424 /*             op(A) = A, A**T, or A**H depending on TRANS (and type). */
00425 
00426             ccopy_(n, &b[j * b_dim1 + 1], &c__1, &res[1], &c__1);
00427             if (y_prec_state__ == 0) {
00428                 cgemv_(trans, n, n, &c_b6, &a[a_offset], lda, &y[j * y_dim1 + 
00429                         1], &c__1, &c_b8, &res[1], &c__1);
00430             } else if (y_prec_state__ == 1) {
00431                 blas_cgemv_x__(trans_type__, n, n, &c_b6, &a[a_offset], lda, &
00432                         y[j * y_dim1 + 1], &c__1, &c_b8, &res[1], &c__1, 
00433                         prec_type__);
00434             } else {
00435                 blas_cgemv2_x__(trans_type__, n, n, &c_b6, &a[a_offset], lda, 
00436                         &y[j * y_dim1 + 1], &y_tail__[1], &c__1, &c_b8, &res[
00437                         1], &c__1, prec_type__);
00438             }
00439 /*         XXX: RES is no longer needed. */
00440             ccopy_(n, &res[1], &c__1, &dy[1], &c__1);
00441             cgetrs_(trans, n, &c__1, &af[af_offset], ldaf, &ipiv[1], &dy[1], 
00442                     n, info);
00443 
00444 /*         Calculate relative changes DX_X, DZ_Z and ratios DXRAT, DZRAT. */
00445 
00446             normx = 0.f;
00447             normy = 0.f;
00448             normdx = 0.f;
00449             dz_z__ = 0.f;
00450             ymin = hugeval;
00451 
00452             i__3 = *n;
00453             for (i__ = 1; i__ <= i__3; ++i__) {
00454                 i__4 = i__ + j * y_dim1;
00455                 yk = (r__1 = y[i__4].r, dabs(r__1)) + (r__2 = r_imag(&y[i__ + 
00456                         j * y_dim1]), dabs(r__2));
00457                 i__4 = i__;
00458                 dyk = (r__1 = dy[i__4].r, dabs(r__1)) + (r__2 = r_imag(&dy[
00459                         i__]), dabs(r__2));
00460                 if (yk != 0.f) {
00461 /* Computing MAX */
00462                     r__1 = dz_z__, r__2 = dyk / yk;
00463                     dz_z__ = dmax(r__1,r__2);
00464                 } else if (dyk != 0.f) {
00465                     dz_z__ = hugeval;
00466                 }
00467                 ymin = dmin(ymin,yk);
00468                 normy = dmax(normy,yk);
00469                 if (*colequ) {
00470 /* Computing MAX */
00471                     r__1 = normx, r__2 = yk * c__[i__];
00472                     normx = dmax(r__1,r__2);
00473 /* Computing MAX */
00474                     r__1 = normdx, r__2 = dyk * c__[i__];
00475                     normdx = dmax(r__1,r__2);
00476                 } else {
00477                     normx = normy;
00478                     normdx = dmax(normdx,dyk);
00479                 }
00480             }
00481             if (normx != 0.f) {
00482                 dx_x__ = normdx / normx;
00483             } else if (normdx == 0.f) {
00484                 dx_x__ = 0.f;
00485             } else {
00486                 dx_x__ = hugeval;
00487             }
00488             dxrat = normdx / prevnormdx;
00489             dzrat = dz_z__ / prev_dz_z__;
00490 
00491 /*         Check termination criteria */
00492 
00493             if (! (*ignore_cwise__) && ymin * *rcond < incr_thresh__ * normy 
00494                     && y_prec_state__ < 2) {
00495                 incr_prec__ = TRUE_;
00496             }
00497             if (x_state__ == 3 && dxrat <= *rthresh) {
00498                 x_state__ = 1;
00499             }
00500             if (x_state__ == 1) {
00501                 if (dx_x__ <= eps) {
00502                     x_state__ = 2;
00503                 } else if (dxrat > *rthresh) {
00504                     if (y_prec_state__ != 2) {
00505                         incr_prec__ = TRUE_;
00506                     } else {
00507                         x_state__ = 3;
00508                     }
00509                 } else {
00510                     if (dxrat > dxratmax) {
00511                         dxratmax = dxrat;
00512                     }
00513                 }
00514                 if (x_state__ > 1) {
00515                     final_dx_x__ = dx_x__;
00516                 }
00517             }
00518             if (z_state__ == 0 && dz_z__ <= *dz_ub__) {
00519                 z_state__ = 1;
00520             }
00521             if (z_state__ == 3 && dzrat <= *rthresh) {
00522                 z_state__ = 1;
00523             }
00524             if (z_state__ == 1) {
00525                 if (dz_z__ <= eps) {
00526                     z_state__ = 2;
00527                 } else if (dz_z__ > *dz_ub__) {
00528                     z_state__ = 0;
00529                     dzratmax = 0.f;
00530                     final_dz_z__ = hugeval;
00531                 } else if (dzrat > *rthresh) {
00532                     if (y_prec_state__ != 2) {
00533                         incr_prec__ = TRUE_;
00534                     } else {
00535                         z_state__ = 3;
00536                     }
00537                 } else {
00538                     if (dzrat > dzratmax) {
00539                         dzratmax = dzrat;
00540                     }
00541                 }
00542                 if (z_state__ > 1) {
00543                     final_dz_z__ = dz_z__;
00544                 }
00545             }
00546 
00547 /*           Exit if both normwise and componentwise stopped working, */
00548 /*           but if componentwise is unstable, let it go at least two */
00549 /*           iterations. */
00550 
00551             if (x_state__ != 1) {
00552                 if (*ignore_cwise__) {
00553                     goto L666;
00554                 }
00555                 if (z_state__ == 3 || z_state__ == 2) {
00556                     goto L666;
00557                 }
00558                 if (z_state__ == 0 && cnt > 1) {
00559                     goto L666;
00560                 }
00561             }
00562             if (incr_prec__) {
00563                 incr_prec__ = FALSE_;
00564                 ++y_prec_state__;
00565                 i__3 = *n;
00566                 for (i__ = 1; i__ <= i__3; ++i__) {
00567                     i__4 = i__;
00568                     y_tail__[i__4].r = 0.f, y_tail__[i__4].i = 0.f;
00569                 }
00570             }
00571             prevnormdx = normdx;
00572             prev_dz_z__ = dz_z__;
00573 
00574 /*           Update soluton. */
00575 
00576             if (y_prec_state__ < 2) {
00577                 caxpy_(n, &c_b8, &dy[1], &c__1, &y[j * y_dim1 + 1], &c__1);
00578             } else {
00579                 cla_wwaddw__(n, &y[j * y_dim1 + 1], &y_tail__[1], &dy[1]);
00580             }
00581         }
00582 /*        Target of "IF (Z_STOP .AND. X_STOP)".  Sun's f77 won't EXIT. */
00583 L666:
00584 
00585 /*     Set final_* when cnt hits ithresh */
00586 
00587         if (x_state__ == 1) {
00588             final_dx_x__ = dx_x__;
00589         }
00590         if (z_state__ == 1) {
00591             final_dz_z__ = dz_z__;
00592         }
00593 
00594 /*     Compute error bounds */
00595 
00596         if (*n_norms__ >= 1) {
00597             errs_n__[j + (errs_n_dim1 << 1)] = final_dx_x__ / (1 - dxratmax);
00598         }
00599         if (*n_norms__ >= 2) {
00600             errs_c__[j + (errs_c_dim1 << 1)] = final_dz_z__ / (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         ccopy_(n, &b[j * b_dim1 + 1], &c__1, &res[1], &c__1);
00612         cgemv_(trans, n, n, &c_b6, &a[a_offset], lda, &y[j * y_dim1 + 1], &
00613                 c__1, &c_b8, &res[1], &c__1);
00614         i__2 = *n;
00615         for (i__ = 1; i__ <= i__2; ++i__) {
00616             i__3 = i__ + j * b_dim1;
00617             ayb[i__] = (r__1 = b[i__3].r, dabs(r__1)) + (r__2 = r_imag(&b[i__ 
00618                     + j * b_dim1]), dabs(r__2));
00619         }
00620 
00621 /*     Compute abs(op(A_s))*abs(Y) + abs(B_s). */
00622 
00623         cla_geamv__(trans_type__, n, n, &c_b31, &a[a_offset], lda, &y[j * 
00624                 y_dim1 + 1], &c__1, &c_b31, &ayb[1], &c__1);
00625         cla_lin_berr__(n, n, &c__1, &res[1], &ayb[1], &berr_out__[j]);
00626 
00627 /*     End of loop for each RHS. */
00628 
00629     }
00630 
00631     return 0;
00632 } /* cla_gerfsx_extended__ */


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