LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches

◆ zpbrfs()

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

ZPBRFS

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

Purpose:
!>
!> ZPBRFS improves the computed solution to a system of linear
!> equations when the coefficient matrix is Hermitian 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 COMPLEX*16 array, dimension (LDAB,N)
!>          The upper or lower triangle of the Hermitian 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 COMPLEX*16 array, dimension (LDAFB,N)
!>          The triangular factor U or L from the Cholesky factorization
!>          A = U**H*U or A = L*L**H of the band matrix A as computed by
!>          ZPBTRF, 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 COMPLEX*16 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 COMPLEX*16 array, dimension (LDX,NRHS)
!>          On entry, the solution matrix X, as computed by ZPBTRS.
!>          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 COMPLEX*16 array, dimension (2*N)
!> 
[out]RWORK
!>          RWORK is DOUBLE PRECISION 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 zpbrfs.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 DOUBLE PRECISION BERR( * ), FERR( * ), RWORK( * )
198 COMPLEX*16 AB( LDAB, * ), AFB( LDAFB, * ), B( LDB, * ),
199 $ 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 COMPLEX*16 ONE
210 parameter( one = ( 1.0d+0, 0.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 COMPLEX*16 ZDUM
221* ..
222* .. Local Arrays ..
223 INTEGER ISAVE( 3 )
224* ..
225* .. External Subroutines ..
226 EXTERNAL xerbla, zaxpy, zcopy, zhbmv, zlacn2,
227 $ zpbtrs
228* ..
229* .. Intrinsic Functions ..
230 INTRINSIC abs, dble, dimag, max, min
231* ..
232* .. External Functions ..
233 LOGICAL LSAME
234 DOUBLE PRECISION DLAMCH
235 EXTERNAL lsame, dlamch
236* ..
237* .. Statement Functions ..
238 DOUBLE PRECISION CABS1
239* ..
240* .. Statement Function definitions ..
241 cabs1( zdum ) = abs( dble( zdum ) ) + abs( dimag( zdum ) )
242* ..
243* .. Executable Statements ..
244*
245* Test the input parameters.
246*
247 info = 0
248 upper = lsame( uplo, 'U' )
249 IF( .NOT.upper .AND. .NOT.lsame( uplo, 'L' ) ) THEN
250 info = -1
251 ELSE IF( n.LT.0 ) THEN
252 info = -2
253 ELSE IF( kd.LT.0 ) THEN
254 info = -3
255 ELSE IF( nrhs.LT.0 ) THEN
256 info = -4
257 ELSE IF( ldab.LT.kd+1 ) THEN
258 info = -6
259 ELSE IF( ldafb.LT.kd+1 ) THEN
260 info = -8
261 ELSE IF( ldb.LT.max( 1, n ) ) THEN
262 info = -10
263 ELSE IF( ldx.LT.max( 1, n ) ) THEN
264 info = -12
265 END IF
266 IF( info.NE.0 ) THEN
267 CALL xerbla( 'ZPBRFS', -info )
268 RETURN
269 END IF
270*
271* Quick return if possible
272*
273 IF( n.EQ.0 .OR. nrhs.EQ.0 ) THEN
274 DO 10 j = 1, nrhs
275 ferr( j ) = zero
276 berr( j ) = zero
277 10 CONTINUE
278 RETURN
279 END IF
280*
281* NZ = maximum number of nonzero elements in each row of A, plus 1
282*
283 nz = min( n+1, 2*kd+2 )
284 eps = dlamch( 'Epsilon' )
285 safmin = dlamch( 'Safe minimum' )
286 safe1 = nz*safmin
287 safe2 = safe1 / eps
288*
289* Do for each right hand side
290*
291 DO 140 j = 1, nrhs
292*
293 count = 1
294 lstres = three
295 20 CONTINUE
296*
297* Loop until stopping criterion is satisfied.
298*
299* Compute residual R = B - A * X
300*
301 CALL zcopy( n, b( 1, j ), 1, work, 1 )
302 CALL zhbmv( uplo, n, kd, -one, ab, ldab, x( 1, j ), 1, one,
303 $ work, 1 )
304*
305* Compute componentwise relative backward error from formula
306*
307* max(i) ( abs(R(i)) / ( abs(A)*abs(X) + abs(B) )(i) )
308*
309* where abs(Z) is the componentwise absolute value of the matrix
310* or vector Z. If the i-th component of the denominator is less
311* than SAFE2, then SAFE1 is added to the i-th components of the
312* numerator and denominator before dividing.
313*
314 DO 30 i = 1, n
315 rwork( i ) = cabs1( b( i, j ) )
316 30 CONTINUE
317*
318* Compute abs(A)*abs(X) + abs(B).
319*
320 IF( upper ) THEN
321 DO 50 k = 1, n
322 s = zero
323 xk = cabs1( x( k, j ) )
324 l = kd + 1 - k
325 DO 40 i = max( 1, k-kd ), k - 1
326 rwork( i ) = rwork( i ) + cabs1( ab( l+i, k ) )*xk
327 s = s + cabs1( ab( l+i, k ) )*cabs1( x( i, j ) )
328 40 CONTINUE
329 rwork( k ) = rwork( k ) + abs( dble( ab( kd+1, k ) ) )*
330 $ xk + s
331 50 CONTINUE
332 ELSE
333 DO 70 k = 1, n
334 s = zero
335 xk = cabs1( x( k, j ) )
336 rwork( k ) = rwork( k ) + abs( dble( ab( 1, k ) ) )*xk
337 l = 1 - k
338 DO 60 i = k + 1, min( n, k+kd )
339 rwork( i ) = rwork( i ) + cabs1( ab( l+i, k ) )*xk
340 s = s + cabs1( ab( l+i, k ) )*cabs1( x( i, j ) )
341 60 CONTINUE
342 rwork( k ) = rwork( k ) + s
343 70 CONTINUE
344 END IF
345 s = zero
346 DO 80 i = 1, n
347 IF( rwork( i ).GT.safe2 ) THEN
348 s = max( s, cabs1( work( i ) ) / rwork( i ) )
349 ELSE
350 s = max( s, ( cabs1( work( i ) )+safe1 ) /
351 $ ( rwork( i )+safe1 ) )
352 END IF
353 80 CONTINUE
354 berr( j ) = s
355*
356* Test stopping criterion. Continue iterating if
357* 1) The residual BERR(J) is larger than machine epsilon, and
358* 2) BERR(J) decreased by at least a factor of 2 during the
359* last iteration, and
360* 3) At most ITMAX iterations tried.
361*
362 IF( berr( j ).GT.eps .AND. two*berr( j ).LE.lstres .AND.
363 $ count.LE.itmax ) THEN
364*
365* Update solution and try again.
366*
367 CALL zpbtrs( uplo, n, kd, 1, afb, ldafb, work, n, info )
368 CALL zaxpy( n, one, work, 1, x( 1, j ), 1 )
369 lstres = berr( j )
370 count = count + 1
371 GO TO 20
372 END IF
373*
374* Bound error from formula
375*
376* norm(X - XTRUE) / norm(X) .le. FERR =
377* norm( abs(inv(A))*
378* ( abs(R) + NZ*EPS*( abs(A)*abs(X)+abs(B) ))) / norm(X)
379*
380* where
381* norm(Z) is the magnitude of the largest component of Z
382* inv(A) is the inverse of A
383* abs(Z) is the componentwise absolute value of the matrix or
384* vector Z
385* NZ is the maximum number of nonzeros in any row of A, plus 1
386* EPS is machine epsilon
387*
388* The i-th component of abs(R)+NZ*EPS*(abs(A)*abs(X)+abs(B))
389* is incremented by SAFE1 if the i-th component of
390* abs(A)*abs(X) + abs(B) is less than SAFE2.
391*
392* Use ZLACN2 to estimate the infinity-norm of the matrix
393* inv(A) * diag(W),
394* where W = abs(R) + NZ*EPS*( abs(A)*abs(X)+abs(B) )))
395*
396 DO 90 i = 1, n
397 IF( rwork( i ).GT.safe2 ) THEN
398 rwork( i ) = cabs1( work( i ) ) + nz*eps*rwork( i )
399 ELSE
400 rwork( i ) = cabs1( work( i ) ) + nz*eps*rwork( i ) +
401 $ safe1
402 END IF
403 90 CONTINUE
404*
405 kase = 0
406 100 CONTINUE
407 CALL zlacn2( n, work( n+1 ), work, ferr( j ), kase, isave )
408 IF( kase.NE.0 ) THEN
409 IF( kase.EQ.1 ) THEN
410*
411* Multiply by diag(W)*inv(A**H).
412*
413 CALL zpbtrs( uplo, n, kd, 1, afb, ldafb, work, n,
414 $ info )
415 DO 110 i = 1, n
416 work( i ) = rwork( i )*work( i )
417 110 CONTINUE
418 ELSE IF( kase.EQ.2 ) THEN
419*
420* Multiply by inv(A)*diag(W).
421*
422 DO 120 i = 1, n
423 work( i ) = rwork( i )*work( i )
424 120 CONTINUE
425 CALL zpbtrs( uplo, n, kd, 1, afb, ldafb, work, n,
426 $ info )
427 END IF
428 GO TO 100
429 END IF
430*
431* Normalize error.
432*
433 lstres = zero
434 DO 130 i = 1, n
435 lstres = max( lstres, cabs1( x( i, j ) ) )
436 130 CONTINUE
437 IF( lstres.NE.zero )
438 $ ferr( j ) = ferr( j ) / lstres
439*
440 140 CONTINUE
441*
442 RETURN
443*
444* End of ZPBRFS
445*
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine zaxpy(n, za, zx, incx, zy, incy)
ZAXPY
Definition zaxpy.f:88
subroutine zcopy(n, zx, incx, zy, incy)
ZCOPY
Definition zcopy.f:81
subroutine zhbmv(uplo, n, k, alpha, a, lda, x, incx, beta, y, incy)
ZHBMV
Definition zhbmv.f:187
subroutine zlacn2(n, v, x, est, kase, isave)
ZLACN2 estimates the 1-norm of a square matrix, using reverse communication for evaluating matrix-vec...
Definition zlacn2.f:131
double precision function dlamch(cmach)
DLAMCH
Definition dlamch.f:69
logical function lsame(ca, cb)
LSAME
Definition lsame.f:48
subroutine zpbtrs(uplo, n, kd, nrhs, ab, ldab, b, ldb, info)
ZPBTRS
Definition zpbtrs.f:119
Here is the call graph for this function:
Here is the caller graph for this function: