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, * )
37 *>\details \b Purpose:
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
52 *> UPLO is CHARACTER*1
53 *> = 'U': Upper triangle of A is stored;
54 *> = 'L': Lower triangle of A is stored.
60 *> The order of the matrix A. N >= 0.
66 *> The number of superdiagonals of the matrix A if UPLO = 'U',
67 *> or the number of subdiagonals if UPLO = 'L'. KD >= 0.
73 *> The number of right hand sides, i.e., the number of columns
74 *> of the matrices B and X. NRHS >= 0.
79 *> AB is DOUBLE PRECISION array, dimension (LDAB,N)
80 *> The upper or lower triangle of the symmetric band matrix A,
81 *> stored in the first KD+1 rows of the array. The j-th column
82 *> of A is stored in the j-th column of the array AB as follows:
83 *> if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j;
84 *> if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+kd).
90 *> The leading dimension of the array AB. LDAB >= KD+1.
95 *> AFB is DOUBLE PRECISION array, dimension (LDAFB,N)
96 *> The triangular factor U or L from the Cholesky factorization
97 *> A = U**T*U or A = L*L**T of the band matrix A as computed by
98 *> DPBTRF, in the same storage format as A (see AB).
104 *> The leading dimension of the array AFB. LDAFB >= KD+1.
109 *> B is DOUBLE PRECISION array, dimension (LDB,NRHS)
110 *> The right hand side matrix B.
116 *> The leading dimension of the array B. LDB >= max(1,N).
121 *> X is DOUBLE PRECISION array, dimension (LDX,NRHS)
122 *> On entry, the solution matrix X, as computed by DPBTRS.
123 *> On exit, the improved solution matrix X.
129 *> The leading dimension of the array X. LDX >= max(1,N).
134 *> FERR is DOUBLE PRECISION array, dimension (NRHS)
135 *> The estimated forward error bound for each solution vector
136 *> X(j) (the j-th column of the solution matrix X).
137 *> If XTRUE is the true solution corresponding to X(j), FERR(j)
138 *> is an estimated upper bound for the magnitude of the largest
139 *> element in (X(j) - XTRUE) divided by the magnitude of the
140 *> largest element in X(j). The estimate is as reliable as
141 *> the estimate for RCOND, and is almost always a slight
142 *> overestimate of the true error.
147 *> BERR is DOUBLE PRECISION array, dimension (NRHS)
148 *> The componentwise relative backward error of each solution
149 *> vector X(j) (i.e., the smallest relative change in
150 *> any element of A or B that makes X(j) an exact solution).
155 *> WORK is DOUBLE PRECISION array, dimension (3*N)
160 *> IWORK is INTEGER array, dimension (N)
166 *> = 0: successful exit
167 *> < 0: if INFO = -i, the i-th argument had an illegal value
170 *> Internal Parameters
171 *> ===================
174 *> ITMAX is the maximum number of steps of iterative refinement.
181 *> \author Univ. of Tennessee
182 *> \author Univ. of California Berkeley
183 *> \author Univ. of Colorado Denver
186 *> \date November 2011
188 *> \ingroup doubleOTHERcomputational
190 * =====================================================================
191 SUBROUTINE DPBRFS( UPLO, N, KD, NRHS, AB, LDAB, AFB, LDAFB, B,
192 $ LDB, X, LDX, FERR, BERR, WORK, IWORK, INFO )
194 * -- LAPACK computational routine (version 3.2) --
195 * -- LAPACK is a software package provided by Univ. of Tennessee, --
196 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
199 * .. Scalar Arguments ..
201 INTEGER INFO, KD, LDAB, LDAFB, LDB, LDX, N, NRHS
203 * .. Array Arguments ..
205 DOUBLE PRECISION AB( LDAB, * ), AFB( LDAFB, * ), B( LDB, * ),
206 $ BERR( * ), FERR( * ), WORK( * ), X( LDX, * )
209 * =====================================================================
213 PARAMETER ( ITMAX = 5 )
214 DOUBLE PRECISION ZERO
215 PARAMETER ( ZERO = 0.0D+0 )
217 PARAMETER ( ONE = 1.0D+0 )
219 PARAMETER ( TWO = 2.0D+0 )
220 DOUBLE PRECISION THREE
221 PARAMETER ( THREE = 3.0D+0 )
223 * .. Local Scalars ..
225 INTEGER COUNT, I, J, K, KASE, L, NZ
226 DOUBLE PRECISION EPS, LSTRES, S, SAFE1, SAFE2, SAFMIN, XK
231 * .. External Subroutines ..
232 EXTERNAL DAXPY, DCOPY, DLACN2, DPBTRS, DSBMV, XERBLA
234 * .. Intrinsic Functions ..
235 INTRINSIC ABS, MAX, MIN
237 * .. External Functions ..
239 DOUBLE PRECISION DLAMCH
240 EXTERNAL LSAME, DLAMCH
242 * .. Executable Statements ..
244 * Test the input parameters.
247 UPPER = LSAME( UPLO, 'U' )
248 IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
250 ELSE IF( N.LT.0 ) THEN
252 ELSE IF( KD.LT.0 ) THEN
254 ELSE IF( NRHS.LT.0 ) THEN
256 ELSE IF( LDAB.LT.KD+1 ) THEN
258 ELSE IF( LDAFB.LT.KD+1 ) THEN
260 ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
262 ELSE IF( LDX.LT.MAX( 1, N ) ) THEN
266 CALL XERBLA( 'DPBRFS', -INFO )
270 * Quick return if possible
272 IF( N.EQ.0 .OR. NRHS.EQ.0 ) THEN
280 * NZ = maximum number of nonzero elements in each row of A, plus 1
282 NZ = MIN( N+1, 2*KD+2 )
283 EPS = DLAMCH( 'Epsilon' )
284 SAFMIN = DLAMCH( 'Safe minimum' )
288 * Do for each right hand side
296 * Loop until stopping criterion is satisfied.
298 * Compute residual R = B - A * X
300 CALL DCOPY( N, B( 1, J ), 1, WORK( N+1 ), 1 )
301 CALL DSBMV( UPLO, N, KD, -ONE, AB, LDAB, X( 1, J ), 1, ONE,
304 * Compute componentwise relative backward error from formula
306 * max(i) ( abs(R(i)) / ( abs(A)*abs(X) + abs(B) )(i) )
308 * where abs(Z) is the componentwise absolute value of the matrix
309 * or vector Z. If the i-th component of the denominator is less
310 * than SAFE2, then SAFE1 is added to the i-th components of the
311 * numerator and denominator before dividing.
314 WORK( I ) = ABS( B( I, J ) )
317 * Compute abs(A)*abs(X) + abs(B).
322 XK = ABS( X( K, J ) )
324 DO 40 I = MAX( 1, K-KD ), K - 1
325 WORK( I ) = WORK( I ) + ABS( AB( L+I, K ) )*XK
326 S = S + ABS( AB( L+I, K ) )*ABS( X( I, J ) )
328 WORK( K ) = WORK( K ) + ABS( AB( KD+1, K ) )*XK + S
333 XK = ABS( X( K, J ) )
334 WORK( K ) = WORK( K ) + ABS( AB( 1, K ) )*XK
336 DO 60 I = K + 1, MIN( N, K+KD )
337 WORK( I ) = WORK( I ) + ABS( AB( L+I, K ) )*XK
338 S = S + ABS( AB( L+I, K ) )*ABS( X( I, J ) )
340 WORK( K ) = WORK( K ) + S
345 IF( WORK( I ).GT.SAFE2 ) THEN
346 S = MAX( S, ABS( WORK( N+I ) ) / WORK( I ) )
348 S = MAX( S, ( ABS( WORK( N+I ) )+SAFE1 ) /
349 $ ( WORK( I )+SAFE1 ) )
354 * Test stopping criterion. Continue iterating if
355 * 1) The residual BERR(J) is larger than machine epsilon, and
356 * 2) BERR(J) decreased by at least a factor of 2 during the
357 * last iteration, and
358 * 3) At most ITMAX iterations tried.
360 IF( BERR( J ).GT.EPS .AND. TWO*BERR( J ).LE.LSTRES .AND.
361 $ COUNT.LE.ITMAX ) THEN
363 * Update solution and try again.
365 CALL DPBTRS( UPLO, N, KD, 1, AFB, LDAFB, WORK( N+1 ), N,
367 CALL DAXPY( N, ONE, WORK( N+1 ), 1, X( 1, J ), 1 )
373 * Bound error from formula
375 * norm(X - XTRUE) / norm(X) .le. FERR =
377 * ( abs(R) + NZ*EPS*( abs(A)*abs(X)+abs(B) ))) / norm(X)
380 * norm(Z) is the magnitude of the largest component of Z
381 * inv(A) is the inverse of A
382 * abs(Z) is the componentwise absolute value of the matrix or
384 * NZ is the maximum number of nonzeros in any row of A, plus 1
385 * EPS is machine epsilon
387 * The i-th component of abs(R)+NZ*EPS*(abs(A)*abs(X)+abs(B))
388 * is incremented by SAFE1 if the i-th component of
389 * abs(A)*abs(X) + abs(B) is less than SAFE2.
391 * Use DLACN2 to estimate the infinity-norm of the matrix
393 * where W = abs(R) + NZ*EPS*( abs(A)*abs(X)+abs(B) )))
396 IF( WORK( I ).GT.SAFE2 ) THEN
397 WORK( I ) = ABS( WORK( N+I ) ) + NZ*EPS*WORK( I )
399 WORK( I ) = ABS( WORK( N+I ) ) + NZ*EPS*WORK( I ) + SAFE1
405 CALL DLACN2( N, WORK( 2*N+1 ), WORK( N+1 ), IWORK, FERR( J ),
410 * Multiply by diag(W)*inv(A**T).
412 CALL DPBTRS( UPLO, N, KD, 1, AFB, LDAFB, WORK( N+1 ), N,
415 WORK( N+I ) = WORK( N+I )*WORK( I )
417 ELSE IF( KASE.EQ.2 ) THEN
419 * Multiply by inv(A)*diag(W).
422 WORK( N+I ) = WORK( N+I )*WORK( I )
424 CALL DPBTRS( UPLO, N, KD, 1, AFB, LDAFB, WORK( N+1 ), N,
434 LSTRES = MAX( LSTRES, ABS( X( I, J ) ) )
437 $ FERR( J ) = FERR( J ) / LSTRES