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