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