LAPACK 3.3.0

zla_gbrfsx_extended.f

Go to the documentation of this file.
00001       SUBROUTINE ZLA_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       DOUBLE PRECISION   RTHRESH, DZ_UB
00024 *     ..
00025 *     .. Array Arguments ..
00026       INTEGER            IPIV( * )
00027       COMPLEX*16         AB( LDAB, * ), AFB( LDAFB, * ), B( LDB, * ),
00028      $                   Y( LDY, * ), RES( * ), DY( * ), Y_TAIL( * )
00029       DOUBLE PRECISION   C( * ), AYB(*), RCOND, BERR_OUT( * ),
00030      $                   ERR_BNDS_NORM( NRHS, * ),
00031      $                   ERR_BNDS_COMP( NRHS, * )
00032 *     ..
00033 *
00034 *  Purpose
00035 *  =======
00036 *
00037 *  ZLA_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 ZGBRFSX 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 *     AB             (input) COMPLEX*16 array, dimension (LDA,N)
00080 *     On entry, the N-by-N matrix A.
00081 *
00082 *     LDAB           (input) INTEGER
00083 *     The leading dimension of the array A.  LDA >= max(1,N).
00084 *
00085 *     AFB            (input) COMPLEX*16 array, dimension (LDAF,N)
00086 *     The factors L and U from the factorization
00087 *     A = P*L*U as computed by ZGBTRF.
00088 *
00089 *     LDAFB          (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 ZGBTRF; 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) DOUBLE PRECISION 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) COMPLEX*16 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) COMPLEX*16 array, dimension (LDY,NRHS)
00119 *     On entry, the solution matrix X, as computed by ZGBTRS.
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) DOUBLE PRECISION 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 ZLA_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) DOUBLE PRECISION 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) DOUBLE PRECISION 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) COMPLEX*16 array, dimension (N)
00233 *     Workspace to hold the intermediate residual.
00234 *
00235 *     AYB            (input) DOUBLE PRECISION array, dimension (N)
00236 *     Workspace.
00237 *
00238 *     DY             (input) COMPLEX*16 array, dimension (N)
00239 *     Workspace to hold the intermediate solution.
00240 *
00241 *     Y_TAIL         (input) COMPLEX*16 array, dimension (N)
00242 *     Workspace to hold the trailing bits of the intermediate solution.
00243 *
00244 *     RCOND          (input) DOUBLE PRECISION
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) DOUBLE PRECISION
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) DOUBLE PRECISION
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 ZGBTRS 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       DOUBLE PRECISION   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       COMPLEX*16         ZDUM
00298 *     ..
00299 *     .. Parameters ..
00300       INTEGER            UNSTABLE_STATE, WORKING_STATE, CONV_STATE,
00301      $                   NOPROG_STATE, BASE_RESIDUAL, EXTRA_RESIDUAL,
00302      $                   EXTRA_Y
00303       PARAMETER          ( UNSTABLE_STATE = 0, WORKING_STATE = 1,
00304      $                   CONV_STATE = 2, NOPROG_STATE = 3 )
00305       PARAMETER          ( BASE_RESIDUAL = 0, EXTRA_RESIDUAL = 1,
00306      $                   EXTRA_Y = 2 )
00307       INTEGER            FINAL_NRM_ERR_I, FINAL_CMP_ERR_I, BERR_I
00308       INTEGER            RCOND_I, NRM_RCOND_I, NRM_ERR_I, CMP_RCOND_I
00309       INTEGER            CMP_ERR_I, PIV_GROWTH_I
00310       PARAMETER          ( FINAL_NRM_ERR_I = 1, FINAL_CMP_ERR_I = 2,
00311      $                   BERR_I = 3 )
00312       PARAMETER          ( RCOND_I = 4, NRM_RCOND_I = 5, NRM_ERR_I = 6 )
00313       PARAMETER          ( CMP_RCOND_I = 7, CMP_ERR_I = 8,
00314      $                   PIV_GROWTH_I = 9 )
00315       INTEGER            LA_LINRX_ITREF_I, LA_LINRX_ITHRESH_I,
00316      $                   LA_LINRX_CWISE_I
00317       PARAMETER          ( LA_LINRX_ITREF_I = 1,
00318      $                   LA_LINRX_ITHRESH_I = 2 )
00319       PARAMETER          ( LA_LINRX_CWISE_I = 3 )
00320       INTEGER            LA_LINRX_TRUST_I, LA_LINRX_ERR_I,
00321      $                   LA_LINRX_RCOND_I
00322       PARAMETER          ( LA_LINRX_TRUST_I = 1, LA_LINRX_ERR_I = 2 )
00323       PARAMETER          ( LA_LINRX_RCOND_I = 3 )
00324 *     ..
00325 *     .. External Subroutines ..
00326       EXTERNAL           ZAXPY, ZCOPY, ZGBTRS, ZGBMV, BLAS_ZGBMV_X,
00327      $                   BLAS_ZGBMV2_X, ZLA_GBAMV, ZLA_WWADDW, DLAMCH,
00328      $                   CHLA_TRANSTYPE, ZLA_LIN_BERR
00329       DOUBLE PRECISION   DLAMCH
00330       CHARACTER          CHLA_TRANSTYPE
00331 *     ..
00332 *     .. Intrinsic Functions..
00333       INTRINSIC          ABS, MAX, MIN
00334 *     ..
00335 *     .. Statement Functions ..
00336       DOUBLE PRECISION   CABS1
00337 *     ..
00338 *     .. Statement Function Definitions ..
00339       CABS1( ZDUM ) = ABS( DBLE( ZDUM ) ) + ABS( DIMAG( ZDUM ) )
00340 *     ..
00341 *     .. Executable Statements ..
00342 *
00343       IF (INFO.NE.0) RETURN
00344       TRANS = CHLA_TRANSTYPE(TRANS_TYPE)
00345       EPS = DLAMCH( 'Epsilon' )
00346       HUGEVAL = DLAMCH( 'Overflow' )
00347 *     Force HUGEVAL to Inf
00348       HUGEVAL = HUGEVAL * HUGEVAL
00349 *     Using HUGEVAL may lead to spurious underflows.
00350       INCR_THRESH = DBLE( N ) * EPS
00351       M = KL+KU+1
00352 
00353       DO J = 1, NRHS
00354          Y_PREC_STATE = EXTRA_RESIDUAL
00355          IF ( Y_PREC_STATE .EQ. EXTRA_Y ) THEN
00356             DO I = 1, N
00357                Y_TAIL( I ) = 0.0D+0
00358             END DO
00359          END IF
00360 
00361          DXRAT = 0.0D+0
00362          DXRATMAX = 0.0D+0
00363          DZRAT = 0.0D+0
00364          DZRATMAX = 0.0D+0
00365          FINAL_DX_X = HUGEVAL
00366          FINAL_DZ_Z = HUGEVAL
00367          PREVNORMDX = HUGEVAL
00368          PREV_DZ_Z = HUGEVAL
00369          DZ_Z = HUGEVAL
00370          DX_X = HUGEVAL
00371 
00372          X_STATE = WORKING_STATE
00373          Z_STATE = UNSTABLE_STATE
00374          INCR_PREC = .FALSE.
00375 
00376          DO CNT = 1, ITHRESH
00377 *
00378 *        Compute residual RES = B_s - op(A_s) * Y,
00379 *            op(A) = A, A**T, or A**H depending on TRANS (and type).
00380 *
00381             CALL ZCOPY( N, B( 1, J ), 1, RES, 1 )
00382             IF ( Y_PREC_STATE .EQ. BASE_RESIDUAL ) THEN
00383                CALL ZGBMV( TRANS, M, N, KL, KU, (-1.0D+0,0.0D+0), AB,
00384      $              LDAB, Y( 1, J ), 1, (1.0D+0,0.0D+0), RES, 1 )
00385             ELSE IF ( Y_PREC_STATE .EQ. EXTRA_RESIDUAL ) THEN
00386                CALL BLAS_ZGBMV_X( TRANS_TYPE, N, N, KL, KU,
00387      $              (-1.0D+0,0.0D+0), AB, LDAB, Y( 1, J ), 1,
00388      $              (1.0D+0,0.0D+0), RES, 1, PREC_TYPE )
00389             ELSE
00390                CALL BLAS_ZGBMV2_X( TRANS_TYPE, N, N, KL, KU,
00391      $              (-1.0D+0,0.0D+0), AB, LDAB, Y( 1, J ), Y_TAIL, 1,
00392      $              (1.0D+0,0.0D+0), RES, 1, PREC_TYPE )
00393             END IF
00394 
00395 !        XXX: RES is no longer needed.
00396             CALL ZCOPY( N, RES, 1, DY, 1 )
00397             CALL ZGBTRS( TRANS, N, KL, KU, 1, AFB, LDAFB, IPIV, DY, N,
00398      $           INFO )
00399 *
00400 *         Calculate relative changes DX_X, DZ_Z and ratios DXRAT, DZRAT.
00401 *
00402             NORMX = 0.0D+0
00403             NORMY = 0.0D+0
00404             NORMDX = 0.0D+0
00405             DZ_Z = 0.0D+0
00406             YMIN = HUGEVAL
00407 
00408             DO I = 1, N
00409                YK = CABS1( Y( I, J ) )
00410                DYK = CABS1( DY( I ) )
00411 
00412                IF (YK .NE. 0.0D+0) THEN
00413                   DZ_Z = MAX( DZ_Z, DYK / YK )
00414                ELSE IF ( DYK .NE. 0.0D+0 ) THEN
00415                   DZ_Z = HUGEVAL
00416                END IF
00417 
00418                YMIN = MIN( YMIN, YK )
00419 
00420                NORMY = MAX( NORMY, YK )
00421 
00422                IF ( COLEQU ) THEN
00423                   NORMX = MAX( NORMX, YK * C( I ) )
00424                   NORMDX = MAX(NORMDX, DYK * C(I))
00425                ELSE
00426                   NORMX = NORMY
00427                   NORMDX = MAX( NORMDX, DYK )
00428                END IF
00429             END DO
00430 
00431             IF ( NORMX .NE. 0.0D+0 ) THEN
00432                DX_X = NORMDX / NORMX
00433             ELSE IF ( NORMDX .EQ. 0.0D+0 ) THEN
00434                DX_X = 0.0D+0
00435             ELSE
00436                DX_X = HUGEVAL
00437             END IF
00438 
00439             DXRAT = NORMDX / PREVNORMDX
00440             DZRAT = DZ_Z / PREV_DZ_Z
00441 *
00442 *         Check termination criteria.
00443 *
00444             IF (.NOT.IGNORE_CWISE
00445      $           .AND. YMIN*RCOND .LT. INCR_THRESH*NORMY
00446      $           .AND. Y_PREC_STATE .LT. EXTRA_Y )
00447      $           INCR_PREC = .TRUE.
00448 
00449             IF ( X_STATE .EQ. NOPROG_STATE .AND. DXRAT .LE. RTHRESH )
00450      $           X_STATE = WORKING_STATE
00451             IF ( X_STATE .EQ. WORKING_STATE ) THEN
00452                IF ( DX_X .LE. EPS ) THEN
00453                   X_STATE = CONV_STATE
00454                ELSE IF ( DXRAT .GT. RTHRESH ) THEN
00455                   IF ( Y_PREC_STATE .NE. EXTRA_Y ) THEN
00456                      INCR_PREC = .TRUE.
00457                   ELSE
00458                      X_STATE = NOPROG_STATE
00459                   END IF
00460                ELSE
00461                   IF ( DXRAT .GT. DXRATMAX ) DXRATMAX = DXRAT
00462                END IF
00463                IF ( X_STATE .GT. WORKING_STATE ) FINAL_DX_X = DX_X
00464             END IF
00465 
00466             IF ( Z_STATE .EQ. UNSTABLE_STATE .AND. DZ_Z .LE. DZ_UB )
00467      $           Z_STATE = WORKING_STATE
00468             IF ( Z_STATE .EQ. NOPROG_STATE .AND. DZRAT .LE. RTHRESH )
00469      $           Z_STATE = WORKING_STATE
00470             IF ( Z_STATE .EQ. WORKING_STATE ) THEN
00471                IF ( DZ_Z .LE. EPS ) THEN
00472                   Z_STATE = CONV_STATE
00473                ELSE IF ( DZ_Z .GT. DZ_UB ) THEN
00474                   Z_STATE = UNSTABLE_STATE
00475                   DZRATMAX = 0.0D+0
00476                   FINAL_DZ_Z = HUGEVAL
00477                ELSE IF ( DZRAT .GT. RTHRESH ) THEN
00478                   IF ( Y_PREC_STATE .NE. EXTRA_Y ) THEN
00479                      INCR_PREC = .TRUE.
00480                   ELSE
00481                      Z_STATE = NOPROG_STATE
00482                   END IF
00483                ELSE
00484                   IF ( DZRAT .GT. DZRATMAX ) DZRATMAX = DZRAT
00485                END IF
00486                IF ( Z_STATE .GT. WORKING_STATE ) FINAL_DZ_Z = DZ_Z
00487             END IF
00488 *
00489 *           Exit if both normwise and componentwise stopped working,
00490 *           but if componentwise is unstable, let it go at least two
00491 *           iterations.
00492 *
00493             IF ( X_STATE.NE.WORKING_STATE ) THEN
00494                IF ( IGNORE_CWISE ) GOTO 666
00495                IF ( Z_STATE.EQ.NOPROG_STATE .OR. Z_STATE.EQ.CONV_STATE )
00496      $              GOTO 666
00497                IF ( Z_STATE.EQ.UNSTABLE_STATE .AND. CNT.GT.1 ) GOTO 666
00498             END IF
00499 
00500             IF ( INCR_PREC ) THEN
00501                INCR_PREC = .FALSE.
00502                Y_PREC_STATE = Y_PREC_STATE + 1
00503                DO I = 1, N
00504                   Y_TAIL( I ) = 0.0D+0
00505                END DO
00506             END IF
00507 
00508             PREVNORMDX = NORMDX
00509             PREV_DZ_Z = DZ_Z
00510 *
00511 *           Update soluton.
00512 *
00513             IF ( Y_PREC_STATE .LT. EXTRA_Y ) THEN
00514                CALL ZAXPY( N, (1.0D+0,0.0D+0), DY, 1, Y(1,J), 1 )
00515             ELSE
00516                CALL ZLA_WWADDW( N, Y(1,J), Y_TAIL, DY )
00517             END IF
00518 
00519          END DO
00520 *        Target of "IF (Z_STOP .AND. X_STOP)".  Sun's f77 won't EXIT.
00521  666     CONTINUE
00522 *
00523 *     Set final_* when cnt hits ithresh.
00524 *
00525          IF ( X_STATE .EQ. WORKING_STATE ) FINAL_DX_X = DX_X
00526          IF ( Z_STATE .EQ. WORKING_STATE ) FINAL_DZ_Z = DZ_Z
00527 *
00528 *     Compute error bounds.
00529 *
00530          IF ( N_NORMS .GE. 1 ) THEN
00531             ERR_BNDS_NORM( J, LA_LINRX_ERR_I ) =
00532      $           FINAL_DX_X / (1 - DXRATMAX)
00533          END IF
00534          IF ( N_NORMS .GE. 2 ) THEN
00535             ERR_BNDS_COMP( J, LA_LINRX_ERR_I ) =
00536      $           FINAL_DZ_Z / (1 - DZRATMAX)
00537          END IF
00538 *
00539 *     Compute componentwise relative backward error from formula
00540 *         max(i) ( abs(R(i)) / ( abs(op(A_s))*abs(Y) + abs(B_s) )(i) )
00541 *     where abs(Z) is the componentwise absolute value of the matrix
00542 *     or vector Z.
00543 *
00544 *        Compute residual RES = B_s - op(A_s) * Y,
00545 *            op(A) = A, A**T, or A**H depending on TRANS (and type).
00546 *
00547          CALL ZCOPY( N, B( 1, J ), 1, RES, 1 )
00548          CALL ZGBMV( TRANS, N, N, KL, KU, (-1.0D+0,0.0D+0), AB, LDAB,
00549      $        Y(1,J), 1, (1.0D+0,0.0D+0), RES, 1 )
00550 
00551          DO I = 1, N
00552             AYB( I ) = CABS1( B( I, J ) )
00553          END DO
00554 *
00555 *     Compute abs(op(A_s))*abs(Y) + abs(B_s).
00556 *
00557         CALL ZLA_GBAMV( TRANS_TYPE, N, N, KL, KU, 1.0D+0,
00558      $        AB, LDAB, Y(1, J), 1, 1.0D+0, AYB, 1 )
00559 
00560          CALL ZLA_LIN_BERR( N, N, 1, RES, AYB, BERR_OUT( J ) )
00561 *
00562 *     End of loop for each RHS.
00563 *
00564       END DO
00565 *
00566       RETURN
00567       END
 All Files Functions