LAPACK 3.3.1
Linear Algebra PACKage

cla_gerfsx_extended.f

Go to the documentation of this file.
00001       SUBROUTINE CLA_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       REAL               RTHRESH, DZ_UB
00024 *     ..
00025 *     .. Array Arguments
00026       INTEGER            IPIV( * )
00027       COMPLEX            A( LDA, * ), AF( LDAF, * ), B( LDB, * ),
00028      $                   Y( LDY, * ), RES( * ), DY( * ), Y_TAIL( * )
00029       REAL               C( * ), AYB( * ), RCOND, BERR_OUT( * ),
00030      $                   ERRS_N( NRHS, * ), ERRS_C( NRHS, * )
00031 *     ..
00032 *
00033 *  Purpose
00034 *  =======
00035 * 
00036 *  CLA_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 CGERFSX 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 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 array, dimension (LDAF,N)
00079 *     The factors L and U from the factorization
00080 *     A = P*L*U as computed by CGETRF.
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 CGETRF; 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) REAL 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 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 array, dimension (LDY,NRHS)
00112 *     On entry, the solution matrix X, as computed by CGETRS.
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) REAL 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 CLA_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) REAL array, dimension (NRHS, N_ERR_BNDS)
00132 *     For each right-hand side, this array contains information about
00133 *     various error bounds and condition numbers corresponding to the
00134 *     normwise relative error, which is defined as follows:
00135 *
00136 *     Normwise relative error in the ith solution vector:
00137 *             max_j (abs(XTRUE(j,i) - X(j,i)))
00138 *            ------------------------------
00139 *                  max_j abs(X(j,i))
00140 *
00141 *     The array is indexed by the type of error information as described
00142 *     below. There currently are up to three pieces of information
00143 *     returned.
00144 *
00145 *     The first index in ERR_BNDS_NORM(i,:) corresponds to the ith
00146 *     right-hand side.
00147 *
00148 *     The second index in ERR_BNDS_NORM(:,err) contains the following
00149 *     three fields:
00150 *     err = 1 "Trust/don't trust" boolean. Trust the answer if the
00151 *              reciprocal condition number is less than the threshold
00152 *              sqrt(n) * slamch('Epsilon').
00153 *
00154 *     err = 2 "Guaranteed" error bound: The estimated forward error,
00155 *              almost certainly within a factor of 10 of the true error
00156 *              so long as the next entry is greater than the threshold
00157 *              sqrt(n) * slamch('Epsilon'). This error bound should only
00158 *              be trusted if the previous boolean is true.
00159 *
00160 *     err = 3  Reciprocal condition number: Estimated normwise
00161 *              reciprocal condition number.  Compared with the threshold
00162 *              sqrt(n) * slamch('Epsilon') to determine if the error
00163 *              estimate is "guaranteed". These reciprocal condition
00164 *              numbers are 1 / (norm(Z^{-1},inf) * norm(Z,inf)) for some
00165 *              appropriately scaled matrix Z.
00166 *              Let Z = S*A, where S scales each row by a power of the
00167 *              radix so all absolute row sums of Z are approximately 1.
00168 *
00169 *     This subroutine is only responsible for setting the second field
00170 *     above.
00171 *     See Lapack Working Note 165 for further details and extra
00172 *     cautions.
00173 *
00174 *     ERR_BNDS_COMP  (input/output) REAL array, dimension (NRHS, N_ERR_BNDS)
00175 *     For each right-hand side, this array contains information about
00176 *     various error bounds and condition numbers corresponding to the
00177 *     componentwise relative error, which is defined as follows:
00178 *
00179 *     Componentwise relative error in the ith solution vector:
00180 *                    abs(XTRUE(j,i) - X(j,i))
00181 *             max_j ----------------------
00182 *                         abs(X(j,i))
00183 *
00184 *     The array is indexed by the right-hand side i (on which the
00185 *     componentwise relative error depends), and the type of error
00186 *     information as described below. There currently are up to three
00187 *     pieces of information returned for each right-hand side. If
00188 *     componentwise accuracy is not requested (PARAMS(3) = 0.0), then
00189 *     ERR_BNDS_COMP is not accessed.  If N_ERR_BNDS .LT. 3, then at most
00190 *     the first (:,N_ERR_BNDS) entries are returned.
00191 *
00192 *     The first index in ERR_BNDS_COMP(i,:) corresponds to the ith
00193 *     right-hand side.
00194 *
00195 *     The second index in ERR_BNDS_COMP(:,err) contains the following
00196 *     three fields:
00197 *     err = 1 "Trust/don't trust" boolean. Trust the answer if the
00198 *              reciprocal condition number is less than the threshold
00199 *              sqrt(n) * slamch('Epsilon').
00200 *
00201 *     err = 2 "Guaranteed" error bound: The estimated forward error,
00202 *              almost certainly within a factor of 10 of the true error
00203 *              so long as the next entry is greater than the threshold
00204 *              sqrt(n) * slamch('Epsilon'). This error bound should only
00205 *              be trusted if the previous boolean is true.
00206 *
00207 *     err = 3  Reciprocal condition number: Estimated componentwise
00208 *              reciprocal condition number.  Compared with the threshold
00209 *              sqrt(n) * slamch('Epsilon') to determine if the error
00210 *              estimate is "guaranteed". These reciprocal condition
00211 *              numbers are 1 / (norm(Z^{-1},inf) * norm(Z,inf)) for some
00212 *              appropriately scaled matrix Z.
00213 *              Let Z = S*(A*diag(x)), where x is the solution for the
00214 *              current right-hand side and S scales each row of
00215 *              A*diag(x) by a power of the radix so all absolute row
00216 *              sums of Z are approximately 1.
00217 *
00218 *     This subroutine is only responsible for setting the second field
00219 *     above.
00220 *     See Lapack Working Note 165 for further details and extra
00221 *     cautions.
00222 *
00223 *     RES            (input) COMPLEX array, dimension (N)
00224 *     Workspace to hold the intermediate residual.
00225 *
00226 *     AYB            (input) REAL array, dimension (N)
00227 *     Workspace.
00228 *
00229 *     DY             (input) COMPLEX array, dimension (N)
00230 *     Workspace to hold the intermediate solution.
00231 *
00232 *     Y_TAIL         (input) COMPLEX array, dimension (N)
00233 *     Workspace to hold the trailing bits of the intermediate solution.
00234 *
00235 *     RCOND          (input) REAL
00236 *     Reciprocal scaled condition number.  This is an estimate of the
00237 *     reciprocal Skeel condition number of the matrix A after
00238 *     equilibration (if done).  If this is less than the machine
00239 *     precision (in particular, if it is zero), the matrix is singular
00240 *     to working precision.  Note that the error may still be small even
00241 *     if this number is very small and the matrix appears ill-
00242 *     conditioned.
00243 *
00244 *     ITHRESH        (input) INTEGER
00245 *     The maximum number of residual computations allowed for
00246 *     refinement. The default is 10. For 'aggressive' set to 100 to
00247 *     permit convergence using approximate factorizations or
00248 *     factorizations other than LU. If the factorization uses a
00249 *     technique other than Gaussian elimination, the guarantees in
00250 *     ERR_BNDS_NORM and ERR_BNDS_COMP may no longer be trustworthy.
00251 *
00252 *     RTHRESH        (input) REAL
00253 *     Determines when to stop refinement if the error estimate stops
00254 *     decreasing. Refinement will stop when the next solution no longer
00255 *     satisfies norm(dx_{i+1}) < RTHRESH * norm(dx_i) where norm(Z) is
00256 *     the infinity norm of Z. RTHRESH satisfies 0 < RTHRESH <= 1. The
00257 *     default value is 0.5. For 'aggressive' set to 0.9 to permit
00258 *     convergence on extremely ill-conditioned matrices. See LAWN 165
00259 *     for more details.
00260 *
00261 *     DZ_UB          (input) REAL
00262 *     Determines when to start considering componentwise convergence.
00263 *     Componentwise convergence is only considered after each component
00264 *     of the solution Y is stable, which we definte as the relative
00265 *     change in each component being less than DZ_UB. The default value
00266 *     is 0.25, requiring the first bit to be stable. See LAWN 165 for
00267 *     more details.
00268 *
00269 *     IGNORE_CWISE   (input) LOGICAL
00270 *     If .TRUE. then ignore componentwise convergence. Default value
00271 *     is .FALSE..
00272 *
00273 *     INFO           (output) INTEGER
00274 *       = 0:  Successful exit.
00275 *       < 0:  if INFO = -i, the ith argument to CGETRS had an illegal
00276 *             value
00277 *
00278 *  =====================================================================
00279 *
00280 *     .. Local Scalars ..
00281       CHARACTER          TRANS
00282       INTEGER            CNT, I, J,  X_STATE, Z_STATE, Y_PREC_STATE
00283       REAL               YK, DYK, YMIN, NORMY, NORMX, NORMDX, DXRAT,
00284      $                   DZRAT, PREVNORMDX, PREV_DZ_Z, DXRATMAX,
00285      $                   DZRATMAX, DX_X, DZ_Z, FINAL_DX_X, FINAL_DZ_Z,
00286      $                   EPS, HUGEVAL, INCR_THRESH
00287       LOGICAL            INCR_PREC
00288       COMPLEX            ZDUM
00289 *     ..
00290 *     .. Parameters ..
00291       INTEGER            UNSTABLE_STATE, WORKING_STATE, CONV_STATE,
00292      $                   NOPROG_STATE, BASE_RESIDUAL, EXTRA_RESIDUAL,
00293      $                   EXTRA_Y
00294       PARAMETER          ( UNSTABLE_STATE = 0, WORKING_STATE = 1,
00295      $                   CONV_STATE = 2,
00296      $                   NOPROG_STATE = 3 )
00297       PARAMETER          ( BASE_RESIDUAL = 0, EXTRA_RESIDUAL = 1,
00298      $                   EXTRA_Y = 2 )
00299       INTEGER            FINAL_NRM_ERR_I, FINAL_CMP_ERR_I, BERR_I
00300       INTEGER            RCOND_I, NRM_RCOND_I, NRM_ERR_I, CMP_RCOND_I
00301       INTEGER            CMP_ERR_I, PIV_GROWTH_I
00302       PARAMETER          ( FINAL_NRM_ERR_I = 1, FINAL_CMP_ERR_I = 2,
00303      $                   BERR_I = 3 )
00304       PARAMETER          ( RCOND_I = 4, NRM_RCOND_I = 5, NRM_ERR_I = 6 )
00305       PARAMETER          ( CMP_RCOND_I = 7, CMP_ERR_I = 8,
00306      $                   PIV_GROWTH_I = 9 )
00307       INTEGER            LA_LINRX_ITREF_I, LA_LINRX_ITHRESH_I,
00308      $                   LA_LINRX_CWISE_I
00309       PARAMETER          ( LA_LINRX_ITREF_I = 1,
00310      $                   LA_LINRX_ITHRESH_I = 2 )
00311       PARAMETER          ( LA_LINRX_CWISE_I = 3 )
00312       INTEGER            LA_LINRX_TRUST_I, LA_LINRX_ERR_I,
00313      $                   LA_LINRX_RCOND_I
00314       PARAMETER          ( LA_LINRX_TRUST_I = 1, LA_LINRX_ERR_I = 2 )
00315       PARAMETER          ( LA_LINRX_RCOND_I = 3 )
00316 *     ..
00317 *     .. External Subroutines ..
00318       EXTERNAL           CAXPY, CCOPY, CGETRS, CGEMV, BLAS_CGEMV_X,
00319      $                   BLAS_CGEMV2_X, CLA_GEAMV, CLA_WWADDW, SLAMCH,
00320      $                   CHLA_TRANSTYPE, CLA_LIN_BERR
00321       REAL               SLAMCH
00322       CHARACTER          CHLA_TRANSTYPE
00323 *     ..
00324 *     .. Intrinsic Functions ..
00325       INTRINSIC          ABS, MAX, MIN
00326 *     ..
00327 *     .. Statement Functions ..
00328       REAL               CABS1
00329 *     ..
00330 *     .. Statement Function Definitions ..
00331       CABS1( ZDUM ) = ABS( REAL( ZDUM ) ) + ABS( AIMAG( ZDUM ) )
00332 *     ..
00333 *     .. Executable Statements ..
00334 *
00335       IF ( INFO.NE.0 ) RETURN
00336       TRANS = CHLA_TRANSTYPE(TRANS_TYPE)
00337       EPS = SLAMCH( 'Epsilon' )
00338       HUGEVAL = SLAMCH( 'Overflow' )
00339 *     Force HUGEVAL to Inf
00340       HUGEVAL = HUGEVAL * HUGEVAL
00341 *     Using HUGEVAL may lead to spurious underflows.
00342       INCR_THRESH = REAL( N ) * EPS
00343 *
00344       DO J = 1, NRHS
00345          Y_PREC_STATE = EXTRA_RESIDUAL
00346          IF ( Y_PREC_STATE .EQ. EXTRA_Y ) THEN
00347             DO I = 1, N
00348                Y_TAIL( I ) = 0.0
00349             END DO
00350          END IF
00351 
00352          DXRAT = 0.0
00353          DXRATMAX = 0.0
00354          DZRAT = 0.0
00355          DZRATMAX = 0.0
00356          FINAL_DX_X = HUGEVAL
00357          FINAL_DZ_Z = HUGEVAL
00358          PREVNORMDX = HUGEVAL
00359          PREV_DZ_Z = HUGEVAL
00360          DZ_Z = HUGEVAL
00361          DX_X = HUGEVAL
00362 
00363          X_STATE = WORKING_STATE
00364          Z_STATE = UNSTABLE_STATE
00365          INCR_PREC = .FALSE.
00366 
00367          DO CNT = 1, ITHRESH
00368 *
00369 *         Compute residual RES = B_s - op(A_s) * Y,
00370 *             op(A) = A, A**T, or A**H depending on TRANS (and type).
00371 *
00372             CALL CCOPY( N, B( 1, J ), 1, RES, 1 )
00373             IF ( Y_PREC_STATE .EQ. BASE_RESIDUAL ) THEN
00374                CALL CGEMV( TRANS, N, N, (-1.0E+0,0.0E+0), A, LDA,
00375      $              Y( 1, J ), 1, (1.0E+0,0.0E+0), RES, 1)
00376             ELSE IF (Y_PREC_STATE .EQ. EXTRA_RESIDUAL) THEN
00377                CALL BLAS_CGEMV_X( TRANS_TYPE, N, N, (-1.0E+0,0.0E+0), A,
00378      $              LDA, Y( 1, J ), 1, (1.0E+0,0.0E+0),
00379      $              RES, 1, PREC_TYPE )
00380             ELSE
00381                CALL BLAS_CGEMV2_X( TRANS_TYPE, N, N, (-1.0E+0,0.0E+0),
00382      $              A, LDA, Y(1, J), Y_TAIL, 1, (1.0E+0,0.0E+0), RES, 1,
00383      $              PREC_TYPE)
00384             END IF
00385 
00386 !         XXX: RES is no longer needed.
00387             CALL CCOPY( N, RES, 1, DY, 1 )
00388             CALL CGETRS( TRANS, N, 1, AF, LDAF, IPIV, DY, N, INFO )
00389 *
00390 *         Calculate relative changes DX_X, DZ_Z and ratios DXRAT, DZRAT.
00391 *
00392             NORMX = 0.0E+0
00393             NORMY = 0.0E+0
00394             NORMDX = 0.0E+0
00395             DZ_Z = 0.0E+0
00396             YMIN = HUGEVAL
00397 *
00398             DO I = 1, N
00399                YK = CABS1( Y( I, J ) )
00400                DYK = CABS1( DY( I ) )
00401 
00402                IF ( YK .NE. 0.0E+0 ) THEN
00403                   DZ_Z = MAX( DZ_Z, DYK / YK )
00404                ELSE IF ( DYK .NE. 0.0 ) THEN
00405                   DZ_Z = HUGEVAL
00406                END IF
00407 
00408                YMIN = MIN( YMIN, YK )
00409 
00410                NORMY = MAX( NORMY, YK )
00411 
00412                IF ( COLEQU ) THEN
00413                   NORMX = MAX( NORMX, YK * C( I ) )
00414                   NORMDX = MAX( NORMDX, DYK * C( I ) )
00415                ELSE
00416                   NORMX = NORMY
00417                   NORMDX = MAX(NORMDX, DYK)
00418                END IF
00419             END DO
00420 
00421             IF ( NORMX .NE. 0.0 ) THEN
00422                DX_X = NORMDX / NORMX
00423             ELSE IF ( NORMDX .EQ. 0.0 ) THEN
00424                DX_X = 0.0
00425             ELSE
00426                DX_X = HUGEVAL
00427             END IF
00428 
00429             DXRAT = NORMDX / PREVNORMDX
00430             DZRAT = DZ_Z / PREV_DZ_Z
00431 *
00432 *         Check termination criteria
00433 *
00434             IF (.NOT.IGNORE_CWISE
00435      $           .AND. YMIN*RCOND .LT. INCR_THRESH*NORMY
00436      $           .AND. Y_PREC_STATE .LT. EXTRA_Y )
00437      $           INCR_PREC = .TRUE.
00438 
00439             IF ( X_STATE .EQ. NOPROG_STATE .AND. DXRAT .LE. RTHRESH )
00440      $           X_STATE = WORKING_STATE
00441             IF ( X_STATE .EQ. WORKING_STATE ) THEN
00442                IF (DX_X .LE. EPS) THEN
00443                   X_STATE = CONV_STATE
00444                ELSE IF ( DXRAT .GT. RTHRESH ) THEN
00445                   IF ( Y_PREC_STATE .NE. EXTRA_Y ) THEN
00446                      INCR_PREC = .TRUE.
00447                   ELSE
00448                      X_STATE = NOPROG_STATE
00449                   END IF
00450                ELSE
00451                   IF ( DXRAT .GT. DXRATMAX ) DXRATMAX = DXRAT
00452                END IF
00453                IF ( X_STATE .GT. WORKING_STATE ) FINAL_DX_X = DX_X
00454             END IF
00455 
00456             IF ( Z_STATE .EQ. UNSTABLE_STATE .AND. DZ_Z .LE. DZ_UB )
00457      $           Z_STATE = WORKING_STATE
00458             IF ( Z_STATE .EQ. NOPROG_STATE .AND. DZRAT .LE. RTHRESH )
00459      $           Z_STATE = WORKING_STATE
00460             IF ( Z_STATE .EQ. WORKING_STATE ) THEN
00461                IF ( DZ_Z .LE. EPS ) THEN
00462                   Z_STATE = CONV_STATE
00463                ELSE IF ( DZ_Z .GT. DZ_UB ) THEN
00464                   Z_STATE = UNSTABLE_STATE
00465                   DZRATMAX = 0.0
00466                   FINAL_DZ_Z = HUGEVAL
00467                ELSE IF ( DZRAT .GT. RTHRESH ) THEN
00468                   IF ( Y_PREC_STATE .NE. EXTRA_Y ) THEN
00469                      INCR_PREC = .TRUE.
00470                   ELSE
00471                      Z_STATE = NOPROG_STATE
00472                   END IF
00473                ELSE
00474                   IF ( DZRAT .GT. DZRATMAX ) DZRATMAX = DZRAT
00475                END IF
00476                IF ( Z_STATE .GT. WORKING_STATE ) FINAL_DZ_Z = DZ_Z
00477             END IF
00478 *
00479 *           Exit if both normwise and componentwise stopped working,
00480 *           but if componentwise is unstable, let it go at least two
00481 *           iterations.
00482 *
00483             IF ( X_STATE.NE.WORKING_STATE ) THEN
00484                IF ( IGNORE_CWISE ) GOTO 666
00485                IF ( Z_STATE.EQ.NOPROG_STATE .OR. Z_STATE.EQ.CONV_STATE )
00486      $              GOTO 666
00487                IF ( Z_STATE.EQ.UNSTABLE_STATE .AND. CNT.GT.1 ) GOTO 666
00488             END IF
00489 
00490             IF ( INCR_PREC ) THEN
00491                INCR_PREC = .FALSE.
00492                Y_PREC_STATE = Y_PREC_STATE + 1
00493                DO I = 1, N
00494                   Y_TAIL( I ) = 0.0
00495                END DO
00496             END IF
00497 
00498             PREVNORMDX = NORMDX
00499             PREV_DZ_Z = DZ_Z
00500 *
00501 *           Update soluton.
00502 *
00503             IF ( Y_PREC_STATE .LT. EXTRA_Y ) THEN
00504                CALL CAXPY( N, (1.0E+0,0.0E+0), DY, 1, Y(1,J), 1 )
00505             ELSE
00506                CALL CLA_WWADDW( N, Y( 1, J ), Y_TAIL, DY )
00507             END IF
00508 
00509          END DO
00510 *        Target of "IF (Z_STOP .AND. X_STOP)".  Sun's f77 won't EXIT.
00511  666     CONTINUE
00512 *
00513 *     Set final_* when cnt hits ithresh
00514 *
00515          IF ( X_STATE .EQ. WORKING_STATE ) FINAL_DX_X = DX_X
00516          IF ( Z_STATE .EQ. WORKING_STATE ) FINAL_DZ_Z = DZ_Z
00517 *
00518 *     Compute error bounds
00519 *
00520          IF (N_NORMS .GE. 1) THEN
00521             ERRS_N( J, LA_LINRX_ERR_I ) = FINAL_DX_X / (1 - DXRATMAX)
00522 
00523          END IF
00524          IF ( N_NORMS .GE. 2 ) THEN
00525             ERRS_C( J, LA_LINRX_ERR_I ) = FINAL_DZ_Z / (1 - DZRATMAX)
00526          END IF
00527 *
00528 *     Compute componentwise relative backward error from formula
00529 *         max(i) ( abs(R(i)) / ( abs(op(A_s))*abs(Y) + abs(B_s) )(i) )
00530 *     where abs(Z) is the componentwise absolute value of the matrix
00531 *     or vector Z.
00532 *
00533 *        Compute residual RES = B_s - op(A_s) * Y,
00534 *            op(A) = A, A**T, or A**H depending on TRANS (and type).
00535 *
00536          CALL CCOPY( N, B( 1, J ), 1, RES, 1 )
00537          CALL CGEMV( TRANS, N, N, (-1.0E+0,0.0E+0), A, LDA, Y(1,J), 1,
00538      $        (1.0E+0,0.0E+0), RES, 1 )
00539 
00540          DO I = 1, N
00541             AYB( I ) = CABS1( B( I, J ) )
00542          END DO
00543 *
00544 *     Compute abs(op(A_s))*abs(Y) + abs(B_s).
00545 *
00546          CALL CLA_GEAMV ( TRANS_TYPE, N, N, 1.0E+0,
00547      $        A, LDA, Y(1, J), 1, 1.0E+0, AYB, 1 )
00548 
00549          CALL CLA_LIN_BERR ( N, N, 1, RES, AYB, BERR_OUT( J ) )
00550 *
00551 *     End of loop for each RHS.
00552 *
00553       END DO
00554 *
00555       RETURN
00556       END
 All Files Functions