LAPACK 3.3.1
Linear Algebra PACKage

zla_gerfsx_extended.f

Go to the documentation of this file.
00001       SUBROUTINE ZLA_GERFSX_EXTENDED( PREC_TYPE, TRANS_TYPE, N, NRHS, A,
00002      $                                LDA, AF, LDAF, IPIV, COLEQU, C, B,
00003      $                                LDB, Y, LDY, BERR_OUT, N_NORMS,
00004      $                                ERRS_N, ERRS_C, RES, AYB, DY,
00005      $                                Y_TAIL, RCOND, ITHRESH, RTHRESH,
00006      $                                DZ_UB, IGNORE_CWISE, INFO )
00007 *
00008 *     -- LAPACK routine (version 3.2.1)                                 --
00009 *     -- Contributed by James Demmel, Deaglan Halligan, Yozo Hida and --
00010 *     -- Jason Riedy of Univ. of California Berkeley.                 --
00011 *     -- April 2009                                                   --
00012 *
00013 *     -- LAPACK is a software package provided by Univ. of Tennessee, --
00014 *     -- Univ. of California Berkeley and NAG Ltd.                    --
00015 *
00016       IMPLICIT NONE
00017 *     ..
00018 *     .. Scalar Arguments ..
00019       INTEGER            INFO, LDA, LDAF, LDB, LDY, N, NRHS, PREC_TYPE,
00020      $                   TRANS_TYPE, N_NORMS
00021       LOGICAL            COLEQU, IGNORE_CWISE
00022       INTEGER            ITHRESH
00023       DOUBLE PRECISION   RTHRESH, DZ_UB
00024 *     ..
00025 *     .. Array Arguments
00026       INTEGER            IPIV( * )
00027       COMPLEX*16         A( LDA, * ), AF( LDAF, * ), B( LDB, * ),
00028      $                   Y( LDY, * ), RES( * ), DY( * ), Y_TAIL( * )
00029       DOUBLE PRECISION   C( * ), AYB( * ), RCOND, BERR_OUT( * ),
00030      $                   ERRS_N( NRHS, * ), ERRS_C( NRHS, * )
00031 *     ..
00032 *
00033 *  Purpose
00034 *  =======
00035 *
00036 *  ZLA_GERFSX_EXTENDED improves the computed solution to a system of
00037 *  linear equations by performing extra-precise iterative refinement
00038 *  and provides error bounds and backward error estimates for the solution.
00039 *  This subroutine is called by ZGERFSX to perform iterative refinement.
00040 *  In addition to normwise error bound, the code provides maximum
00041 *  componentwise error bound if possible. See comments for ERR_BNDS_NORM
00042 *  and ERR_BNDS_COMP for details of the error bounds. Note that this
00043 *  subroutine is only resonsible for setting the second fields of
00044 *  ERR_BNDS_NORM and ERR_BNDS_COMP.
00045 *
00046 *  Arguments
00047 *  =========
00048 *
00049 *     PREC_TYPE      (input) INTEGER
00050 *     Specifies the intermediate precision to be used in refinement.
00051 *     The value is defined by ILAPREC(P) where P is a CHARACTER and
00052 *     P    = 'S':  Single
00053 *          = 'D':  Double
00054 *          = 'I':  Indigenous
00055 *          = 'X', 'E':  Extra
00056 *
00057 *     TRANS_TYPE     (input) INTEGER
00058 *     Specifies the transposition operation on A.
00059 *     The value is defined by ILATRANS(T) where T is a CHARACTER and
00060 *     T    = 'N':  No transpose
00061 *          = 'T':  Transpose
00062 *          = 'C':  Conjugate transpose
00063 *
00064 *     N              (input) INTEGER
00065 *     The number of linear equations, i.e., the order of the
00066 *     matrix A.  N >= 0.
00067 *
00068 *     NRHS           (input) INTEGER
00069 *     The number of right-hand-sides, i.e., the number of columns of the
00070 *     matrix B.
00071 *
00072 *     A              (input) COMPLEX*16 array, dimension (LDA,N)
00073 *     On entry, the N-by-N matrix A.
00074 *
00075 *     LDA            (input) INTEGER
00076 *     The leading dimension of the array A.  LDA >= max(1,N).
00077 *
00078 *     AF             (input) COMPLEX*16 array, dimension (LDAF,N)
00079 *     The factors L and U from the factorization
00080 *     A = P*L*U as computed by ZGETRF.
00081 *
00082 *     LDAF           (input) INTEGER
00083 *     The leading dimension of the array AF.  LDAF >= max(1,N).
00084 *
00085 *     IPIV           (input) INTEGER array, dimension (N)
00086 *     The pivot indices from the factorization A = P*L*U
00087 *     as computed by ZGETRF; row i of the matrix was interchanged
00088 *     with row IPIV(i).
00089 *
00090 *     COLEQU         (input) LOGICAL
00091 *     If .TRUE. then column equilibration was done to A before calling
00092 *     this routine. This is needed to compute the solution and error
00093 *     bounds correctly.
00094 *
00095 *     C              (input) DOUBLE PRECISION array, dimension (N)
00096 *     The column scale factors for A. If COLEQU = .FALSE., C
00097 *     is not accessed. If C is input, each element of C should be a power
00098 *     of the radix to ensure a reliable solution and error estimates.
00099 *     Scaling by powers of the radix does not cause rounding errors unless
00100 *     the result underflows or overflows. Rounding errors during scaling
00101 *     lead to refining with a matrix that is not equivalent to the
00102 *     input matrix, producing error estimates that may not be
00103 *     reliable.
00104 *
00105 *     B              (input) COMPLEX*16 array, dimension (LDB,NRHS)
00106 *     The right-hand-side matrix B.
00107 *
00108 *     LDB            (input) INTEGER
00109 *     The leading dimension of the array B.  LDB >= max(1,N).
00110 *
00111 *     Y              (input/output) COMPLEX*16 array, dimension (LDY,NRHS)
00112 *     On entry, the solution matrix X, as computed by ZGETRS.
00113 *     On exit, the improved solution matrix Y.
00114 *
00115 *     LDY            (input) INTEGER
00116 *     The leading dimension of the array Y.  LDY >= max(1,N).
00117 *
00118 *     BERR_OUT       (output) DOUBLE PRECISION array, dimension (NRHS)
00119 *     On exit, BERR_OUT(j) contains the componentwise relative backward
00120 *     error for right-hand-side j from the formula
00121 *         max(i) ( abs(RES(i)) / ( abs(op(A_s))*abs(Y) + abs(B_s) )(i) )
00122 *     where abs(Z) is the componentwise absolute value of the matrix
00123 *     or vector Z. This is computed by ZLA_LIN_BERR.
00124 *
00125 *     N_NORMS        (input) INTEGER
00126 *     Determines which error bounds to return (see ERR_BNDS_NORM
00127 *     and ERR_BNDS_COMP).
00128 *     If N_NORMS >= 1 return normwise error bounds.
00129 *     If N_NORMS >= 2 return componentwise error bounds.
00130 *
00131 *     ERR_BNDS_NORM  (input/output) DOUBLE PRECISION array, dimension
00132 *                    (NRHS, N_ERR_BNDS)
00133 *     For each right-hand side, this array contains information about
00134 *     various error bounds and condition numbers corresponding to the
00135 *     normwise relative error, which is defined as follows:
00136 *
00137 *     Normwise relative error in the ith solution vector:
00138 *             max_j (abs(XTRUE(j,i) - X(j,i)))
00139 *            ------------------------------
00140 *                  max_j abs(X(j,i))
00141 *
00142 *     The array is indexed by the type of error information as described
00143 *     below. There currently are up to three pieces of information
00144 *     returned.
00145 *
00146 *     The first index in ERR_BNDS_NORM(i,:) corresponds to the ith
00147 *     right-hand side.
00148 *
00149 *     The second index in ERR_BNDS_NORM(:,err) contains the following
00150 *     three fields:
00151 *     err = 1 "Trust/don't trust" boolean. Trust the answer if the
00152 *              reciprocal condition number is less than the threshold
00153 *              sqrt(n) * slamch('Epsilon').
00154 *
00155 *     err = 2 "Guaranteed" error bound: The estimated forward error,
00156 *              almost certainly within a factor of 10 of the true error
00157 *              so long as the next entry is greater than the threshold
00158 *              sqrt(n) * slamch('Epsilon'). This error bound should only
00159 *              be trusted if the previous boolean is true.
00160 *
00161 *     err = 3  Reciprocal condition number: Estimated normwise
00162 *              reciprocal condition number.  Compared with the threshold
00163 *              sqrt(n) * slamch('Epsilon') to determine if the error
00164 *              estimate is "guaranteed". These reciprocal condition
00165 *              numbers are 1 / (norm(Z^{-1},inf) * norm(Z,inf)) for some
00166 *              appropriately scaled matrix Z.
00167 *              Let Z = S*A, where S scales each row by a power of the
00168 *              radix so all absolute row sums of Z are approximately 1.
00169 *
00170 *     This subroutine is only responsible for setting the second field
00171 *     above.
00172 *     See Lapack Working Note 165 for further details and extra
00173 *     cautions.
00174 *
00175 *     ERR_BNDS_COMP  (input/output) DOUBLE PRECISION array, dimension
00176 *                    (NRHS, N_ERR_BNDS)
00177 *     For each right-hand side, this array contains information about
00178 *     various error bounds and condition numbers corresponding to the
00179 *     componentwise relative error, which is defined as follows:
00180 *
00181 *     Componentwise relative error in the ith solution vector:
00182 *                    abs(XTRUE(j,i) - X(j,i))
00183 *             max_j ----------------------
00184 *                         abs(X(j,i))
00185 *
00186 *     The array is indexed by the right-hand side i (on which the
00187 *     componentwise relative error depends), and the type of error
00188 *     information as described below. There currently are up to three
00189 *     pieces of information returned for each right-hand side. If
00190 *     componentwise accuracy is not requested (PARAMS(3) = 0.0), then
00191 *     ERR_BNDS_COMP is not accessed.  If N_ERR_BNDS .LT. 3, then at most
00192 *     the first (:,N_ERR_BNDS) entries are returned.
00193 *
00194 *     The first index in ERR_BNDS_COMP(i,:) corresponds to the ith
00195 *     right-hand side.
00196 *
00197 *     The second index in ERR_BNDS_COMP(:,err) contains the following
00198 *     three fields:
00199 *     err = 1 "Trust/don't trust" boolean. Trust the answer if the
00200 *              reciprocal condition number is less than the threshold
00201 *              sqrt(n) * slamch('Epsilon').
00202 *
00203 *     err = 2 "Guaranteed" error bound: The estimated forward error,
00204 *              almost certainly within a factor of 10 of the true error
00205 *              so long as the next entry is greater than the threshold
00206 *              sqrt(n) * slamch('Epsilon'). This error bound should only
00207 *              be trusted if the previous boolean is true.
00208 *
00209 *     err = 3  Reciprocal condition number: Estimated componentwise
00210 *              reciprocal condition number.  Compared with the threshold
00211 *              sqrt(n) * slamch('Epsilon') to determine if the error
00212 *              estimate is "guaranteed". These reciprocal condition
00213 *              numbers are 1 / (norm(Z^{-1},inf) * norm(Z,inf)) for some
00214 *              appropriately scaled matrix Z.
00215 *              Let Z = S*(A*diag(x)), where x is the solution for the
00216 *              current right-hand side and S scales each row of
00217 *              A*diag(x) by a power of the radix so all absolute row
00218 *              sums of Z are approximately 1.
00219 *
00220 *     This subroutine is only responsible for setting the second field
00221 *     above.
00222 *     See Lapack Working Note 165 for further details and extra
00223 *     cautions.
00224 *
00225 *     RES            (input) COMPLEX*16 array, dimension (N)
00226 *     Workspace to hold the intermediate residual.
00227 *
00228 *     AYB            (input) DOUBLE PRECISION array, dimension (N)
00229 *     Workspace.
00230 *
00231 *     DY             (input) COMPLEX*16 array, dimension (N)
00232 *     Workspace to hold the intermediate solution.
00233 *
00234 *     Y_TAIL         (input) COMPLEX*16 array, dimension (N)
00235 *     Workspace to hold the trailing bits of the intermediate solution.
00236 *
00237 *     RCOND          (input) DOUBLE PRECISION
00238 *     Reciprocal scaled condition number.  This is an estimate of the
00239 *     reciprocal Skeel condition number of the matrix A after
00240 *     equilibration (if done).  If this is less than the machine
00241 *     precision (in particular, if it is zero), the matrix is singular
00242 *     to working precision.  Note that the error may still be small even
00243 *     if this number is very small and the matrix appears ill-
00244 *     conditioned.
00245 *
00246 *     ITHRESH        (input) INTEGER
00247 *     The maximum number of residual computations allowed for
00248 *     refinement. The default is 10. For 'aggressive' set to 100 to
00249 *     permit convergence using approximate factorizations or
00250 *     factorizations other than LU. If the factorization uses a
00251 *     technique other than Gaussian elimination, the guarantees in
00252 *     ERR_BNDS_NORM and ERR_BNDS_COMP may no longer be trustworthy.
00253 *
00254 *     RTHRESH        (input) DOUBLE PRECISION
00255 *     Determines when to stop refinement if the error estimate stops
00256 *     decreasing. Refinement will stop when the next solution no longer
00257 *     satisfies norm(dx_{i+1}) < RTHRESH * norm(dx_i) where norm(Z) is
00258 *     the infinity norm of Z. RTHRESH satisfies 0 < RTHRESH <= 1. The
00259 *     default value is 0.5. For 'aggressive' set to 0.9 to permit
00260 *     convergence on extremely ill-conditioned matrices. See LAWN 165
00261 *     for more details.
00262 *
00263 *     DZ_UB          (input) DOUBLE PRECISION
00264 *     Determines when to start considering componentwise convergence.
00265 *     Componentwise convergence is only considered after each component
00266 *     of the solution Y is stable, which we definte as the relative
00267 *     change in each component being less than DZ_UB. The default value
00268 *     is 0.25, requiring the first bit to be stable. See LAWN 165 for
00269 *     more details.
00270 *
00271 *     IGNORE_CWISE   (input) LOGICAL
00272 *     If .TRUE. then ignore componentwise convergence. Default value
00273 *     is .FALSE..
00274 *
00275 *     INFO           (output) INTEGER
00276 *       = 0:  Successful exit.
00277 *       < 0:  if INFO = -i, the ith argument to ZGETRS had an illegal
00278 *             value
00279 *
00280 *  =====================================================================
00281 *
00282 *     .. Local Scalars ..
00283       CHARACTER          TRANS
00284       INTEGER            CNT, I, J,  X_STATE, Z_STATE, Y_PREC_STATE
00285       DOUBLE PRECISION   YK, DYK, YMIN, NORMY, NORMX, NORMDX, DXRAT,
00286      $                   DZRAT, PREVNORMDX, PREV_DZ_Z, DXRATMAX,
00287      $                   DZRATMAX, DX_X, DZ_Z, FINAL_DX_X, FINAL_DZ_Z,
00288      $                   EPS, HUGEVAL, INCR_THRESH
00289       LOGICAL            INCR_PREC
00290       COMPLEX*16         ZDUM
00291 *     ..
00292 *     .. Parameters ..
00293       INTEGER            UNSTABLE_STATE, WORKING_STATE, CONV_STATE,
00294      $                   NOPROG_STATE, BASE_RESIDUAL, EXTRA_RESIDUAL,
00295      $                   EXTRA_Y
00296       PARAMETER          ( UNSTABLE_STATE = 0, WORKING_STATE = 1,
00297      $                   CONV_STATE = 2,
00298      $                   NOPROG_STATE = 3 )
00299       PARAMETER          ( BASE_RESIDUAL = 0, EXTRA_RESIDUAL = 1,
00300      $                   EXTRA_Y = 2 )
00301       INTEGER            FINAL_NRM_ERR_I, FINAL_CMP_ERR_I, BERR_I
00302       INTEGER            RCOND_I, NRM_RCOND_I, NRM_ERR_I, CMP_RCOND_I
00303       INTEGER            CMP_ERR_I, PIV_GROWTH_I
00304       PARAMETER          ( FINAL_NRM_ERR_I = 1, FINAL_CMP_ERR_I = 2,
00305      $                   BERR_I = 3 )
00306       PARAMETER          ( RCOND_I = 4, NRM_RCOND_I = 5, NRM_ERR_I = 6 )
00307       PARAMETER          ( CMP_RCOND_I = 7, CMP_ERR_I = 8,
00308      $                   PIV_GROWTH_I = 9 )
00309       INTEGER            LA_LINRX_ITREF_I, LA_LINRX_ITHRESH_I,
00310      $                   LA_LINRX_CWISE_I
00311       PARAMETER          ( LA_LINRX_ITREF_I = 1,
00312      $                   LA_LINRX_ITHRESH_I = 2 )
00313       PARAMETER          ( LA_LINRX_CWISE_I = 3 )
00314       INTEGER            LA_LINRX_TRUST_I, LA_LINRX_ERR_I,
00315      $                   LA_LINRX_RCOND_I
00316       PARAMETER          ( LA_LINRX_TRUST_I = 1, LA_LINRX_ERR_I = 2 )
00317       PARAMETER          ( LA_LINRX_RCOND_I = 3 )
00318 *     ..
00319 *     .. External Subroutines ..
00320       EXTERNAL           ZAXPY, ZCOPY, ZGETRS, ZGEMV, BLAS_ZGEMV_X,
00321      $                   BLAS_ZGEMV2_X, ZLA_GEAMV, ZLA_WWADDW, DLAMCH,
00322      $                   CHLA_TRANSTYPE, ZLA_LIN_BERR
00323       DOUBLE PRECISION   DLAMCH
00324       CHARACTER          CHLA_TRANSTYPE
00325 *     ..
00326 *     .. Intrinsic Functions ..
00327       INTRINSIC          ABS, MAX, MIN
00328 *     ..
00329 *     .. Statement Functions ..
00330       DOUBLE PRECISION   CABS1
00331 *     ..
00332 *     .. Statement Function Definitions ..
00333       CABS1( ZDUM ) = ABS( DBLE( ZDUM ) ) + ABS( DIMAG( ZDUM ) )
00334 *     ..
00335 *     .. Executable Statements ..
00336 *
00337       IF ( INFO.NE.0 ) RETURN
00338       TRANS = CHLA_TRANSTYPE(TRANS_TYPE)
00339       EPS = DLAMCH( 'Epsilon' )
00340       HUGEVAL = DLAMCH( 'Overflow' )
00341 *     Force HUGEVAL to Inf
00342       HUGEVAL = HUGEVAL * HUGEVAL
00343 *     Using HUGEVAL may lead to spurious underflows.
00344       INCR_THRESH = DBLE( N ) * EPS
00345 *
00346       DO J = 1, NRHS
00347          Y_PREC_STATE = EXTRA_RESIDUAL
00348          IF ( Y_PREC_STATE .EQ. EXTRA_Y ) THEN
00349             DO I = 1, N
00350                Y_TAIL( I ) = 0.0D+0
00351             END DO
00352          END IF
00353 
00354          DXRAT = 0.0D+0
00355          DXRATMAX = 0.0D+0
00356          DZRAT = 0.0D+0
00357          DZRATMAX = 0.0D+0
00358          FINAL_DX_X = HUGEVAL
00359          FINAL_DZ_Z = HUGEVAL
00360          PREVNORMDX = HUGEVAL
00361          PREV_DZ_Z = HUGEVAL
00362          DZ_Z = HUGEVAL
00363          DX_X = HUGEVAL
00364 
00365          X_STATE = WORKING_STATE
00366          Z_STATE = UNSTABLE_STATE
00367          INCR_PREC = .FALSE.
00368 
00369          DO CNT = 1, ITHRESH
00370 *
00371 *         Compute residual RES = B_s - op(A_s) * Y,
00372 *             op(A) = A, A**T, or A**H depending on TRANS (and type).
00373 *
00374             CALL ZCOPY( N, B( 1, J ), 1, RES, 1 )
00375             IF ( Y_PREC_STATE .EQ. BASE_RESIDUAL ) THEN
00376                CALL ZGEMV( TRANS, N, N, (-1.0D+0,0.0D+0), A, LDA,
00377      $              Y( 1, J ), 1, (1.0D+0,0.0D+0), RES, 1)
00378             ELSE IF (Y_PREC_STATE .EQ. EXTRA_RESIDUAL) THEN
00379                CALL BLAS_ZGEMV_X( TRANS_TYPE, N, N, (-1.0D+0,0.0D+0), A,
00380      $              LDA, Y( 1, J ), 1, (1.0D+0,0.0D+0),
00381      $              RES, 1, PREC_TYPE )
00382             ELSE
00383                CALL BLAS_ZGEMV2_X( TRANS_TYPE, N, N, (-1.0D+0,0.0D+0),
00384      $              A, LDA, Y(1, J), Y_TAIL, 1, (1.0D+0,0.0D+0), RES, 1,
00385      $              PREC_TYPE)
00386             END IF
00387 
00388 !         XXX: RES is no longer needed.
00389             CALL ZCOPY( N, RES, 1, DY, 1 )
00390             CALL ZGETRS( TRANS, N, 1, AF, LDAF, IPIV, DY, N, INFO )
00391 *
00392 *         Calculate relative changes DX_X, DZ_Z and ratios DXRAT, DZRAT.
00393 *
00394             NORMX = 0.0D+0
00395             NORMY = 0.0D+0
00396             NORMDX = 0.0D+0
00397             DZ_Z = 0.0D+0
00398             YMIN = HUGEVAL
00399 *
00400             DO I = 1, N
00401                YK = CABS1( Y( I, J ) )
00402                DYK = CABS1( DY( I ) )
00403 
00404                IF ( YK .NE. 0.0D+0 ) THEN
00405                   DZ_Z = MAX( DZ_Z, DYK / YK )
00406                ELSE IF ( DYK .NE. 0.0D+0 ) THEN
00407                   DZ_Z = HUGEVAL
00408                END IF
00409 
00410                YMIN = MIN( YMIN, YK )
00411 
00412                NORMY = MAX( NORMY, YK )
00413 
00414                IF ( COLEQU ) THEN
00415                   NORMX = MAX( NORMX, YK * C( I ) )
00416                   NORMDX = MAX( NORMDX, DYK * C( I ) )
00417                ELSE
00418                   NORMX = NORMY
00419                   NORMDX = MAX(NORMDX, DYK)
00420                END IF
00421             END DO
00422 
00423             IF ( NORMX .NE. 0.0D+0 ) THEN
00424                DX_X = NORMDX / NORMX
00425             ELSE IF ( NORMDX .EQ. 0.0D+0 ) THEN
00426                DX_X = 0.0D+0
00427             ELSE
00428                DX_X = HUGEVAL
00429             END IF
00430 
00431             DXRAT = NORMDX / PREVNORMDX
00432             DZRAT = DZ_Z / PREV_DZ_Z
00433 *
00434 *         Check termination criteria
00435 *
00436             IF (.NOT.IGNORE_CWISE
00437      $           .AND. YMIN*RCOND .LT. INCR_THRESH*NORMY
00438      $           .AND. Y_PREC_STATE .LT. EXTRA_Y )
00439      $           INCR_PREC = .TRUE.
00440 
00441             IF ( X_STATE .EQ. NOPROG_STATE .AND. DXRAT .LE. RTHRESH )
00442      $           X_STATE = WORKING_STATE
00443             IF ( X_STATE .EQ. WORKING_STATE ) THEN
00444                IF (DX_X .LE. EPS) THEN
00445                   X_STATE = CONV_STATE
00446                ELSE IF ( DXRAT .GT. RTHRESH ) THEN
00447                   IF ( Y_PREC_STATE .NE. EXTRA_Y ) THEN
00448                      INCR_PREC = .TRUE.
00449                   ELSE
00450                      X_STATE = NOPROG_STATE
00451                   END IF
00452                ELSE
00453                   IF ( DXRAT .GT. DXRATMAX ) DXRATMAX = DXRAT
00454                END IF
00455                IF ( X_STATE .GT. WORKING_STATE ) FINAL_DX_X = DX_X
00456             END IF
00457 
00458             IF ( Z_STATE .EQ. UNSTABLE_STATE .AND. DZ_Z .LE. DZ_UB )
00459      $           Z_STATE = WORKING_STATE
00460             IF ( Z_STATE .EQ. NOPROG_STATE .AND. DZRAT .LE. RTHRESH )
00461      $           Z_STATE = WORKING_STATE
00462             IF ( Z_STATE .EQ. WORKING_STATE ) THEN
00463                IF ( DZ_Z .LE. EPS ) THEN
00464                   Z_STATE = CONV_STATE
00465                ELSE IF ( DZ_Z .GT. DZ_UB ) THEN
00466                   Z_STATE = UNSTABLE_STATE
00467                   DZRATMAX = 0.0D+0
00468                   FINAL_DZ_Z = HUGEVAL
00469                ELSE IF ( DZRAT .GT. RTHRESH ) THEN
00470                   IF ( Y_PREC_STATE .NE. EXTRA_Y ) THEN
00471                      INCR_PREC = .TRUE.
00472                   ELSE
00473                      Z_STATE = NOPROG_STATE
00474                   END IF
00475                ELSE
00476                   IF ( DZRAT .GT. DZRATMAX ) DZRATMAX = DZRAT
00477                END IF
00478                IF ( Z_STATE .GT. WORKING_STATE ) FINAL_DZ_Z = DZ_Z
00479             END IF
00480 *
00481 *           Exit if both normwise and componentwise stopped working,
00482 *           but if componentwise is unstable, let it go at least two
00483 *           iterations.
00484 *
00485             IF ( X_STATE.NE.WORKING_STATE ) THEN
00486                IF ( IGNORE_CWISE ) GOTO 666
00487                IF ( Z_STATE.EQ.NOPROG_STATE .OR. Z_STATE.EQ.CONV_STATE )
00488      $              GOTO 666
00489                IF ( Z_STATE.EQ.UNSTABLE_STATE .AND. CNT.GT.1 ) GOTO 666
00490             END IF
00491 
00492             IF ( INCR_PREC ) THEN
00493                INCR_PREC = .FALSE.
00494                Y_PREC_STATE = Y_PREC_STATE + 1
00495                DO I = 1, N
00496                   Y_TAIL( I ) = 0.0D+0
00497                END DO
00498             END IF
00499 
00500             PREVNORMDX = NORMDX
00501             PREV_DZ_Z = DZ_Z
00502 *
00503 *           Update soluton.
00504 *
00505             IF ( Y_PREC_STATE .LT. EXTRA_Y ) THEN
00506                CALL ZAXPY( N, (1.0D+0,0.0D+0), DY, 1, Y(1,J), 1 )
00507             ELSE
00508                CALL ZLA_WWADDW( N, Y( 1, J ), Y_TAIL, DY )
00509             END IF
00510 
00511          END DO
00512 *        Target of "IF (Z_STOP .AND. X_STOP)".  Sun's f77 won't EXIT.
00513  666     CONTINUE
00514 *
00515 *     Set final_* when cnt hits ithresh
00516 *
00517          IF ( X_STATE .EQ. WORKING_STATE ) FINAL_DX_X = DX_X
00518          IF ( Z_STATE .EQ. WORKING_STATE ) FINAL_DZ_Z = DZ_Z
00519 *
00520 *     Compute error bounds
00521 *
00522          IF (N_NORMS .GE. 1) THEN
00523             ERRS_N( J, LA_LINRX_ERR_I ) = FINAL_DX_X / (1 - DXRATMAX)
00524 
00525          END IF
00526          IF ( N_NORMS .GE. 2 ) THEN
00527             ERRS_C( J, LA_LINRX_ERR_I ) = FINAL_DZ_Z / (1 - DZRATMAX)
00528          END IF
00529 *
00530 *     Compute componentwise relative backward error from formula
00531 *         max(i) ( abs(R(i)) / ( abs(op(A_s))*abs(Y) + abs(B_s) )(i) )
00532 *     where abs(Z) is the componentwise absolute value of the matrix
00533 *     or vector Z.
00534 *
00535 *        Compute residual RES = B_s - op(A_s) * Y,
00536 *            op(A) = A, A**T, or A**H depending on TRANS (and type).
00537 *
00538          CALL ZCOPY( N, B( 1, J ), 1, RES, 1 )
00539          CALL ZGEMV( TRANS, N, N, (-1.0D+0,0.0D+0), A, LDA, Y(1,J), 1,
00540      $        (1.0D+0,0.0D+0), RES, 1 )
00541 
00542          DO I = 1, N
00543             AYB( I ) = CABS1( B( I, J ) )
00544          END DO
00545 *
00546 *     Compute abs(op(A_s))*abs(Y) + abs(B_s).
00547 *
00548          CALL ZLA_GEAMV ( TRANS_TYPE, N, N, 1.0D+0,
00549      $        A, LDA, Y(1, J), 1, 1.0D+0, AYB, 1 )
00550 
00551          CALL ZLA_LIN_BERR ( N, N, 1, RES, AYB, BERR_OUT( J ) )
00552 *
00553 *     End of loop for each RHS.
00554 *
00555       END DO
00556 *
00557       RETURN
00558       END
 All Files Functions