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


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