Annotation of rpl/lapack/lapack/zpbrfs.f, revision 1.9
1.9 ! bertrand 1: *> \brief \b ZPBRFS
! 2: *
! 3: * =========== DOCUMENTATION ===========
! 4: *
! 5: * Online html documentation available at
! 6: * http://www.netlib.org/lapack/explore-html/
! 7: *
! 8: *> \htmlonly
! 9: *> Download ZPBRFS + dependencies
! 10: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zpbrfs.f">
! 11: *> [TGZ]</a>
! 12: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zpbrfs.f">
! 13: *> [ZIP]</a>
! 14: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zpbrfs.f">
! 15: *> [TXT]</a>
! 16: *> \endhtmlonly
! 17: *
! 18: * Definition:
! 19: * ===========
! 20: *
! 21: * SUBROUTINE ZPBRFS( UPLO, N, KD, NRHS, AB, LDAB, AFB, LDAFB, B,
! 22: * LDB, X, LDX, FERR, BERR, WORK, RWORK, INFO )
! 23: *
! 24: * .. Scalar Arguments ..
! 25: * CHARACTER UPLO
! 26: * INTEGER INFO, KD, LDAB, LDAFB, LDB, LDX, N, NRHS
! 27: * ..
! 28: * .. Array Arguments ..
! 29: * DOUBLE PRECISION BERR( * ), FERR( * ), RWORK( * )
! 30: * COMPLEX*16 AB( LDAB, * ), AFB( LDAFB, * ), B( LDB, * ),
! 31: * $ WORK( * ), X( LDX, * )
! 32: * ..
! 33: *
! 34: *
! 35: *> \par Purpose:
! 36: * =============
! 37: *>
! 38: *> \verbatim
! 39: *>
! 40: *> ZPBRFS improves the computed solution to a system of linear
! 41: *> equations when the coefficient matrix is Hermitian 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 Hermitian 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 COMPLEX*16 array, dimension (LDAFB,N)
! 95: *> The triangular factor U or L from the Cholesky factorization
! 96: *> A = U**H*U or A = L*L**H of the band matrix A as computed by
! 97: *> ZPBTRF, 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 COMPLEX*16 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 COMPLEX*16 array, dimension (LDX,NRHS)
! 121: *> On entry, the solution matrix X, as computed by ZPBTRS.
! 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 COMPLEX*16 array, dimension (2*N)
! 155: *> \endverbatim
! 156: *>
! 157: *> \param[out] RWORK
! 158: *> \verbatim
! 159: *> RWORK is DOUBLE PRECISION 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: *> \date November 2011
! 185: *
! 186: *> \ingroup complex16OTHERcomputational
! 187: *
! 188: * =====================================================================
1.1 bertrand 189: SUBROUTINE ZPBRFS( UPLO, N, KD, NRHS, AB, LDAB, AFB, LDAFB, B,
190: $ LDB, X, LDX, FERR, BERR, WORK, RWORK, INFO )
191: *
1.9 ! bertrand 192: * -- LAPACK computational routine (version 3.4.0) --
1.1 bertrand 193: * -- LAPACK is a software package provided by Univ. of Tennessee, --
194: * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
1.9 ! bertrand 195: * November 2011
1.1 bertrand 196: *
197: * .. Scalar Arguments ..
198: CHARACTER UPLO
199: INTEGER INFO, KD, LDAB, LDAFB, LDB, LDX, N, NRHS
200: * ..
201: * .. Array Arguments ..
202: DOUBLE PRECISION BERR( * ), FERR( * ), RWORK( * )
203: COMPLEX*16 AB( LDAB, * ), AFB( LDAFB, * ), B( LDB, * ),
204: $ WORK( * ), X( LDX, * )
205: * ..
206: *
207: * =====================================================================
208: *
209: * .. Parameters ..
210: INTEGER ITMAX
211: PARAMETER ( ITMAX = 5 )
212: DOUBLE PRECISION ZERO
213: PARAMETER ( ZERO = 0.0D+0 )
214: COMPLEX*16 ONE
215: PARAMETER ( ONE = ( 1.0D+0, 0.0D+0 ) )
216: DOUBLE PRECISION TWO
217: PARAMETER ( TWO = 2.0D+0 )
218: DOUBLE PRECISION THREE
219: PARAMETER ( THREE = 3.0D+0 )
220: * ..
221: * .. Local Scalars ..
222: LOGICAL UPPER
223: INTEGER COUNT, I, J, K, KASE, L, NZ
224: DOUBLE PRECISION EPS, LSTRES, S, SAFE1, SAFE2, SAFMIN, XK
225: COMPLEX*16 ZDUM
226: * ..
227: * .. Local Arrays ..
228: INTEGER ISAVE( 3 )
229: * ..
230: * .. External Subroutines ..
231: EXTERNAL XERBLA, ZAXPY, ZCOPY, ZHBMV, ZLACN2, ZPBTRS
232: * ..
233: * .. Intrinsic Functions ..
234: INTRINSIC ABS, DBLE, DIMAG, MAX, MIN
235: * ..
236: * .. External Functions ..
237: LOGICAL LSAME
238: DOUBLE PRECISION DLAMCH
239: EXTERNAL LSAME, DLAMCH
240: * ..
241: * .. Statement Functions ..
242: DOUBLE PRECISION CABS1
243: * ..
244: * .. Statement Function definitions ..
245: CABS1( ZDUM ) = ABS( DBLE( ZDUM ) ) + ABS( DIMAG( ZDUM ) )
246: * ..
247: * .. Executable Statements ..
248: *
249: * Test the input parameters.
250: *
251: INFO = 0
252: UPPER = LSAME( UPLO, 'U' )
253: IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
254: INFO = -1
255: ELSE IF( N.LT.0 ) THEN
256: INFO = -2
257: ELSE IF( KD.LT.0 ) THEN
258: INFO = -3
259: ELSE IF( NRHS.LT.0 ) THEN
260: INFO = -4
261: ELSE IF( LDAB.LT.KD+1 ) THEN
262: INFO = -6
263: ELSE IF( LDAFB.LT.KD+1 ) THEN
264: INFO = -8
265: ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
266: INFO = -10
267: ELSE IF( LDX.LT.MAX( 1, N ) ) THEN
268: INFO = -12
269: END IF
270: IF( INFO.NE.0 ) THEN
271: CALL XERBLA( 'ZPBRFS', -INFO )
272: RETURN
273: END IF
274: *
275: * Quick return if possible
276: *
277: IF( N.EQ.0 .OR. NRHS.EQ.0 ) THEN
278: DO 10 J = 1, NRHS
279: FERR( J ) = ZERO
280: BERR( J ) = ZERO
281: 10 CONTINUE
282: RETURN
283: END IF
284: *
285: * NZ = maximum number of nonzero elements in each row of A, plus 1
286: *
287: NZ = MIN( N+1, 2*KD+2 )
288: EPS = DLAMCH( 'Epsilon' )
289: SAFMIN = DLAMCH( 'Safe minimum' )
290: SAFE1 = NZ*SAFMIN
291: SAFE2 = SAFE1 / EPS
292: *
293: * Do for each right hand side
294: *
295: DO 140 J = 1, NRHS
296: *
297: COUNT = 1
298: LSTRES = THREE
299: 20 CONTINUE
300: *
301: * Loop until stopping criterion is satisfied.
302: *
303: * Compute residual R = B - A * X
304: *
305: CALL ZCOPY( N, B( 1, J ), 1, WORK, 1 )
306: CALL ZHBMV( UPLO, N, KD, -ONE, AB, LDAB, X( 1, J ), 1, ONE,
307: $ WORK, 1 )
308: *
309: * Compute componentwise relative backward error from formula
310: *
311: * max(i) ( abs(R(i)) / ( abs(A)*abs(X) + abs(B) )(i) )
312: *
313: * where abs(Z) is the componentwise absolute value of the matrix
314: * or vector Z. If the i-th component of the denominator is less
315: * than SAFE2, then SAFE1 is added to the i-th components of the
316: * numerator and denominator before dividing.
317: *
318: DO 30 I = 1, N
319: RWORK( I ) = CABS1( B( I, J ) )
320: 30 CONTINUE
321: *
322: * Compute abs(A)*abs(X) + abs(B).
323: *
324: IF( UPPER ) THEN
325: DO 50 K = 1, N
326: S = ZERO
327: XK = CABS1( X( K, J ) )
328: L = KD + 1 - K
329: DO 40 I = MAX( 1, K-KD ), K - 1
330: RWORK( I ) = RWORK( I ) + CABS1( AB( L+I, K ) )*XK
331: S = S + CABS1( AB( L+I, K ) )*CABS1( X( I, J ) )
332: 40 CONTINUE
333: RWORK( K ) = RWORK( K ) + ABS( DBLE( AB( KD+1, K ) ) )*
334: $ XK + S
335: 50 CONTINUE
336: ELSE
337: DO 70 K = 1, N
338: S = ZERO
339: XK = CABS1( X( K, J ) )
340: RWORK( K ) = RWORK( K ) + ABS( DBLE( AB( 1, K ) ) )*XK
341: L = 1 - K
342: DO 60 I = K + 1, MIN( N, K+KD )
343: RWORK( I ) = RWORK( I ) + CABS1( AB( L+I, K ) )*XK
344: S = S + CABS1( AB( L+I, K ) )*CABS1( X( I, J ) )
345: 60 CONTINUE
346: RWORK( K ) = RWORK( K ) + S
347: 70 CONTINUE
348: END IF
349: S = ZERO
350: DO 80 I = 1, N
351: IF( RWORK( I ).GT.SAFE2 ) THEN
352: S = MAX( S, CABS1( WORK( I ) ) / RWORK( I ) )
353: ELSE
354: S = MAX( S, ( CABS1( WORK( I ) )+SAFE1 ) /
355: $ ( RWORK( I )+SAFE1 ) )
356: END IF
357: 80 CONTINUE
358: BERR( J ) = S
359: *
360: * Test stopping criterion. Continue iterating if
361: * 1) The residual BERR(J) is larger than machine epsilon, and
362: * 2) BERR(J) decreased by at least a factor of 2 during the
363: * last iteration, and
364: * 3) At most ITMAX iterations tried.
365: *
366: IF( BERR( J ).GT.EPS .AND. TWO*BERR( J ).LE.LSTRES .AND.
367: $ COUNT.LE.ITMAX ) THEN
368: *
369: * Update solution and try again.
370: *
371: CALL ZPBTRS( UPLO, N, KD, 1, AFB, LDAFB, WORK, N, INFO )
372: CALL ZAXPY( N, ONE, WORK, 1, X( 1, J ), 1 )
373: LSTRES = BERR( J )
374: COUNT = COUNT + 1
375: GO TO 20
376: END IF
377: *
378: * Bound error from formula
379: *
380: * norm(X - XTRUE) / norm(X) .le. FERR =
381: * norm( abs(inv(A))*
382: * ( abs(R) + NZ*EPS*( abs(A)*abs(X)+abs(B) ))) / norm(X)
383: *
384: * where
385: * norm(Z) is the magnitude of the largest component of Z
386: * inv(A) is the inverse of A
387: * abs(Z) is the componentwise absolute value of the matrix or
388: * vector Z
389: * NZ is the maximum number of nonzeros in any row of A, plus 1
390: * EPS is machine epsilon
391: *
392: * The i-th component of abs(R)+NZ*EPS*(abs(A)*abs(X)+abs(B))
393: * is incremented by SAFE1 if the i-th component of
394: * abs(A)*abs(X) + abs(B) is less than SAFE2.
395: *
396: * Use ZLACN2 to estimate the infinity-norm of the matrix
397: * inv(A) * diag(W),
398: * where W = abs(R) + NZ*EPS*( abs(A)*abs(X)+abs(B) )))
399: *
400: DO 90 I = 1, N
401: IF( RWORK( I ).GT.SAFE2 ) THEN
402: RWORK( I ) = CABS1( WORK( I ) ) + NZ*EPS*RWORK( I )
403: ELSE
404: RWORK( I ) = CABS1( WORK( I ) ) + NZ*EPS*RWORK( I ) +
405: $ SAFE1
406: END IF
407: 90 CONTINUE
408: *
409: KASE = 0
410: 100 CONTINUE
411: CALL ZLACN2( N, WORK( N+1 ), WORK, FERR( J ), KASE, ISAVE )
412: IF( KASE.NE.0 ) THEN
413: IF( KASE.EQ.1 ) THEN
414: *
1.8 bertrand 415: * Multiply by diag(W)*inv(A**H).
1.1 bertrand 416: *
417: CALL ZPBTRS( UPLO, N, KD, 1, AFB, LDAFB, WORK, N, INFO )
418: DO 110 I = 1, N
419: WORK( I ) = RWORK( I )*WORK( I )
420: 110 CONTINUE
421: ELSE IF( KASE.EQ.2 ) THEN
422: *
423: * Multiply by inv(A)*diag(W).
424: *
425: DO 120 I = 1, N
426: WORK( I ) = RWORK( I )*WORK( I )
427: 120 CONTINUE
428: CALL ZPBTRS( UPLO, N, KD, 1, AFB, LDAFB, WORK, N, INFO )
429: END IF
430: GO TO 100
431: END IF
432: *
433: * Normalize error.
434: *
435: LSTRES = ZERO
436: DO 130 I = 1, N
437: LSTRES = MAX( LSTRES, CABS1( X( I, J ) ) )
438: 130 CONTINUE
439: IF( LSTRES.NE.ZERO )
440: $ FERR( J ) = FERR( J ) / LSTRES
441: *
442: 140 CONTINUE
443: *
444: RETURN
445: *
446: * End of ZPBRFS
447: *
448: END
CVSweb interface <joel.bertrand@systella.fr>