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