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


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:56:09