3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download DPBRFS + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dpbrfs.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dpbrfs.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dpbrfs.f">
21 * SUBROUTINE DPBRFS( UPLO, N, KD, NRHS, AB, LDAB, AFB, LDAFB, B,
22 * LDB, X, LDX, FERR, BERR, WORK, IWORK, INFO )
24 * .. Scalar Arguments ..
26 * INTEGER INFO, KD, LDAB, LDAFB, LDB, LDX, N, NRHS
28 * .. Array Arguments ..
30 * DOUBLE PRECISION AB( LDAB, * ), AFB( LDAFB, * ), B( LDB, * ),
31 * $ BERR( * ), FERR( * ), WORK( * ), X( LDX, * )
40 *> DPBRFS improves the computed solution to a system of linear
41 *> equations when the coefficient matrix is symmetric positive definite
42 *> and banded, and provides error bounds and backward error estimates
51 *> UPLO is CHARACTER*1
52 *> = 'U': Upper triangle of A is stored;
53 *> = 'L': Lower triangle of A is stored.
59 *> The order of the matrix A. N >= 0.
65 *> The number of superdiagonals of the matrix A if UPLO = 'U',
66 *> or the number of subdiagonals if UPLO = 'L'. KD >= 0.
72 *> The number of right hand sides, i.e., the number of columns
73 *> of the matrices B and X. NRHS >= 0.
78 *> AB is DOUBLE PRECISION array, dimension (LDAB,N)
79 *> The upper or lower triangle of the symmetric band matrix A,
80 *> stored in the first KD+1 rows of the array. The j-th column
81 *> of A is stored in the j-th column of the array AB as follows:
82 *> if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j;
83 *> if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+kd).
89 *> The leading dimension of the array AB. LDAB >= KD+1.
94 *> AFB is DOUBLE PRECISION array, dimension (LDAFB,N)
95 *> The triangular factor U or L from the Cholesky factorization
96 *> A = U**T*U or A = L*L**T of the band matrix A as computed by
97 *> DPBTRF, in the same storage format as A (see AB).
103 *> The leading dimension of the array AFB. LDAFB >= KD+1.
108 *> B is DOUBLE PRECISION array, dimension (LDB,NRHS)
109 *> The right hand side matrix B.
115 *> The leading dimension of the array B. LDB >= max(1,N).
120 *> X is DOUBLE PRECISION array, dimension (LDX,NRHS)
121 *> On entry, the solution matrix X, as computed by DPBTRS.
122 *> On exit, the improved solution matrix X.
128 *> The leading dimension of the array X. LDX >= max(1,N).
133 *> FERR is DOUBLE PRECISION array, dimension (NRHS)
134 *> The estimated forward error bound for each solution vector
135 *> X(j) (the j-th column of the solution matrix X).
136 *> If XTRUE is the true solution corresponding to X(j), FERR(j)
137 *> is an estimated upper bound for the magnitude of the largest
138 *> element in (X(j) - XTRUE) divided by the magnitude of the
139 *> largest element in X(j). The estimate is as reliable as
140 *> the estimate for RCOND, and is almost always a slight
141 *> overestimate of the true error.
146 *> BERR is DOUBLE PRECISION array, dimension (NRHS)
147 *> The componentwise relative backward error of each solution
148 *> vector X(j) (i.e., the smallest relative change in
149 *> any element of A or B that makes X(j) an exact solution).
154 *> WORK is DOUBLE PRECISION array, dimension (3*N)
159 *> IWORK is INTEGER array, dimension (N)
165 *> = 0: successful exit
166 *> < 0: if INFO = -i, the i-th argument had an illegal value
169 *> \par Internal Parameters:
170 * =========================
173 *> ITMAX is the maximum number of steps of iterative refinement.
179 *> \author Univ. of Tennessee
180 *> \author Univ. of California Berkeley
181 *> \author Univ. of Colorado Denver
184 *> \date November 2011
186 *> \ingroup doubleOTHERcomputational
188 * =====================================================================
189 SUBROUTINE DPBRFS( UPLO, N, KD, NRHS, AB, LDAB, AFB, LDAFB, B,
190 $ LDB, X, LDX, FERR, BERR, WORK, IWORK, INFO )
192 * -- LAPACK computational routine (version 3.4.0) --
193 * -- LAPACK is a software package provided by Univ. of Tennessee, --
194 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
197 * .. Scalar Arguments ..
199 INTEGER INFO, KD, LDAB, LDAFB, LDB, LDX, N, NRHS
201 * .. Array Arguments ..
203 DOUBLE PRECISION AB( LDAB, * ), AFB( LDAFB, * ), B( LDB, * ),
204 $ BERR( * ), FERR( * ), WORK( * ), X( LDX, * )
207 * =====================================================================
211 PARAMETER ( ITMAX = 5 )
212 DOUBLE PRECISION ZERO
213 PARAMETER ( ZERO = 0.0D+0 )
215 PARAMETER ( ONE = 1.0D+0 )
217 PARAMETER ( TWO = 2.0D+0 )
218 DOUBLE PRECISION THREE
219 PARAMETER ( THREE = 3.0D+0 )
221 * .. Local Scalars ..
223 INTEGER COUNT, I, J, K, KASE, L, NZ
224 DOUBLE PRECISION EPS, LSTRES, S, SAFE1, SAFE2, SAFMIN, XK
229 * .. External Subroutines ..
230 EXTERNAL DAXPY, DCOPY, DLACN2, DPBTRS, DSBMV, XERBLA
232 * .. Intrinsic Functions ..
233 INTRINSIC ABS, MAX, MIN
235 * .. External Functions ..
237 DOUBLE PRECISION DLAMCH
238 EXTERNAL LSAME, DLAMCH
240 * .. Executable Statements ..
242 * Test the input parameters.
245 UPPER = LSAME( UPLO, 'U' )
246 IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
248 ELSE IF( N.LT.0 ) THEN
250 ELSE IF( KD.LT.0 ) THEN
252 ELSE IF( NRHS.LT.0 ) THEN
254 ELSE IF( LDAB.LT.KD+1 ) THEN
256 ELSE IF( LDAFB.LT.KD+1 ) THEN
258 ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
260 ELSE IF( LDX.LT.MAX( 1, N ) ) THEN
264 CALL XERBLA( 'DPBRFS', -INFO )
268 * Quick return if possible
270 IF( N.EQ.0 .OR. NRHS.EQ.0 ) THEN
278 * NZ = maximum number of nonzero elements in each row of A, plus 1
280 NZ = MIN( N+1, 2*KD+2 )
281 EPS = DLAMCH( 'Epsilon' )
282 SAFMIN = DLAMCH( 'Safe minimum' )
286 * Do for each right hand side
294 * Loop until stopping criterion is satisfied.
296 * Compute residual R = B - A * X
298 CALL DCOPY( N, B( 1, J ), 1, WORK( N+1 ), 1 )
299 CALL DSBMV( UPLO, N, KD, -ONE, AB, LDAB, X( 1, J ), 1, ONE,
302 * Compute componentwise relative backward error from formula
304 * max(i) ( abs(R(i)) / ( abs(A)*abs(X) + abs(B) )(i) )
306 * where abs(Z) is the componentwise absolute value of the matrix
307 * or vector Z. If the i-th component of the denominator is less
308 * than SAFE2, then SAFE1 is added to the i-th components of the
309 * numerator and denominator before dividing.
312 WORK( I ) = ABS( B( I, J ) )
315 * Compute abs(A)*abs(X) + abs(B).
320 XK = ABS( X( K, J ) )
322 DO 40 I = MAX( 1, K-KD ), K - 1
323 WORK( I ) = WORK( I ) + ABS( AB( L+I, K ) )*XK
324 S = S + ABS( AB( L+I, K ) )*ABS( X( I, J ) )
326 WORK( K ) = WORK( K ) + ABS( AB( KD+1, K ) )*XK + S
331 XK = ABS( X( K, J ) )
332 WORK( K ) = WORK( K ) + ABS( AB( 1, K ) )*XK
334 DO 60 I = K + 1, MIN( N, K+KD )
335 WORK( I ) = WORK( I ) + ABS( AB( L+I, K ) )*XK
336 S = S + ABS( AB( L+I, K ) )*ABS( X( I, J ) )
338 WORK( K ) = WORK( K ) + S
343 IF( WORK( I ).GT.SAFE2 ) THEN
344 S = MAX( S, ABS( WORK( N+I ) ) / WORK( I ) )
346 S = MAX( S, ( ABS( WORK( N+I ) )+SAFE1 ) /
347 $ ( WORK( I )+SAFE1 ) )
352 * Test stopping criterion. Continue iterating if
353 * 1) The residual BERR(J) is larger than machine epsilon, and
354 * 2) BERR(J) decreased by at least a factor of 2 during the
355 * last iteration, and
356 * 3) At most ITMAX iterations tried.
358 IF( BERR( J ).GT.EPS .AND. TWO*BERR( J ).LE.LSTRES .AND.
359 $ COUNT.LE.ITMAX ) THEN
361 * Update solution and try again.
363 CALL DPBTRS( UPLO, N, KD, 1, AFB, LDAFB, WORK( N+1 ), N,
365 CALL DAXPY( N, ONE, WORK( N+1 ), 1, X( 1, J ), 1 )
371 * Bound error from formula
373 * norm(X - XTRUE) / norm(X) .le. FERR =
375 * ( abs(R) + NZ*EPS*( abs(A)*abs(X)+abs(B) ))) / norm(X)
378 * norm(Z) is the magnitude of the largest component of Z
379 * inv(A) is the inverse of A
380 * abs(Z) is the componentwise absolute value of the matrix or
382 * NZ is the maximum number of nonzeros in any row of A, plus 1
383 * EPS is machine epsilon
385 * The i-th component of abs(R)+NZ*EPS*(abs(A)*abs(X)+abs(B))
386 * is incremented by SAFE1 if the i-th component of
387 * abs(A)*abs(X) + abs(B) is less than SAFE2.
389 * Use DLACN2 to estimate the infinity-norm of the matrix
391 * where W = abs(R) + NZ*EPS*( abs(A)*abs(X)+abs(B) )))
394 IF( WORK( I ).GT.SAFE2 ) THEN
395 WORK( I ) = ABS( WORK( N+I ) ) + NZ*EPS*WORK( I )
397 WORK( I ) = ABS( WORK( N+I ) ) + NZ*EPS*WORK( I ) + SAFE1
403 CALL DLACN2( N, WORK( 2*N+1 ), WORK( N+1 ), IWORK, FERR( J ),
408 * Multiply by diag(W)*inv(A**T).
410 CALL DPBTRS( UPLO, N, KD, 1, AFB, LDAFB, WORK( N+1 ), N,
413 WORK( N+I ) = WORK( N+I )*WORK( I )
415 ELSE IF( KASE.EQ.2 ) THEN
417 * Multiply by inv(A)*diag(W).
420 WORK( N+I ) = WORK( N+I )*WORK( I )
422 CALL DPBTRS( UPLO, N, KD, 1, AFB, LDAFB, WORK( N+1 ), N,
432 LSTRES = MAX( LSTRES, ABS( X( I, J ) ) )
435 $ FERR( J ) = FERR( J ) / LSTRES