zla_porfsx_extended.c
Go to the documentation of this file.
00001 /* zla_porfsx_extended.f -- translated by f2c (version 20061008).
00002    You must link the resulting object file with libf2c:
00003         on Microsoft Windows system, link with libf2c.lib;
00004         on Linux or Unix systems, link with .../path/to/libf2c.a -lm
00005         or, if you install libf2c.a in a standard place, with -lf2c -lm
00006         -- in that order, at the end of the command line, as in
00007                 cc *.o -lf2c -lm
00008         Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
00009 
00010                 http://www.netlib.org/f2c/libf2c.zip
00011 */
00012 
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015 
00016 /* Table of constant values */
00017 
00018 static integer c__1 = 1;
00019 static doublecomplex c_b11 = {-1.,0.};
00020 static doublecomplex c_b12 = {1.,0.};
00021 static doublereal c_b33 = 1.;
00022 
00023 /* Subroutine */ int zla_porfsx_extended__(integer *prec_type__, char *uplo, 
00024         integer *n, integer *nrhs, doublecomplex *a, integer *lda, 
00025         doublecomplex *af, integer *ldaf, logical *colequ, doublereal *c__, 
00026         doublecomplex *b, integer *ldb, doublecomplex *y, integer *ldy, 
00027         doublereal *berr_out__, integer *n_norms__, doublereal *
00028         err_bnds_norm__, doublereal *err_bnds_comp__, doublecomplex *res, 
00029         doublereal *ayb, doublecomplex *dy, doublecomplex *y_tail__, 
00030         doublereal *rcond, integer *ithresh, doublereal *rthresh, doublereal *
00031         dz_ub__, logical *ignore_cwise__, integer *info, ftnlen uplo_len)
00032 {
00033     /* System generated locals */
00034     integer a_dim1, a_offset, af_dim1, af_offset, b_dim1, b_offset, y_dim1, 
00035             y_offset, err_bnds_norm_dim1, err_bnds_norm_offset, 
00036             err_bnds_comp_dim1, err_bnds_comp_offset, i__1, i__2, i__3, i__4;
00037     doublereal d__1, d__2;
00038 
00039     /* Builtin functions */
00040     double d_imag(doublecomplex *);
00041 
00042     /* Local variables */
00043     doublereal dxratmax, dzratmax;
00044     integer i__, j;
00045     logical incr_prec__;
00046     extern /* Subroutine */ int zla_heamv__(integer *, integer *, doublereal *
00047             , doublecomplex *, integer *, doublecomplex *, integer *, 
00048             doublereal *, doublereal *, integer *);
00049     doublereal prev_dz_z__, yk, final_dx_x__, final_dz_z__;
00050     extern /* Subroutine */ int zla_wwaddw__(integer *, doublecomplex *, 
00051             doublecomplex *, doublecomplex *);
00052     doublereal prevnormdx;
00053     integer cnt;
00054     doublereal dyk, eps, incr_thresh__, dx_x__, dz_z__, ymin;
00055     extern /* Subroutine */ int zla_lin_berr__(integer *, integer *, integer *
00056             , doublecomplex *, doublereal *, doublereal *);
00057     integer y_prec_state__;
00058     extern /* Subroutine */ int blas_zhemv_x__(integer *, integer *, 
00059             doublecomplex *, doublecomplex *, integer *, doublecomplex *, 
00060             integer *, doublecomplex *, doublecomplex *, integer *, integer *)
00061             ;
00062     integer uplo2;
00063     extern logical lsame_(char *, char *);
00064     extern /* Subroutine */ int blas_zhemv2_x__(integer *, integer *, 
00065             doublecomplex *, doublecomplex *, integer *, doublecomplex *, 
00066             doublecomplex *, integer *, doublecomplex *, doublecomplex *, 
00067             integer *, integer *);
00068     doublereal dxrat, dzrat;
00069     extern /* Subroutine */ int zhemv_(char *, integer *, doublecomplex *, 
00070             doublecomplex *, integer *, doublecomplex *, integer *, 
00071             doublecomplex *, doublecomplex *, integer *);
00072     doublereal normx, normy;
00073     extern /* Subroutine */ int zcopy_(integer *, doublecomplex *, integer *, 
00074             doublecomplex *, integer *), zaxpy_(integer *, doublecomplex *, 
00075             doublecomplex *, integer *, doublecomplex *, integer *);
00076     extern doublereal dlamch_(char *);
00077     doublereal normdx;
00078     extern /* Subroutine */ int zpotrs_(char *, integer *, integer *, 
00079             doublecomplex *, integer *, doublecomplex *, integer *, integer *);
00080     doublereal hugeval;
00081     extern integer ilauplo_(char *);
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_PORFSX_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 ZPORFSX 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 /*     UPLO    (input) CHARACTER*1 */
00124 /*       = 'U':  Upper triangle of A is stored; */
00125 /*       = 'L':  Lower triangle of A is stored. */
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*16 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*16 array, dimension (LDAF,N) */
00142 /*     The triangular factor U or L from the Cholesky factorization */
00143 /*     A = U**T*U or A = L*L**T, as computed by ZPOTRF. */
00144 
00145 /*     LDAF           (input) INTEGER */
00146 /*     The leading dimension of the array AF.  LDAF >= max(1,N). */
00147 
00148 /*     COLEQU         (input) LOGICAL */
00149 /*     If .TRUE. then column equilibration was done to A before calling */
00150 /*     this routine. This is needed to compute the solution and error */
00151 /*     bounds correctly. */
00152 
00153 /*     C              (input) DOUBLE PRECISION array, dimension (N) */
00154 /*     The column scale factors for A. If COLEQU = .FALSE., C */
00155 /*     is not accessed. If C is input, each element of C should be a power */
00156 /*     of the radix to ensure a reliable solution and error estimates. */
00157 /*     Scaling by powers of the radix does not cause rounding errors unless */
00158 /*     the result underflows or overflows. Rounding errors during scaling */
00159 /*     lead to refining with a matrix that is not equivalent to the */
00160 /*     input matrix, producing error estimates that may not be */
00161 /*     reliable. */
00162 
00163 /*     B              (input) COMPLEX*16 array, dimension (LDB,NRHS) */
00164 /*     The right-hand-side matrix B. */
00165 
00166 /*     LDB            (input) INTEGER */
00167 /*     The leading dimension of the array B.  LDB >= max(1,N). */
00168 
00169 /*     Y              (input/output) COMPLEX*16 array, dimension */
00170 /*                    (LDY,NRHS) */
00171 /*     On entry, the solution matrix X, as computed by ZPOTRS. */
00172 /*     On exit, the improved solution matrix Y. */
00173 
00174 /*     LDY            (input) INTEGER */
00175 /*     The leading dimension of the array Y.  LDY >= max(1,N). */
00176 
00177 /*     BERR_OUT       (output) DOUBLE PRECISION array, dimension (NRHS) */
00178 /*     On exit, BERR_OUT(j) contains the componentwise relative backward */
00179 /*     error for right-hand-side j from the formula */
00180 /*         max(i) ( abs(RES(i)) / ( abs(op(A_s))*abs(Y) + abs(B_s) )(i) ) */
00181 /*     where abs(Z) is the componentwise absolute value of the matrix */
00182 /*     or vector Z. This is computed by ZLA_LIN_BERR. */
00183 
00184 /*     N_NORMS        (input) INTEGER */
00185 /*     Determines which error bounds to return (see ERR_BNDS_NORM */
00186 /*     and ERR_BNDS_COMP). */
00187 /*     If N_NORMS >= 1 return normwise error bounds. */
00188 /*     If N_NORMS >= 2 return componentwise error bounds. */
00189 
00190 /*     ERR_BNDS_NORM  (input/output) DOUBLE PRECISION array, dimension */
00191 /*                    (NRHS, N_ERR_BNDS) */
00192 /*     For each right-hand side, this array contains information about */
00193 /*     various error bounds and condition numbers corresponding to the */
00194 /*     normwise relative error, which is defined as follows: */
00195 
00196 /*     Normwise relative error in the ith solution vector: */
00197 /*             max_j (abs(XTRUE(j,i) - X(j,i))) */
00198 /*            ------------------------------ */
00199 /*                  max_j abs(X(j,i)) */
00200 
00201 /*     The array is indexed by the type of error information as described */
00202 /*     below. There currently are up to three pieces of information */
00203 /*     returned. */
00204 
00205 /*     The first index in ERR_BNDS_NORM(i,:) corresponds to the ith */
00206 /*     right-hand side. */
00207 
00208 /*     The second index in ERR_BNDS_NORM(:,err) contains the following */
00209 /*     three fields: */
00210 /*     err = 1 "Trust/don't trust" boolean. Trust the answer if the */
00211 /*              reciprocal condition number is less than the threshold */
00212 /*              sqrt(n) * slamch('Epsilon'). */
00213 
00214 /*     err = 2 "Guaranteed" error bound: The estimated forward error, */
00215 /*              almost certainly within a factor of 10 of the true error */
00216 /*              so long as the next entry is greater than the threshold */
00217 /*              sqrt(n) * slamch('Epsilon'). This error bound should only */
00218 /*              be trusted if the previous boolean is true. */
00219 
00220 /*     err = 3  Reciprocal condition number: Estimated normwise */
00221 /*              reciprocal condition number.  Compared with the threshold */
00222 /*              sqrt(n) * slamch('Epsilon') to determine if the error */
00223 /*              estimate is "guaranteed". These reciprocal condition */
00224 /*              numbers are 1 / (norm(Z^{-1},inf) * norm(Z,inf)) for some */
00225 /*              appropriately scaled matrix Z. */
00226 /*              Let Z = S*A, where S scales each row by a power of the */
00227 /*              radix so all absolute row sums of Z are approximately 1. */
00228 
00229 /*     This subroutine is only responsible for setting the second field */
00230 /*     above. */
00231 /*     See Lapack Working Note 165 for further details and extra */
00232 /*     cautions. */
00233 
00234 /*     ERR_BNDS_COMP  (input/output) DOUBLE PRECISION array, dimension */
00235 /*                    (NRHS, N_ERR_BNDS) */
00236 /*     For each right-hand side, this array contains information about */
00237 /*     various error bounds and condition numbers corresponding to the */
00238 /*     componentwise relative error, which is defined as follows: */
00239 
00240 /*     Componentwise relative error in the ith solution vector: */
00241 /*                    abs(XTRUE(j,i) - X(j,i)) */
00242 /*             max_j ---------------------- */
00243 /*                         abs(X(j,i)) */
00244 
00245 /*     The array is indexed by the right-hand side i (on which the */
00246 /*     componentwise relative error depends), and the type of error */
00247 /*     information as described below. There currently are up to three */
00248 /*     pieces of information returned for each right-hand side. If */
00249 /*     componentwise accuracy is not requested (PARAMS(3) = 0.0), then */
00250 /*     ERR_BNDS_COMP is not accessed.  If N_ERR_BNDS .LT. 3, then at most */
00251 /*     the first (:,N_ERR_BNDS) entries are returned. */
00252 
00253 /*     The first index in ERR_BNDS_COMP(i,:) corresponds to the ith */
00254 /*     right-hand side. */
00255 
00256 /*     The second index in ERR_BNDS_COMP(:,err) contains the following */
00257 /*     three fields: */
00258 /*     err = 1 "Trust/don't trust" boolean. Trust the answer if the */
00259 /*              reciprocal condition number is less than the threshold */
00260 /*              sqrt(n) * slamch('Epsilon'). */
00261 
00262 /*     err = 2 "Guaranteed" error bound: The estimated forward error, */
00263 /*              almost certainly within a factor of 10 of the true error */
00264 /*              so long as the next entry is greater than the threshold */
00265 /*              sqrt(n) * slamch('Epsilon'). This error bound should only */
00266 /*              be trusted if the previous boolean is true. */
00267 
00268 /*     err = 3  Reciprocal condition number: Estimated componentwise */
00269 /*              reciprocal condition number.  Compared with the threshold */
00270 /*              sqrt(n) * slamch('Epsilon') to determine if the error */
00271 /*              estimate is "guaranteed". These reciprocal condition */
00272 /*              numbers are 1 / (norm(Z^{-1},inf) * norm(Z,inf)) for some */
00273 /*              appropriately scaled matrix Z. */
00274 /*              Let Z = S*(A*diag(x)), where x is the solution for the */
00275 /*              current right-hand side and S scales each row of */
00276 /*              A*diag(x) by a power of the radix so all absolute row */
00277 /*              sums of Z are approximately 1. */
00278 
00279 /*     This subroutine is only responsible for setting the second field */
00280 /*     above. */
00281 /*     See Lapack Working Note 165 for further details and extra */
00282 /*     cautions. */
00283 
00284 /*     RES            (input) COMPLEX*16 array, dimension (N) */
00285 /*     Workspace to hold the intermediate residual. */
00286 
00287 /*     AYB            (input) DOUBLE PRECISION array, dimension (N) */
00288 /*     Workspace. */
00289 
00290 /*     DY             (input) COMPLEX*16 PRECISION array, dimension (N) */
00291 /*     Workspace to hold the intermediate solution. */
00292 
00293 /*     Y_TAIL         (input) COMPLEX*16 array, dimension (N) */
00294 /*     Workspace to hold the trailing bits of the intermediate solution. */
00295 
00296 /*     RCOND          (input) DOUBLE PRECISION */
00297 /*     Reciprocal scaled condition number.  This is an estimate of the */
00298 /*     reciprocal Skeel condition number of the matrix A after */
00299 /*     equilibration (if done).  If this is less than the machine */
00300 /*     precision (in particular, if it is zero), the matrix is singular */
00301 /*     to working precision.  Note that the error may still be small even */
00302 /*     if this number is very small and the matrix appears ill- */
00303 /*     conditioned. */
00304 
00305 /*     ITHRESH        (input) INTEGER */
00306 /*     The maximum number of residual computations allowed for */
00307 /*     refinement. The default is 10. For 'aggressive' set to 100 to */
00308 /*     permit convergence using approximate factorizations or */
00309 /*     factorizations other than LU. If the factorization uses a */
00310 /*     technique other than Gaussian elimination, the guarantees in */
00311 /*     ERR_BNDS_NORM and ERR_BNDS_COMP may no longer be trustworthy. */
00312 
00313 /*     RTHRESH        (input) DOUBLE PRECISION */
00314 /*     Determines when to stop refinement if the error estimate stops */
00315 /*     decreasing. Refinement will stop when the next solution no longer */
00316 /*     satisfies norm(dx_{i+1}) < RTHRESH * norm(dx_i) where norm(Z) is */
00317 /*     the infinity norm of Z. RTHRESH satisfies 0 < RTHRESH <= 1. The */
00318 /*     default value is 0.5. For 'aggressive' set to 0.9 to permit */
00319 /*     convergence on extremely ill-conditioned matrices. See LAWN 165 */
00320 /*     for more details. */
00321 
00322 /*     DZ_UB          (input) DOUBLE PRECISION */
00323 /*     Determines when to start considering componentwise convergence. */
00324 /*     Componentwise convergence is only considered after each component */
00325 /*     of the solution Y is stable, which we definte as the relative */
00326 /*     change in each component being less than DZ_UB. The default value */
00327 /*     is 0.25, requiring the first bit to be stable. See LAWN 165 for */
00328 /*     more details. */
00329 
00330 /*     IGNORE_CWISE   (input) LOGICAL */
00331 /*     If .TRUE. then ignore componentwise convergence. Default value */
00332 /*     is .FALSE.. */
00333 
00334 /*     INFO           (output) INTEGER */
00335 /*       = 0:  Successful exit. */
00336 /*       < 0:  if INFO = -i, the ith argument to ZPOTRS had an illegal */
00337 /*             value */
00338 
00339 /*  ===================================================================== */
00340 
00341 /*     .. Local Scalars .. */
00342 /*     .. */
00343 /*     .. Parameters .. */
00344 /*     .. */
00345 /*     .. External Functions .. */
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     err_bnds_comp_dim1 = *nrhs;
00359     err_bnds_comp_offset = 1 + err_bnds_comp_dim1;
00360     err_bnds_comp__ -= err_bnds_comp_offset;
00361     err_bnds_norm_dim1 = *nrhs;
00362     err_bnds_norm_offset = 1 + err_bnds_norm_dim1;
00363     err_bnds_norm__ -= err_bnds_norm_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     --c__;
00371     b_dim1 = *ldb;
00372     b_offset = 1 + b_dim1;
00373     b -= b_offset;
00374     y_dim1 = *ldy;
00375     y_offset = 1 + y_dim1;
00376     y -= y_offset;
00377     --berr_out__;
00378     --res;
00379     --ayb;
00380     --dy;
00381     --y_tail__;
00382 
00383     /* Function Body */
00384     if (*info != 0) {
00385         return 0;
00386     }
00387     eps = dlamch_("Epsilon");
00388     hugeval = dlamch_("Overflow");
00389 /*     Force HUGEVAL to Inf */
00390     hugeval *= hugeval;
00391 /*     Using HUGEVAL may lead to spurious underflows. */
00392     incr_thresh__ = (doublereal) (*n) * eps;
00393     if (lsame_(uplo, "L")) {
00394         uplo2 = ilauplo_("L");
00395     } else {
00396         uplo2 = ilauplo_("U");
00397     }
00398     i__1 = *nrhs;
00399     for (j = 1; j <= i__1; ++j) {
00400         y_prec_state__ = 1;
00401         if (y_prec_state__ == 2) {
00402             i__2 = *n;
00403             for (i__ = 1; i__ <= i__2; ++i__) {
00404                 i__3 = i__;
00405                 y_tail__[i__3].r = 0., y_tail__[i__3].i = 0.;
00406             }
00407         }
00408         dxrat = 0.;
00409         dxratmax = 0.;
00410         dzrat = 0.;
00411         dzratmax = 0.;
00412         final_dx_x__ = hugeval;
00413         final_dz_z__ = hugeval;
00414         prevnormdx = hugeval;
00415         prev_dz_z__ = hugeval;
00416         dz_z__ = hugeval;
00417         dx_x__ = hugeval;
00418         x_state__ = 1;
00419         z_state__ = 0;
00420         incr_prec__ = FALSE_;
00421         i__2 = *ithresh;
00422         for (cnt = 1; cnt <= i__2; ++cnt) {
00423 
00424 /*         Compute residual RES = B_s - op(A_s) * Y, */
00425 /*             op(A) = A, A**T, or A**H depending on TRANS (and type). */
00426 
00427             zcopy_(n, &b[j * b_dim1 + 1], &c__1, &res[1], &c__1);
00428             if (y_prec_state__ == 0) {
00429                 zhemv_(uplo, n, &c_b11, &a[a_offset], lda, &y[j * y_dim1 + 1], 
00430                          &c__1, &c_b12, &res[1], &c__1);
00431             } else if (y_prec_state__ == 1) {
00432                 blas_zhemv_x__(&uplo2, n, &c_b11, &a[a_offset], lda, &y[j * 
00433                         y_dim1 + 1], &c__1, &c_b12, &res[1], &c__1, 
00434                         prec_type__);
00435             } else {
00436                 blas_zhemv2_x__(&uplo2, n, &c_b11, &a[a_offset], lda, &y[j * 
00437                         y_dim1 + 1], &y_tail__[1], &c__1, &c_b12, &res[1], &
00438                         c__1, prec_type__);
00439             }
00440 /*         XXX: RES is no longer needed. */
00441             zcopy_(n, &res[1], &c__1, &dy[1], &c__1);
00442             zpotrs_(uplo, n, nrhs, &af[af_offset], ldaf, &dy[1], n, info);
00443 
00444 /*         Calculate relative changes DX_X, DZ_Z and ratios DXRAT, DZRAT. */
00445 
00446             normx = 0.;
00447             normy = 0.;
00448             normdx = 0.;
00449             dz_z__ = 0.;
00450             ymin = hugeval;
00451             i__3 = *n;
00452             for (i__ = 1; i__ <= i__3; ++i__) {
00453                 i__4 = i__ + j * y_dim1;
00454                 yk = (d__1 = y[i__4].r, abs(d__1)) + (d__2 = d_imag(&y[i__ + 
00455                         j * y_dim1]), abs(d__2));
00456                 i__4 = i__;
00457                 dyk = (d__1 = dy[i__4].r, abs(d__1)) + (d__2 = d_imag(&dy[i__]
00458                         ), abs(d__2));
00459                 if (yk != 0.) {
00460 /* Computing MAX */
00461                     d__1 = dz_z__, d__2 = dyk / yk;
00462                     dz_z__ = max(d__1,d__2);
00463                 } else if (dyk != 0.) {
00464                     dz_z__ = hugeval;
00465                 }
00466                 ymin = min(ymin,yk);
00467                 normy = max(normy,yk);
00468                 if (*colequ) {
00469 /* Computing MAX */
00470                     d__1 = normx, d__2 = yk * c__[i__];
00471                     normx = max(d__1,d__2);
00472 /* Computing MAX */
00473                     d__1 = normdx, d__2 = dyk * c__[i__];
00474                     normdx = max(d__1,d__2);
00475                 } else {
00476                     normx = normy;
00477                     normdx = max(normdx,dyk);
00478                 }
00479             }
00480             if (normx != 0.) {
00481                 dx_x__ = normdx / normx;
00482             } else if (normdx == 0.) {
00483                 dx_x__ = 0.;
00484             } else {
00485                 dx_x__ = hugeval;
00486             }
00487             dxrat = normdx / prevnormdx;
00488             dzrat = dz_z__ / prev_dz_z__;
00489 
00490 /*         Check termination criteria. */
00491 
00492             if (ymin * *rcond < incr_thresh__ * normy && y_prec_state__ < 2) {
00493                 incr_prec__ = TRUE_;
00494             }
00495             if (x_state__ == 3 && dxrat <= *rthresh) {
00496                 x_state__ = 1;
00497             }
00498             if (x_state__ == 1) {
00499                 if (dx_x__ <= eps) {
00500                     x_state__ = 2;
00501                 } else if (dxrat > *rthresh) {
00502                     if (y_prec_state__ != 2) {
00503                         incr_prec__ = TRUE_;
00504                     } else {
00505                         x_state__ = 3;
00506                     }
00507                 } else {
00508                     if (dxrat > dxratmax) {
00509                         dxratmax = dxrat;
00510                     }
00511                 }
00512                 if (x_state__ > 1) {
00513                     final_dx_x__ = dx_x__;
00514                 }
00515             }
00516             if (z_state__ == 0 && dz_z__ <= *dz_ub__) {
00517                 z_state__ = 1;
00518             }
00519             if (z_state__ == 3 && dzrat <= *rthresh) {
00520                 z_state__ = 1;
00521             }
00522             if (z_state__ == 1) {
00523                 if (dz_z__ <= eps) {
00524                     z_state__ = 2;
00525                 } else if (dz_z__ > *dz_ub__) {
00526                     z_state__ = 0;
00527                     dzratmax = 0.;
00528                     final_dz_z__ = hugeval;
00529                 } else if (dzrat > *rthresh) {
00530                     if (y_prec_state__ != 2) {
00531                         incr_prec__ = TRUE_;
00532                     } else {
00533                         z_state__ = 3;
00534                     }
00535                 } else {
00536                     if (dzrat > dzratmax) {
00537                         dzratmax = dzrat;
00538                     }
00539                 }
00540                 if (z_state__ > 1) {
00541                     final_dz_z__ = dz_z__;
00542                 }
00543             }
00544             if (x_state__ != 1 && (*ignore_cwise__ || z_state__ != 1)) {
00545                 goto L666;
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                     i__4 = i__;
00553                     y_tail__[i__4].r = 0., y_tail__[i__4].i = 0.;
00554                 }
00555             }
00556             prevnormdx = normdx;
00557             prev_dz_z__ = dz_z__;
00558 
00559 /*           Update soluton. */
00560 
00561             if (y_prec_state__ < 2) {
00562                 zaxpy_(n, &c_b12, &dy[1], &c__1, &y[j * y_dim1 + 1], &c__1);
00563             } else {
00564                 zla_wwaddw__(n, &y[j * y_dim1 + 1], &y_tail__[1], &dy[1]);
00565             }
00566         }
00567 /*        Target of "IF (Z_STOP .AND. X_STOP)".  Sun's f77 won't EXIT. */
00568 L666:
00569 
00570 /*     Set final_* when cnt hits ithresh. */
00571 
00572         if (x_state__ == 1) {
00573             final_dx_x__ = dx_x__;
00574         }
00575         if (z_state__ == 1) {
00576             final_dz_z__ = dz_z__;
00577         }
00578 
00579 /*     Compute error bounds. */
00580 
00581         if (*n_norms__ >= 1) {
00582             err_bnds_norm__[j + (err_bnds_norm_dim1 << 1)] = final_dx_x__ / (
00583                     1 - dxratmax);
00584         }
00585         if (*n_norms__ >= 2) {
00586             err_bnds_comp__[j + (err_bnds_comp_dim1 << 1)] = final_dz_z__ / (
00587                     1 - dzratmax);
00588         }
00589 
00590 /*     Compute componentwise relative backward error from formula */
00591 /*         max(i) ( abs(R(i)) / ( abs(op(A_s))*abs(Y) + abs(B_s) )(i) ) */
00592 /*     where abs(Z) is the componentwise absolute value of the matrix */
00593 /*     or vector Z. */
00594 
00595 /*        Compute residual RES = B_s - op(A_s) * Y, */
00596 /*            op(A) = A, A**T, or A**H depending on TRANS (and type). */
00597 
00598         zcopy_(n, &b[j * b_dim1 + 1], &c__1, &res[1], &c__1);
00599         zhemv_(uplo, n, &c_b11, &a[a_offset], lda, &y[j * y_dim1 + 1], &c__1, 
00600                 &c_b12, &res[1], &c__1);
00601         i__2 = *n;
00602         for (i__ = 1; i__ <= i__2; ++i__) {
00603             i__3 = i__ + j * b_dim1;
00604             ayb[i__] = (d__1 = b[i__3].r, abs(d__1)) + (d__2 = d_imag(&b[i__ 
00605                     + j * b_dim1]), abs(d__2));
00606         }
00607 
00608 /*     Compute abs(op(A_s))*abs(Y) + abs(B_s). */
00609 
00610         zla_heamv__(&uplo2, n, &c_b33, &a[a_offset], lda, &y[j * y_dim1 + 1], 
00611                 &c__1, &c_b33, &ayb[1], &c__1);
00612         zla_lin_berr__(n, n, &c__1, &res[1], &ayb[1], &berr_out__[j]);
00613 
00614 /*     End of loop for each RHS. */
00615 
00616     }
00617 
00618     return 0;
00619 } /* zla_porfsx_extended__ */


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