LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
dpbrfs.f
Go to the documentation of this file.
1*> \brief \b DPBRFS
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download DPBRFS + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dpbrfs.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dpbrfs.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dpbrfs.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE DPBRFS( UPLO, N, KD, NRHS, AB, LDAB, AFB, LDAFB, B,
20* LDB, X, LDX, FERR, BERR, WORK, IWORK, INFO )
21*
22* .. Scalar Arguments ..
23* CHARACTER UPLO
24* INTEGER INFO, KD, LDAB, LDAFB, LDB, LDX, N, NRHS
25* ..
26* .. Array Arguments ..
27* INTEGER IWORK( * )
28* DOUBLE PRECISION AB( LDAB, * ), AFB( LDAFB, * ), B( LDB, * ),
29* $ BERR( * ), FERR( * ), WORK( * ), X( LDX, * )
30* ..
31*
32*
33*> \par Purpose:
34* =============
35*>
36*> \verbatim
37*>
38*> DPBRFS improves the computed solution to a system of linear
39*> equations when the coefficient matrix is symmetric positive definite
40*> and banded, and provides error bounds and backward error estimates
41*> for the solution.
42*> \endverbatim
43*
44* Arguments:
45* ==========
46*
47*> \param[in] UPLO
48*> \verbatim
49*> UPLO is CHARACTER*1
50*> = 'U': Upper triangle of A is stored;
51*> = 'L': Lower triangle of A is stored.
52*> \endverbatim
53*>
54*> \param[in] N
55*> \verbatim
56*> N is INTEGER
57*> The order of the matrix A. N >= 0.
58*> \endverbatim
59*>
60*> \param[in] KD
61*> \verbatim
62*> KD is INTEGER
63*> The number of superdiagonals of the matrix A if UPLO = 'U',
64*> or the number of subdiagonals if UPLO = 'L'. KD >= 0.
65*> \endverbatim
66*>
67*> \param[in] NRHS
68*> \verbatim
69*> NRHS is INTEGER
70*> The number of right hand sides, i.e., the number of columns
71*> of the matrices B and X. NRHS >= 0.
72*> \endverbatim
73*>
74*> \param[in] AB
75*> \verbatim
76*> AB is DOUBLE PRECISION array, dimension (LDAB,N)
77*> The upper or lower triangle of the symmetric band matrix A,
78*> stored in the first KD+1 rows of the array. The j-th column
79*> of A is stored in the j-th column of the array AB as follows:
80*> if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j;
81*> if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+kd).
82*> \endverbatim
83*>
84*> \param[in] LDAB
85*> \verbatim
86*> LDAB is INTEGER
87*> The leading dimension of the array AB. LDAB >= KD+1.
88*> \endverbatim
89*>
90*> \param[in] AFB
91*> \verbatim
92*> AFB is DOUBLE PRECISION array, dimension (LDAFB,N)
93*> The triangular factor U or L from the Cholesky factorization
94*> A = U**T*U or A = L*L**T of the band matrix A as computed by
95*> DPBTRF, in the same storage format as A (see AB).
96*> \endverbatim
97*>
98*> \param[in] LDAFB
99*> \verbatim
100*> LDAFB is INTEGER
101*> The leading dimension of the array AFB. LDAFB >= KD+1.
102*> \endverbatim
103*>
104*> \param[in] B
105*> \verbatim
106*> B is DOUBLE PRECISION array, dimension (LDB,NRHS)
107*> The right hand side matrix B.
108*> \endverbatim
109*>
110*> \param[in] LDB
111*> \verbatim
112*> LDB is INTEGER
113*> The leading dimension of the array B. LDB >= max(1,N).
114*> \endverbatim
115*>
116*> \param[in,out] X
117*> \verbatim
118*> X is DOUBLE PRECISION array, dimension (LDX,NRHS)
119*> On entry, the solution matrix X, as computed by DPBTRS.
120*> On exit, the improved solution matrix X.
121*> \endverbatim
122*>
123*> \param[in] LDX
124*> \verbatim
125*> LDX is INTEGER
126*> The leading dimension of the array X. LDX >= max(1,N).
127*> \endverbatim
128*>
129*> \param[out] FERR
130*> \verbatim
131*> FERR is DOUBLE PRECISION array, dimension (NRHS)
132*> The estimated forward error bound for each solution vector
133*> X(j) (the j-th column of the solution matrix X).
134*> If XTRUE is the true solution corresponding to X(j), FERR(j)
135*> is an estimated upper bound for the magnitude of the largest
136*> element in (X(j) - XTRUE) divided by the magnitude of the
137*> largest element in X(j). The estimate is as reliable as
138*> the estimate for RCOND, and is almost always a slight
139*> overestimate of the true error.
140*> \endverbatim
141*>
142*> \param[out] BERR
143*> \verbatim
144*> BERR is DOUBLE PRECISION array, dimension (NRHS)
145*> The componentwise relative backward error of each solution
146*> vector X(j) (i.e., the smallest relative change in
147*> any element of A or B that makes X(j) an exact solution).
148*> \endverbatim
149*>
150*> \param[out] WORK
151*> \verbatim
152*> WORK is DOUBLE PRECISION array, dimension (3*N)
153*> \endverbatim
154*>
155*> \param[out] IWORK
156*> \verbatim
157*> IWORK is INTEGER array, dimension (N)
158*> \endverbatim
159*>
160*> \param[out] INFO
161*> \verbatim
162*> INFO is INTEGER
163*> = 0: successful exit
164*> < 0: if INFO = -i, the i-th argument had an illegal value
165*> \endverbatim
166*
167*> \par Internal Parameters:
168* =========================
169*>
170*> \verbatim
171*> ITMAX is the maximum number of steps of iterative refinement.
172*> \endverbatim
173*
174* Authors:
175* ========
176*
177*> \author Univ. of Tennessee
178*> \author Univ. of California Berkeley
179*> \author Univ. of Colorado Denver
180*> \author NAG Ltd.
181*
182*> \ingroup pbrfs
183*
184* =====================================================================
185 SUBROUTINE dpbrfs( UPLO, N, KD, NRHS, AB, LDAB, AFB, LDAFB, B,
186 $ LDB, X, LDX, FERR, BERR, WORK, IWORK, INFO )
187*
188* -- LAPACK computational routine --
189* -- LAPACK is a software package provided by Univ. of Tennessee, --
190* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
191*
192* .. Scalar Arguments ..
193 CHARACTER UPLO
194 INTEGER INFO, KD, LDAB, LDAFB, LDB, LDX, N, NRHS
195* ..
196* .. Array Arguments ..
197 INTEGER IWORK( * )
198 DOUBLE PRECISION AB( LDAB, * ), AFB( LDAFB, * ), B( LDB, * ),
199 $ berr( * ), ferr( * ), work( * ), x( ldx, * )
200* ..
201*
202* =====================================================================
203*
204* .. Parameters ..
205 INTEGER ITMAX
206 parameter( itmax = 5 )
207 DOUBLE PRECISION ZERO
208 parameter( zero = 0.0d+0 )
209 DOUBLE PRECISION ONE
210 parameter( one = 1.0d+0 )
211 DOUBLE PRECISION TWO
212 parameter( two = 2.0d+0 )
213 DOUBLE PRECISION THREE
214 parameter( three = 3.0d+0 )
215* ..
216* .. Local Scalars ..
217 LOGICAL UPPER
218 INTEGER COUNT, I, J, K, KASE, L, NZ
219 DOUBLE PRECISION EPS, LSTRES, S, SAFE1, SAFE2, SAFMIN, XK
220* ..
221* .. Local Arrays ..
222 INTEGER ISAVE( 3 )
223* ..
224* .. External Subroutines ..
225 EXTERNAL daxpy, dcopy, dlacn2, dpbtrs, dsbmv,
226 $ xerbla
227* ..
228* .. Intrinsic Functions ..
229 INTRINSIC abs, max, min
230* ..
231* .. External Functions ..
232 LOGICAL LSAME
233 DOUBLE PRECISION DLAMCH
234 EXTERNAL lsame, dlamch
235* ..
236* .. Executable Statements ..
237*
238* Test the input parameters.
239*
240 info = 0
241 upper = lsame( uplo, 'U' )
242 IF( .NOT.upper .AND. .NOT.lsame( uplo, 'L' ) ) THEN
243 info = -1
244 ELSE IF( n.LT.0 ) THEN
245 info = -2
246 ELSE IF( kd.LT.0 ) THEN
247 info = -3
248 ELSE IF( nrhs.LT.0 ) THEN
249 info = -4
250 ELSE IF( ldab.LT.kd+1 ) THEN
251 info = -6
252 ELSE IF( ldafb.LT.kd+1 ) THEN
253 info = -8
254 ELSE IF( ldb.LT.max( 1, n ) ) THEN
255 info = -10
256 ELSE IF( ldx.LT.max( 1, n ) ) THEN
257 info = -12
258 END IF
259 IF( info.NE.0 ) THEN
260 CALL xerbla( 'DPBRFS', -info )
261 RETURN
262 END IF
263*
264* Quick return if possible
265*
266 IF( n.EQ.0 .OR. nrhs.EQ.0 ) THEN
267 DO 10 j = 1, nrhs
268 ferr( j ) = zero
269 berr( j ) = zero
270 10 CONTINUE
271 RETURN
272 END IF
273*
274* NZ = maximum number of nonzero elements in each row of A, plus 1
275*
276 nz = min( n+1, 2*kd+2 )
277 eps = dlamch( 'Epsilon' )
278 safmin = dlamch( 'Safe minimum' )
279 safe1 = nz*safmin
280 safe2 = safe1 / eps
281*
282* Do for each right hand side
283*
284 DO 140 j = 1, nrhs
285*
286 count = 1
287 lstres = three
288 20 CONTINUE
289*
290* Loop until stopping criterion is satisfied.
291*
292* Compute residual R = B - A * X
293*
294 CALL dcopy( n, b( 1, j ), 1, work( n+1 ), 1 )
295 CALL dsbmv( uplo, n, kd, -one, ab, ldab, x( 1, j ), 1, one,
296 $ work( n+1 ), 1 )
297*
298* Compute componentwise relative backward error from formula
299*
300* max(i) ( abs(R(i)) / ( abs(A)*abs(X) + abs(B) )(i) )
301*
302* where abs(Z) is the componentwise absolute value of the matrix
303* or vector Z. If the i-th component of the denominator is less
304* than SAFE2, then SAFE1 is added to the i-th components of the
305* numerator and denominator before dividing.
306*
307 DO 30 i = 1, n
308 work( i ) = abs( b( i, j ) )
309 30 CONTINUE
310*
311* Compute abs(A)*abs(X) + abs(B).
312*
313 IF( upper ) THEN
314 DO 50 k = 1, n
315 s = zero
316 xk = abs( x( k, j ) )
317 l = kd + 1 - k
318 DO 40 i = max( 1, k-kd ), k - 1
319 work( i ) = work( i ) + abs( ab( l+i, k ) )*xk
320 s = s + abs( ab( l+i, k ) )*abs( x( i, j ) )
321 40 CONTINUE
322 work( k ) = work( k ) + abs( ab( kd+1, k ) )*xk + s
323 50 CONTINUE
324 ELSE
325 DO 70 k = 1, n
326 s = zero
327 xk = abs( x( k, j ) )
328 work( k ) = work( k ) + abs( ab( 1, k ) )*xk
329 l = 1 - k
330 DO 60 i = k + 1, min( n, k+kd )
331 work( i ) = work( i ) + abs( ab( l+i, k ) )*xk
332 s = s + abs( ab( l+i, k ) )*abs( x( i, j ) )
333 60 CONTINUE
334 work( k ) = work( k ) + s
335 70 CONTINUE
336 END IF
337 s = zero
338 DO 80 i = 1, n
339 IF( work( i ).GT.safe2 ) THEN
340 s = max( s, abs( work( n+i ) ) / work( i ) )
341 ELSE
342 s = max( s, ( abs( work( n+i ) )+safe1 ) /
343 $ ( work( i )+safe1 ) )
344 END IF
345 80 CONTINUE
346 berr( j ) = s
347*
348* Test stopping criterion. Continue iterating if
349* 1) The residual BERR(J) is larger than machine epsilon, and
350* 2) BERR(J) decreased by at least a factor of 2 during the
351* last iteration, and
352* 3) At most ITMAX iterations tried.
353*
354 IF( berr( j ).GT.eps .AND. two*berr( j ).LE.lstres .AND.
355 $ count.LE.itmax ) THEN
356*
357* Update solution and try again.
358*
359 CALL dpbtrs( uplo, n, kd, 1, afb, ldafb, work( n+1 ), n,
360 $ info )
361 CALL daxpy( n, one, work( n+1 ), 1, x( 1, j ), 1 )
362 lstres = berr( j )
363 count = count + 1
364 GO TO 20
365 END IF
366*
367* Bound error from formula
368*
369* norm(X - XTRUE) / norm(X) .le. FERR =
370* norm( abs(inv(A))*
371* ( abs(R) + NZ*EPS*( abs(A)*abs(X)+abs(B) ))) / norm(X)
372*
373* where
374* norm(Z) is the magnitude of the largest component of Z
375* inv(A) is the inverse of A
376* abs(Z) is the componentwise absolute value of the matrix or
377* vector Z
378* NZ is the maximum number of nonzeros in any row of A, plus 1
379* EPS is machine epsilon
380*
381* The i-th component of abs(R)+NZ*EPS*(abs(A)*abs(X)+abs(B))
382* is incremented by SAFE1 if the i-th component of
383* abs(A)*abs(X) + abs(B) is less than SAFE2.
384*
385* Use DLACN2 to estimate the infinity-norm of the matrix
386* inv(A) * diag(W),
387* where W = abs(R) + NZ*EPS*( abs(A)*abs(X)+abs(B) )))
388*
389 DO 90 i = 1, n
390 IF( work( i ).GT.safe2 ) THEN
391 work( i ) = abs( work( n+i ) ) + nz*eps*work( i )
392 ELSE
393 work( i ) = abs( work( n+i ) ) + nz*eps*work( i ) + safe1
394 END IF
395 90 CONTINUE
396*
397 kase = 0
398 100 CONTINUE
399 CALL dlacn2( n, work( 2*n+1 ), work( n+1 ), iwork,
400 $ 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 ),
408 $ n,
409 $ info )
410 DO 110 i = 1, n
411 work( n+i ) = work( n+i )*work( i )
412 110 CONTINUE
413 ELSE IF( kase.EQ.2 ) THEN
414*
415* Multiply by inv(A)*diag(W).
416*
417 DO 120 i = 1, n
418 work( n+i ) = work( n+i )*work( i )
419 120 CONTINUE
420 CALL dpbtrs( uplo, n, kd, 1, afb, ldafb, work( n+1 ),
421 $ n,
422 $ info )
423 END IF
424 GO TO 100
425 END IF
426*
427* Normalize error.
428*
429 lstres = zero
430 DO 130 i = 1, n
431 lstres = max( lstres, abs( x( i, j ) ) )
432 130 CONTINUE
433 IF( lstres.NE.zero )
434 $ ferr( j ) = ferr( j ) / lstres
435*
436 140 CONTINUE
437*
438 RETURN
439*
440* End of DPBRFS
441*
442 END
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine daxpy(n, da, dx, incx, dy, incy)
DAXPY
Definition daxpy.f:89
subroutine dcopy(n, dx, incx, dy, incy)
DCOPY
Definition dcopy.f:82
subroutine dsbmv(uplo, n, k, alpha, a, lda, x, incx, beta, y, incy)
DSBMV
Definition dsbmv.f:184
subroutine dlacn2(n, v, x, isgn, est, kase, isave)
DLACN2 estimates the 1-norm of a square matrix, using reverse communication for evaluating matrix-vec...
Definition dlacn2.f:134
subroutine dpbrfs(uplo, n, kd, nrhs, ab, ldab, afb, ldafb, b, ldb, x, ldx, ferr, berr, work, iwork, info)
DPBRFS
Definition dpbrfs.f:187
subroutine dpbtrs(uplo, n, kd, nrhs, ab, ldab, b, ldb, info)
DPBTRS
Definition dpbtrs.f:119