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