LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages

◆ dpbrfs()

subroutine dpbrfs ( character uplo,
integer n,
integer kd,
integer nrhs,
double precision, dimension( ldab, * ) ab,
integer ldab,
double precision, dimension( ldafb, * ) afb,
integer ldafb,
double precision, dimension( ldb, * ) b,
integer ldb,
double precision, dimension( ldx, * ) x,
integer ldx,
double precision, dimension( * ) ferr,
double precision, dimension( * ) berr,
double precision, dimension( * ) work,
integer, dimension( * ) iwork,
integer info )

DPBRFS

Download DPBRFS + dependencies [TGZ] [ZIP] [TXT]

Purpose:
!> !> DPBRFS improves the computed solution to a system of linear !> equations when the coefficient matrix is symmetric positive definite !> and banded, and provides error bounds and backward error estimates !> for the solution. !>
Parameters
[in]UPLO
!> UPLO is CHARACTER*1 !> = 'U': Upper triangle of A is stored; !> = 'L': Lower triangle of A is stored. !>
[in]N
!> N is INTEGER !> The order of the matrix A. N >= 0. !>
[in]KD
!> KD is INTEGER !> The number of superdiagonals of the matrix A if UPLO = 'U', !> or the number of subdiagonals if UPLO = 'L'. KD >= 0. !>
[in]NRHS
!> NRHS is INTEGER !> The number of right hand sides, i.e., the number of columns !> of the matrices B and X. NRHS >= 0. !>
[in]AB
!> AB is DOUBLE PRECISION array, dimension (LDAB,N) !> The upper or lower triangle of the symmetric band matrix A, !> stored in the first KD+1 rows of the array. The j-th column !> of A is stored in the j-th column of the array AB as follows: !> if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j; !> if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+kd). !>
[in]LDAB
!> LDAB is INTEGER !> The leading dimension of the array AB. LDAB >= KD+1. !>
[in]AFB
!> AFB is DOUBLE PRECISION array, dimension (LDAFB,N) !> The triangular factor U or L from the Cholesky factorization !> A = U**T*U or A = L*L**T of the band matrix A as computed by !> DPBTRF, in the same storage format as A (see AB). !>
[in]LDAFB
!> LDAFB is INTEGER !> The leading dimension of the array AFB. LDAFB >= KD+1. !>
[in]B
!> B is DOUBLE PRECISION array, dimension (LDB,NRHS) !> The right hand side matrix B. !>
[in]LDB
!> LDB is INTEGER !> The leading dimension of the array B. LDB >= max(1,N). !>
[in,out]X
!> X is DOUBLE PRECISION array, dimension (LDX,NRHS) !> On entry, the solution matrix X, as computed by DPBTRS. !> On exit, the improved solution matrix X. !>
[in]LDX
!> LDX is INTEGER !> The leading dimension of the array X. LDX >= max(1,N). !>
[out]FERR
!> FERR is DOUBLE PRECISION array, dimension (NRHS) !> The estimated forward error bound for each solution vector !> X(j) (the j-th column of the solution matrix X). !> If XTRUE is the true solution corresponding to X(j), FERR(j) !> is an estimated upper bound for the magnitude of the largest !> element in (X(j) - XTRUE) divided by the magnitude of the !> largest element in X(j). The estimate is as reliable as !> the estimate for RCOND, and is almost always a slight !> overestimate of the true error. !>
[out]BERR
!> BERR is DOUBLE PRECISION array, dimension (NRHS) !> The componentwise relative backward error of each solution !> vector X(j) (i.e., the smallest relative change in !> any element of A or B that makes X(j) an exact solution). !>
[out]WORK
!> WORK is DOUBLE PRECISION array, dimension (3*N) !>
[out]IWORK
!> IWORK is INTEGER array, dimension (N) !>
[out]INFO
!> INFO is INTEGER !> = 0: successful exit !> < 0: if INFO = -i, the i-th argument had an illegal value !>
Internal Parameters:
!> ITMAX is the maximum number of steps of iterative refinement. !>
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.

Definition at line 185 of file dpbrfs.f.

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*
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
double precision function dlamch(cmach)
DLAMCH
Definition dlamch.f:69
logical function lsame(ca, cb)
LSAME
Definition lsame.f:48
subroutine dpbtrs(uplo, n, kd, nrhs, ab, ldab, b, ldb, info)
DPBTRS
Definition dpbtrs.f:119
Here is the call graph for this function:
Here is the caller graph for this function: