1: *> \brief \b DPBRFS
2: *
3: * =========== DOCUMENTATION ===========
4: *
5: * Online html documentation available at
6: * http://www.netlib.org/lapack/explore-html/
7: *
8: *> \htmlonly
9: *> Download DPBRFS + dependencies
10: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dpbrfs.f">
11: *> [TGZ]</a>
12: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dpbrfs.f">
13: *> [ZIP]</a>
14: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dpbrfs.f">
15: *> [TXT]</a>
16: *> \endhtmlonly
17: *
18: * Definition:
19: * ===========
20: *
21: * SUBROUTINE DPBRFS( UPLO, N, KD, NRHS, AB, LDAB, AFB, LDAFB, B,
22: * LDB, X, LDX, FERR, BERR, WORK, IWORK, INFO )
23: *
24: * .. Scalar Arguments ..
25: * CHARACTER UPLO
26: * INTEGER INFO, KD, LDAB, LDAFB, LDB, LDX, N, NRHS
27: * ..
28: * .. Array Arguments ..
29: * INTEGER IWORK( * )
30: * DOUBLE PRECISION AB( LDAB, * ), AFB( LDAFB, * ), B( LDB, * ),
31: * $ BERR( * ), FERR( * ), WORK( * ), X( LDX, * )
32: * ..
33: *
34: *
35: *> \par Purpose:
36: * =============
37: *>
38: *> \verbatim
39: *>
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
43: *> for the solution.
44: *> \endverbatim
45: *
46: * Arguments:
47: * ==========
48: *
49: *> \param[in] UPLO
50: *> \verbatim
51: *> UPLO is CHARACTER*1
52: *> = 'U': Upper triangle of A is stored;
53: *> = 'L': Lower triangle of A is stored.
54: *> \endverbatim
55: *>
56: *> \param[in] N
57: *> \verbatim
58: *> N is INTEGER
59: *> The order of the matrix A. N >= 0.
60: *> \endverbatim
61: *>
62: *> \param[in] KD
63: *> \verbatim
64: *> KD is INTEGER
65: *> The number of superdiagonals of the matrix A if UPLO = 'U',
66: *> or the number of subdiagonals if UPLO = 'L'. KD >= 0.
67: *> \endverbatim
68: *>
69: *> \param[in] NRHS
70: *> \verbatim
71: *> NRHS is INTEGER
72: *> The number of right hand sides, i.e., the number of columns
73: *> of the matrices B and X. NRHS >= 0.
74: *> \endverbatim
75: *>
76: *> \param[in] AB
77: *> \verbatim
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).
84: *> \endverbatim
85: *>
86: *> \param[in] LDAB
87: *> \verbatim
88: *> LDAB is INTEGER
89: *> The leading dimension of the array AB. LDAB >= KD+1.
90: *> \endverbatim
91: *>
92: *> \param[in] AFB
93: *> \verbatim
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).
98: *> \endverbatim
99: *>
100: *> \param[in] LDAFB
101: *> \verbatim
102: *> LDAFB is INTEGER
103: *> The leading dimension of the array AFB. LDAFB >= KD+1.
104: *> \endverbatim
105: *>
106: *> \param[in] B
107: *> \verbatim
108: *> B is DOUBLE PRECISION array, dimension (LDB,NRHS)
109: *> The right hand side matrix B.
110: *> \endverbatim
111: *>
112: *> \param[in] LDB
113: *> \verbatim
114: *> LDB is INTEGER
115: *> The leading dimension of the array B. LDB >= max(1,N).
116: *> \endverbatim
117: *>
118: *> \param[in,out] X
119: *> \verbatim
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.
123: *> \endverbatim
124: *>
125: *> \param[in] LDX
126: *> \verbatim
127: *> LDX is INTEGER
128: *> The leading dimension of the array X. LDX >= max(1,N).
129: *> \endverbatim
130: *>
131: *> \param[out] FERR
132: *> \verbatim
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.
142: *> \endverbatim
143: *>
144: *> \param[out] BERR
145: *> \verbatim
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).
150: *> \endverbatim
151: *>
152: *> \param[out] WORK
153: *> \verbatim
154: *> WORK is DOUBLE PRECISION array, dimension (3*N)
155: *> \endverbatim
156: *>
157: *> \param[out] IWORK
158: *> \verbatim
159: *> IWORK is INTEGER array, dimension (N)
160: *> \endverbatim
161: *>
162: *> \param[out] INFO
163: *> \verbatim
164: *> INFO is INTEGER
165: *> = 0: successful exit
166: *> < 0: if INFO = -i, the i-th argument had an illegal value
167: *> \endverbatim
168: *
169: *> \par Internal Parameters:
170: * =========================
171: *>
172: *> \verbatim
173: *> ITMAX is the maximum number of steps of iterative refinement.
174: *> \endverbatim
175: *
176: * Authors:
177: * ========
178: *
179: *> \author Univ. of Tennessee
180: *> \author Univ. of California Berkeley
181: *> \author Univ. of Colorado Denver
182: *> \author NAG Ltd.
183: *
184: *> \ingroup doubleOTHERcomputational
185: *
186: * =====================================================================
187: SUBROUTINE DPBRFS( UPLO, N, KD, NRHS, AB, LDAB, AFB, LDAFB, B,
188: $ LDB, X, LDX, FERR, BERR, WORK, IWORK, INFO )
189: *
190: * -- LAPACK computational routine --
191: * -- LAPACK is a software package provided by Univ. of Tennessee, --
192: * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
193: *
194: * .. Scalar Arguments ..
195: CHARACTER UPLO
196: INTEGER INFO, KD, LDAB, LDAFB, LDB, LDX, N, NRHS
197: * ..
198: * .. Array Arguments ..
199: INTEGER IWORK( * )
200: DOUBLE PRECISION AB( LDAB, * ), AFB( LDAFB, * ), B( LDB, * ),
201: $ BERR( * ), FERR( * ), WORK( * ), X( LDX, * )
202: * ..
203: *
204: * =====================================================================
205: *
206: * .. Parameters ..
207: INTEGER ITMAX
208: PARAMETER ( ITMAX = 5 )
209: DOUBLE PRECISION ZERO
210: PARAMETER ( ZERO = 0.0D+0 )
211: DOUBLE PRECISION ONE
212: PARAMETER ( ONE = 1.0D+0 )
213: DOUBLE PRECISION TWO
214: PARAMETER ( TWO = 2.0D+0 )
215: DOUBLE PRECISION THREE
216: PARAMETER ( THREE = 3.0D+0 )
217: * ..
218: * .. Local Scalars ..
219: LOGICAL UPPER
220: INTEGER COUNT, I, J, K, KASE, L, NZ
221: DOUBLE PRECISION EPS, LSTRES, S, SAFE1, SAFE2, SAFMIN, XK
222: * ..
223: * .. Local Arrays ..
224: INTEGER ISAVE( 3 )
225: * ..
226: * .. External Subroutines ..
227: EXTERNAL DAXPY, DCOPY, DLACN2, DPBTRS, DSBMV, XERBLA
228: * ..
229: * .. Intrinsic Functions ..
230: INTRINSIC ABS, MAX, MIN
231: * ..
232: * .. External Functions ..
233: LOGICAL LSAME
234: DOUBLE PRECISION DLAMCH
235: EXTERNAL LSAME, DLAMCH
236: * ..
237: * .. Executable Statements ..
238: *
239: * Test the input parameters.
240: *
241: INFO = 0
242: UPPER = LSAME( UPLO, 'U' )
243: IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
244: INFO = -1
245: ELSE IF( N.LT.0 ) THEN
246: INFO = -2
247: ELSE IF( KD.LT.0 ) THEN
248: INFO = -3
249: ELSE IF( NRHS.LT.0 ) THEN
250: INFO = -4
251: ELSE IF( LDAB.LT.KD+1 ) THEN
252: INFO = -6
253: ELSE IF( LDAFB.LT.KD+1 ) THEN
254: INFO = -8
255: ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
256: INFO = -10
257: ELSE IF( LDX.LT.MAX( 1, N ) ) THEN
258: INFO = -12
259: END IF
260: IF( INFO.NE.0 ) THEN
261: CALL XERBLA( 'DPBRFS', -INFO )
262: RETURN
263: END IF
264: *
265: * Quick return if possible
266: *
267: IF( N.EQ.0 .OR. NRHS.EQ.0 ) THEN
268: DO 10 J = 1, NRHS
269: FERR( J ) = ZERO
270: BERR( J ) = ZERO
271: 10 CONTINUE
272: RETURN
273: END IF
274: *
275: * NZ = maximum number of nonzero elements in each row of A, plus 1
276: *
277: NZ = MIN( N+1, 2*KD+2 )
278: EPS = DLAMCH( 'Epsilon' )
279: SAFMIN = DLAMCH( 'Safe minimum' )
280: SAFE1 = NZ*SAFMIN
281: SAFE2 = SAFE1 / EPS
282: *
283: * Do for each right hand side
284: *
285: DO 140 J = 1, NRHS
286: *
287: COUNT = 1
288: LSTRES = THREE
289: 20 CONTINUE
290: *
291: * Loop until stopping criterion is satisfied.
292: *
293: * Compute residual R = B - A * X
294: *
295: CALL DCOPY( N, B( 1, J ), 1, WORK( N+1 ), 1 )
296: CALL DSBMV( UPLO, N, KD, -ONE, AB, LDAB, X( 1, J ), 1, ONE,
297: $ WORK( N+1 ), 1 )
298: *
299: * Compute componentwise relative backward error from formula
300: *
301: * max(i) ( abs(R(i)) / ( abs(A)*abs(X) + abs(B) )(i) )
302: *
303: * where abs(Z) is the componentwise absolute value of the matrix
304: * or vector Z. If the i-th component of the denominator is less
305: * than SAFE2, then SAFE1 is added to the i-th components of the
306: * numerator and denominator before dividing.
307: *
308: DO 30 I = 1, N
309: WORK( I ) = ABS( B( I, J ) )
310: 30 CONTINUE
311: *
312: * Compute abs(A)*abs(X) + abs(B).
313: *
314: IF( UPPER ) THEN
315: DO 50 K = 1, N
316: S = ZERO
317: XK = ABS( X( K, J ) )
318: L = KD + 1 - K
319: DO 40 I = MAX( 1, K-KD ), K - 1
320: WORK( I ) = WORK( I ) + ABS( AB( L+I, K ) )*XK
321: S = S + ABS( AB( L+I, K ) )*ABS( X( I, J ) )
322: 40 CONTINUE
323: WORK( K ) = WORK( K ) + ABS( AB( KD+1, K ) )*XK + S
324: 50 CONTINUE
325: ELSE
326: DO 70 K = 1, N
327: S = ZERO
328: XK = ABS( X( K, J ) )
329: WORK( K ) = WORK( K ) + ABS( AB( 1, K ) )*XK
330: L = 1 - K
331: DO 60 I = K + 1, MIN( N, K+KD )
332: WORK( I ) = WORK( I ) + ABS( AB( L+I, K ) )*XK
333: S = S + ABS( AB( L+I, K ) )*ABS( X( I, J ) )
334: 60 CONTINUE
335: WORK( K ) = WORK( K ) + S
336: 70 CONTINUE
337: END IF
338: S = ZERO
339: DO 80 I = 1, N
340: IF( WORK( I ).GT.SAFE2 ) THEN
341: S = MAX( S, ABS( WORK( N+I ) ) / WORK( I ) )
342: ELSE
343: S = MAX( S, ( ABS( WORK( N+I ) )+SAFE1 ) /
344: $ ( WORK( I )+SAFE1 ) )
345: END IF
346: 80 CONTINUE
347: BERR( J ) = S
348: *
349: * Test stopping criterion. Continue iterating if
350: * 1) The residual BERR(J) is larger than machine epsilon, and
351: * 2) BERR(J) decreased by at least a factor of 2 during the
352: * last iteration, and
353: * 3) At most ITMAX iterations tried.
354: *
355: IF( BERR( J ).GT.EPS .AND. TWO*BERR( J ).LE.LSTRES .AND.
356: $ COUNT.LE.ITMAX ) THEN
357: *
358: * Update solution and try again.
359: *
360: CALL DPBTRS( UPLO, N, KD, 1, AFB, LDAFB, WORK( N+1 ), N,
361: $ INFO )
362: CALL DAXPY( N, ONE, WORK( N+1 ), 1, X( 1, J ), 1 )
363: LSTRES = BERR( J )
364: COUNT = COUNT + 1
365: GO TO 20
366: END IF
367: *
368: * Bound error from formula
369: *
370: * norm(X - XTRUE) / norm(X) .le. FERR =
371: * norm( abs(inv(A))*
372: * ( abs(R) + NZ*EPS*( abs(A)*abs(X)+abs(B) ))) / norm(X)
373: *
374: * where
375: * norm(Z) is the magnitude of the largest component of Z
376: * inv(A) is the inverse of A
377: * abs(Z) is the componentwise absolute value of the matrix or
378: * vector Z
379: * NZ is the maximum number of nonzeros in any row of A, plus 1
380: * EPS is machine epsilon
381: *
382: * The i-th component of abs(R)+NZ*EPS*(abs(A)*abs(X)+abs(B))
383: * is incremented by SAFE1 if the i-th component of
384: * abs(A)*abs(X) + abs(B) is less than SAFE2.
385: *
386: * Use DLACN2 to estimate the infinity-norm of the matrix
387: * inv(A) * diag(W),
388: * where W = abs(R) + NZ*EPS*( abs(A)*abs(X)+abs(B) )))
389: *
390: DO 90 I = 1, N
391: IF( WORK( I ).GT.SAFE2 ) THEN
392: WORK( I ) = ABS( WORK( N+I ) ) + NZ*EPS*WORK( I )
393: ELSE
394: WORK( I ) = ABS( WORK( N+I ) ) + NZ*EPS*WORK( I ) + SAFE1
395: END IF
396: 90 CONTINUE
397: *
398: KASE = 0
399: 100 CONTINUE
400: CALL DLACN2( N, WORK( 2*N+1 ), WORK( N+1 ), IWORK, FERR( J ),
401: $ KASE, ISAVE )
402: IF( KASE.NE.0 ) THEN
403: IF( KASE.EQ.1 ) THEN
404: *
405: * Multiply by diag(W)*inv(A**T).
406: *
407: CALL DPBTRS( UPLO, N, KD, 1, AFB, LDAFB, WORK( N+1 ), N,
408: $ INFO )
409: DO 110 I = 1, N
410: WORK( N+I ) = WORK( N+I )*WORK( I )
411: 110 CONTINUE
412: ELSE IF( KASE.EQ.2 ) THEN
413: *
414: * Multiply by inv(A)*diag(W).
415: *
416: DO 120 I = 1, N
417: WORK( N+I ) = WORK( N+I )*WORK( I )
418: 120 CONTINUE
419: CALL DPBTRS( UPLO, N, KD, 1, AFB, LDAFB, WORK( N+1 ), N,
420: $ INFO )
421: END IF
422: GO TO 100
423: END IF
424: *
425: * Normalize error.
426: *
427: LSTRES = ZERO
428: DO 130 I = 1, N
429: LSTRES = MAX( LSTRES, ABS( X( I, J ) ) )
430: 130 CONTINUE
431: IF( LSTRES.NE.ZERO )
432: $ FERR( J ) = FERR( J ) / LSTRES
433: *
434: 140 CONTINUE
435: *
436: RETURN
437: *
438: * End of DPBRFS
439: *
440: END
CVSweb interface <joel.bertrand@systella.fr>