![]() |
LAPACK
3.4.1
LAPACK: Linear Algebra PACKage
|
00001 *> \brief \b DGBRFS 00002 * 00003 * =========== DOCUMENTATION =========== 00004 * 00005 * Online html documentation available at 00006 * http://www.netlib.org/lapack/explore-html/ 00007 * 00008 *> \htmlonly 00009 *> Download DGBRFS + dependencies 00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dgbrfs.f"> 00011 *> [TGZ]</a> 00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dgbrfs.f"> 00013 *> [ZIP]</a> 00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dgbrfs.f"> 00015 *> [TXT]</a> 00016 *> \endhtmlonly 00017 * 00018 * Definition: 00019 * =========== 00020 * 00021 * SUBROUTINE DGBRFS( TRANS, N, KL, KU, NRHS, AB, LDAB, AFB, LDAFB, 00022 * IPIV, B, LDB, X, LDX, FERR, BERR, WORK, IWORK, 00023 * INFO ) 00024 * 00025 * .. Scalar Arguments .. 00026 * CHARACTER TRANS 00027 * INTEGER INFO, KL, KU, LDAB, LDAFB, LDB, LDX, N, NRHS 00028 * .. 00029 * .. Array Arguments .. 00030 * INTEGER IPIV( * ), IWORK( * ) 00031 * DOUBLE PRECISION AB( LDAB, * ), AFB( LDAFB, * ), B( LDB, * ), 00032 * $ BERR( * ), FERR( * ), WORK( * ), X( LDX, * ) 00033 * .. 00034 * 00035 * 00036 *> \par Purpose: 00037 * ============= 00038 *> 00039 *> \verbatim 00040 *> 00041 *> DGBRFS improves the computed solution to a system of linear 00042 *> equations when the coefficient matrix is banded, and provides 00043 *> error bounds and backward error estimates for the solution. 00044 *> \endverbatim 00045 * 00046 * Arguments: 00047 * ========== 00048 * 00049 *> \param[in] TRANS 00050 *> \verbatim 00051 *> TRANS is CHARACTER*1 00052 *> Specifies the form of the system of equations: 00053 *> = 'N': A * X = B (No transpose) 00054 *> = 'T': A**T * X = B (Transpose) 00055 *> = 'C': A**H * X = B (Conjugate transpose = Transpose) 00056 *> \endverbatim 00057 *> 00058 *> \param[in] N 00059 *> \verbatim 00060 *> N is INTEGER 00061 *> The order of the matrix A. N >= 0. 00062 *> \endverbatim 00063 *> 00064 *> \param[in] KL 00065 *> \verbatim 00066 *> KL is INTEGER 00067 *> The number of subdiagonals within the band of A. KL >= 0. 00068 *> \endverbatim 00069 *> 00070 *> \param[in] KU 00071 *> \verbatim 00072 *> KU is INTEGER 00073 *> The number of superdiagonals within the band of A. KU >= 0. 00074 *> \endverbatim 00075 *> 00076 *> \param[in] NRHS 00077 *> \verbatim 00078 *> NRHS is INTEGER 00079 *> The number of right hand sides, i.e., the number of columns 00080 *> of the matrices B and X. NRHS >= 0. 00081 *> \endverbatim 00082 *> 00083 *> \param[in] AB 00084 *> \verbatim 00085 *> AB is DOUBLE PRECISION array, dimension (LDAB,N) 00086 *> The original band matrix A, stored in rows 1 to KL+KU+1. 00087 *> The j-th column of A is stored in the j-th column of the 00088 *> array AB as follows: 00089 *> AB(ku+1+i-j,j) = A(i,j) for max(1,j-ku)<=i<=min(n,j+kl). 00090 *> \endverbatim 00091 *> 00092 *> \param[in] LDAB 00093 *> \verbatim 00094 *> LDAB is INTEGER 00095 *> The leading dimension of the array AB. LDAB >= KL+KU+1. 00096 *> \endverbatim 00097 *> 00098 *> \param[in] AFB 00099 *> \verbatim 00100 *> AFB is DOUBLE PRECISION array, dimension (LDAFB,N) 00101 *> Details of the LU factorization of the band matrix A, as 00102 *> computed by DGBTRF. U is stored as an upper triangular band 00103 *> matrix with KL+KU superdiagonals in rows 1 to KL+KU+1, and 00104 *> the multipliers used during the factorization are stored in 00105 *> rows KL+KU+2 to 2*KL+KU+1. 00106 *> \endverbatim 00107 *> 00108 *> \param[in] LDAFB 00109 *> \verbatim 00110 *> LDAFB is INTEGER 00111 *> The leading dimension of the array AFB. LDAFB >= 2*KL*KU+1. 00112 *> \endverbatim 00113 *> 00114 *> \param[in] IPIV 00115 *> \verbatim 00116 *> IPIV is INTEGER array, dimension (N) 00117 *> The pivot indices from DGBTRF; for 1<=i<=N, row i of the 00118 *> matrix was interchanged with row IPIV(i). 00119 *> \endverbatim 00120 *> 00121 *> \param[in] B 00122 *> \verbatim 00123 *> B is DOUBLE PRECISION array, dimension (LDB,NRHS) 00124 *> The right hand side matrix B. 00125 *> \endverbatim 00126 *> 00127 *> \param[in] LDB 00128 *> \verbatim 00129 *> LDB is INTEGER 00130 *> The leading dimension of the array B. LDB >= max(1,N). 00131 *> \endverbatim 00132 *> 00133 *> \param[in,out] X 00134 *> \verbatim 00135 *> X is DOUBLE PRECISION array, dimension (LDX,NRHS) 00136 *> On entry, the solution matrix X, as computed by DGBTRS. 00137 *> On exit, the improved solution matrix X. 00138 *> \endverbatim 00139 *> 00140 *> \param[in] LDX 00141 *> \verbatim 00142 *> LDX is INTEGER 00143 *> The leading dimension of the array X. LDX >= max(1,N). 00144 *> \endverbatim 00145 *> 00146 *> \param[out] FERR 00147 *> \verbatim 00148 *> FERR is DOUBLE PRECISION array, dimension (NRHS) 00149 *> The estimated forward error bound for each solution vector 00150 *> X(j) (the j-th column of the solution matrix X). 00151 *> If XTRUE is the true solution corresponding to X(j), FERR(j) 00152 *> is an estimated upper bound for the magnitude of the largest 00153 *> element in (X(j) - XTRUE) divided by the magnitude of the 00154 *> largest element in X(j). The estimate is as reliable as 00155 *> the estimate for RCOND, and is almost always a slight 00156 *> overestimate of the true error. 00157 *> \endverbatim 00158 *> 00159 *> \param[out] BERR 00160 *> \verbatim 00161 *> BERR is DOUBLE PRECISION array, dimension (NRHS) 00162 *> The componentwise relative backward error of each solution 00163 *> vector X(j) (i.e., the smallest relative change in 00164 *> any element of A or B that makes X(j) an exact solution). 00165 *> \endverbatim 00166 *> 00167 *> \param[out] WORK 00168 *> \verbatim 00169 *> WORK is DOUBLE PRECISION array, dimension (3*N) 00170 *> \endverbatim 00171 *> 00172 *> \param[out] IWORK 00173 *> \verbatim 00174 *> IWORK is INTEGER array, dimension (N) 00175 *> \endverbatim 00176 *> 00177 *> \param[out] INFO 00178 *> \verbatim 00179 *> INFO is INTEGER 00180 *> = 0: successful exit 00181 *> < 0: if INFO = -i, the i-th argument had an illegal value 00182 *> \endverbatim 00183 * 00184 *> \par Internal Parameters: 00185 * ========================= 00186 *> 00187 *> \verbatim 00188 *> ITMAX is the maximum number of steps of iterative refinement. 00189 *> \endverbatim 00190 * 00191 * Authors: 00192 * ======== 00193 * 00194 *> \author Univ. of Tennessee 00195 *> \author Univ. of California Berkeley 00196 *> \author Univ. of Colorado Denver 00197 *> \author NAG Ltd. 00198 * 00199 *> \date November 2011 00200 * 00201 *> \ingroup doubleGBcomputational 00202 * 00203 * ===================================================================== 00204 SUBROUTINE DGBRFS( TRANS, N, KL, KU, NRHS, AB, LDAB, AFB, LDAFB, 00205 $ IPIV, B, LDB, X, LDX, FERR, BERR, WORK, IWORK, 00206 $ INFO ) 00207 * 00208 * -- LAPACK computational routine (version 3.4.0) -- 00209 * -- LAPACK is a software package provided by Univ. of Tennessee, -- 00210 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- 00211 * November 2011 00212 * 00213 * .. Scalar Arguments .. 00214 CHARACTER TRANS 00215 INTEGER INFO, KL, KU, LDAB, LDAFB, LDB, LDX, N, NRHS 00216 * .. 00217 * .. Array Arguments .. 00218 INTEGER IPIV( * ), IWORK( * ) 00219 DOUBLE PRECISION AB( LDAB, * ), AFB( LDAFB, * ), B( LDB, * ), 00220 $ BERR( * ), FERR( * ), WORK( * ), X( LDX, * ) 00221 * .. 00222 * 00223 * ===================================================================== 00224 * 00225 * .. Parameters .. 00226 INTEGER ITMAX 00227 PARAMETER ( ITMAX = 5 ) 00228 DOUBLE PRECISION ZERO 00229 PARAMETER ( ZERO = 0.0D+0 ) 00230 DOUBLE PRECISION ONE 00231 PARAMETER ( ONE = 1.0D+0 ) 00232 DOUBLE PRECISION TWO 00233 PARAMETER ( TWO = 2.0D+0 ) 00234 DOUBLE PRECISION THREE 00235 PARAMETER ( THREE = 3.0D+0 ) 00236 * .. 00237 * .. Local Scalars .. 00238 LOGICAL NOTRAN 00239 CHARACTER TRANST 00240 INTEGER COUNT, I, J, K, KASE, KK, NZ 00241 DOUBLE PRECISION EPS, LSTRES, S, SAFE1, SAFE2, SAFMIN, XK 00242 * .. 00243 * .. Local Arrays .. 00244 INTEGER ISAVE( 3 ) 00245 * .. 00246 * .. External Subroutines .. 00247 EXTERNAL DAXPY, DCOPY, DGBMV, DGBTRS, DLACN2, XERBLA 00248 * .. 00249 * .. Intrinsic Functions .. 00250 INTRINSIC ABS, MAX, MIN 00251 * .. 00252 * .. External Functions .. 00253 LOGICAL LSAME 00254 DOUBLE PRECISION DLAMCH 00255 EXTERNAL LSAME, DLAMCH 00256 * .. 00257 * .. Executable Statements .. 00258 * 00259 * Test the input parameters. 00260 * 00261 INFO = 0 00262 NOTRAN = LSAME( TRANS, 'N' ) 00263 IF( .NOT.NOTRAN .AND. .NOT.LSAME( TRANS, 'T' ) .AND. .NOT. 00264 $ LSAME( TRANS, 'C' ) ) THEN 00265 INFO = -1 00266 ELSE IF( N.LT.0 ) THEN 00267 INFO = -2 00268 ELSE IF( KL.LT.0 ) THEN 00269 INFO = -3 00270 ELSE IF( KU.LT.0 ) THEN 00271 INFO = -4 00272 ELSE IF( NRHS.LT.0 ) THEN 00273 INFO = -5 00274 ELSE IF( LDAB.LT.KL+KU+1 ) THEN 00275 INFO = -7 00276 ELSE IF( LDAFB.LT.2*KL+KU+1 ) THEN 00277 INFO = -9 00278 ELSE IF( LDB.LT.MAX( 1, N ) ) THEN 00279 INFO = -12 00280 ELSE IF( LDX.LT.MAX( 1, N ) ) THEN 00281 INFO = -14 00282 END IF 00283 IF( INFO.NE.0 ) THEN 00284 CALL XERBLA( 'DGBRFS', -INFO ) 00285 RETURN 00286 END IF 00287 * 00288 * Quick return if possible 00289 * 00290 IF( N.EQ.0 .OR. NRHS.EQ.0 ) THEN 00291 DO 10 J = 1, NRHS 00292 FERR( J ) = ZERO 00293 BERR( J ) = ZERO 00294 10 CONTINUE 00295 RETURN 00296 END IF 00297 * 00298 IF( NOTRAN ) THEN 00299 TRANST = 'T' 00300 ELSE 00301 TRANST = 'N' 00302 END IF 00303 * 00304 * NZ = maximum number of nonzero elements in each row of A, plus 1 00305 * 00306 NZ = MIN( KL+KU+2, N+1 ) 00307 EPS = DLAMCH( 'Epsilon' ) 00308 SAFMIN = DLAMCH( 'Safe minimum' ) 00309 SAFE1 = NZ*SAFMIN 00310 SAFE2 = SAFE1 / EPS 00311 * 00312 * Do for each right hand side 00313 * 00314 DO 140 J = 1, NRHS 00315 * 00316 COUNT = 1 00317 LSTRES = THREE 00318 20 CONTINUE 00319 * 00320 * Loop until stopping criterion is satisfied. 00321 * 00322 * Compute residual R = B - op(A) * X, 00323 * where op(A) = A, A**T, or A**H, depending on TRANS. 00324 * 00325 CALL DCOPY( N, B( 1, J ), 1, WORK( N+1 ), 1 ) 00326 CALL DGBMV( TRANS, N, N, KL, KU, -ONE, AB, LDAB, X( 1, J ), 1, 00327 $ ONE, WORK( N+1 ), 1 ) 00328 * 00329 * Compute componentwise relative backward error from formula 00330 * 00331 * max(i) ( abs(R(i)) / ( abs(op(A))*abs(X) + abs(B) )(i) ) 00332 * 00333 * where abs(Z) is the componentwise absolute value of the matrix 00334 * or vector Z. If the i-th component of the denominator is less 00335 * than SAFE2, then SAFE1 is added to the i-th components of the 00336 * numerator and denominator before dividing. 00337 * 00338 DO 30 I = 1, N 00339 WORK( I ) = ABS( B( I, J ) ) 00340 30 CONTINUE 00341 * 00342 * Compute abs(op(A))*abs(X) + abs(B). 00343 * 00344 IF( NOTRAN ) THEN 00345 DO 50 K = 1, N 00346 KK = KU + 1 - K 00347 XK = ABS( X( K, J ) ) 00348 DO 40 I = MAX( 1, K-KU ), MIN( N, K+KL ) 00349 WORK( I ) = WORK( I ) + ABS( AB( KK+I, K ) )*XK 00350 40 CONTINUE 00351 50 CONTINUE 00352 ELSE 00353 DO 70 K = 1, N 00354 S = ZERO 00355 KK = KU + 1 - K 00356 DO 60 I = MAX( 1, K-KU ), MIN( N, K+KL ) 00357 S = S + ABS( AB( KK+I, K ) )*ABS( X( I, J ) ) 00358 60 CONTINUE 00359 WORK( K ) = WORK( K ) + S 00360 70 CONTINUE 00361 END IF 00362 S = ZERO 00363 DO 80 I = 1, N 00364 IF( WORK( I ).GT.SAFE2 ) THEN 00365 S = MAX( S, ABS( WORK( N+I ) ) / WORK( I ) ) 00366 ELSE 00367 S = MAX( S, ( ABS( WORK( N+I ) )+SAFE1 ) / 00368 $ ( WORK( I )+SAFE1 ) ) 00369 END IF 00370 80 CONTINUE 00371 BERR( J ) = S 00372 * 00373 * Test stopping criterion. Continue iterating if 00374 * 1) The residual BERR(J) is larger than machine epsilon, and 00375 * 2) BERR(J) decreased by at least a factor of 2 during the 00376 * last iteration, and 00377 * 3) At most ITMAX iterations tried. 00378 * 00379 IF( BERR( J ).GT.EPS .AND. TWO*BERR( J ).LE.LSTRES .AND. 00380 $ COUNT.LE.ITMAX ) THEN 00381 * 00382 * Update solution and try again. 00383 * 00384 CALL DGBTRS( TRANS, N, KL, KU, 1, AFB, LDAFB, IPIV, 00385 $ WORK( N+1 ), N, INFO ) 00386 CALL DAXPY( N, ONE, WORK( N+1 ), 1, X( 1, J ), 1 ) 00387 LSTRES = BERR( J ) 00388 COUNT = COUNT + 1 00389 GO TO 20 00390 END IF 00391 * 00392 * Bound error from formula 00393 * 00394 * norm(X - XTRUE) / norm(X) .le. FERR = 00395 * norm( abs(inv(op(A)))* 00396 * ( abs(R) + NZ*EPS*( abs(op(A))*abs(X)+abs(B) ))) / norm(X) 00397 * 00398 * where 00399 * norm(Z) is the magnitude of the largest component of Z 00400 * inv(op(A)) is the inverse of op(A) 00401 * abs(Z) is the componentwise absolute value of the matrix or 00402 * vector Z 00403 * NZ is the maximum number of nonzeros in any row of A, plus 1 00404 * EPS is machine epsilon 00405 * 00406 * The i-th component of abs(R)+NZ*EPS*(abs(op(A))*abs(X)+abs(B)) 00407 * is incremented by SAFE1 if the i-th component of 00408 * abs(op(A))*abs(X) + abs(B) is less than SAFE2. 00409 * 00410 * Use DLACN2 to estimate the infinity-norm of the matrix 00411 * inv(op(A)) * diag(W), 00412 * where W = abs(R) + NZ*EPS*( abs(op(A))*abs(X)+abs(B) ))) 00413 * 00414 DO 90 I = 1, N 00415 IF( WORK( I ).GT.SAFE2 ) THEN 00416 WORK( I ) = ABS( WORK( N+I ) ) + NZ*EPS*WORK( I ) 00417 ELSE 00418 WORK( I ) = ABS( WORK( N+I ) ) + NZ*EPS*WORK( I ) + SAFE1 00419 END IF 00420 90 CONTINUE 00421 * 00422 KASE = 0 00423 100 CONTINUE 00424 CALL DLACN2( N, WORK( 2*N+1 ), WORK( N+1 ), IWORK, FERR( J ), 00425 $ KASE, ISAVE ) 00426 IF( KASE.NE.0 ) THEN 00427 IF( KASE.EQ.1 ) THEN 00428 * 00429 * Multiply by diag(W)*inv(op(A)**T). 00430 * 00431 CALL DGBTRS( TRANST, N, KL, KU, 1, AFB, LDAFB, IPIV, 00432 $ WORK( N+1 ), N, INFO ) 00433 DO 110 I = 1, N 00434 WORK( N+I ) = WORK( N+I )*WORK( I ) 00435 110 CONTINUE 00436 ELSE 00437 * 00438 * Multiply by inv(op(A))*diag(W). 00439 * 00440 DO 120 I = 1, N 00441 WORK( N+I ) = WORK( N+I )*WORK( I ) 00442 120 CONTINUE 00443 CALL DGBTRS( TRANS, N, KL, KU, 1, AFB, LDAFB, IPIV, 00444 $ WORK( N+1 ), N, INFO ) 00445 END IF 00446 GO TO 100 00447 END IF 00448 * 00449 * Normalize error. 00450 * 00451 LSTRES = ZERO 00452 DO 130 I = 1, N 00453 LSTRES = MAX( LSTRES, ABS( X( I, J ) ) ) 00454 130 CONTINUE 00455 IF( LSTRES.NE.ZERO ) 00456 $ FERR( J ) = FERR( J ) / LSTRES 00457 * 00458 140 CONTINUE 00459 * 00460 RETURN 00461 * 00462 * End of DGBRFS 00463 * 00464 END