LAPACK 3.3.0

sla_gbrfsx_extended.f

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