Annotation of rpl/lapack/lapack/zpbrfs.f, revision 1.1
1.1 ! bertrand 1: SUBROUTINE ZPBRFS( UPLO, N, KD, NRHS, AB, LDAB, AFB, LDAFB, B,
! 2: $ LDB, X, LDX, FERR, BERR, WORK, RWORK, INFO )
! 3: *
! 4: * -- LAPACK routine (version 3.2) --
! 5: * -- LAPACK is a software package provided by Univ. of Tennessee, --
! 6: * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
! 7: * November 2006
! 8: *
! 9: * Modified to call ZLACN2 in place of ZLACON, 10 Feb 03, SJH.
! 10: *
! 11: * .. Scalar Arguments ..
! 12: CHARACTER UPLO
! 13: INTEGER INFO, KD, LDAB, LDAFB, LDB, LDX, N, NRHS
! 14: * ..
! 15: * .. Array Arguments ..
! 16: DOUBLE PRECISION BERR( * ), FERR( * ), RWORK( * )
! 17: COMPLEX*16 AB( LDAB, * ), AFB( LDAFB, * ), B( LDB, * ),
! 18: $ WORK( * ), X( LDX, * )
! 19: * ..
! 20: *
! 21: * Purpose
! 22: * =======
! 23: *
! 24: * ZPBRFS improves the computed solution to a system of linear
! 25: * equations when the coefficient matrix is Hermitian positive definite
! 26: * and banded, and provides error bounds and backward error estimates
! 27: * for the solution.
! 28: *
! 29: * Arguments
! 30: * =========
! 31: *
! 32: * UPLO (input) CHARACTER*1
! 33: * = 'U': Upper triangle of A is stored;
! 34: * = 'L': Lower triangle of A is stored.
! 35: *
! 36: * N (input) INTEGER
! 37: * The order of the matrix A. N >= 0.
! 38: *
! 39: * KD (input) INTEGER
! 40: * The number of superdiagonals of the matrix A if UPLO = 'U',
! 41: * or the number of subdiagonals if UPLO = 'L'. KD >= 0.
! 42: *
! 43: * NRHS (input) INTEGER
! 44: * The number of right hand sides, i.e., the number of columns
! 45: * of the matrices B and X. NRHS >= 0.
! 46: *
! 47: * AB (input) DOUBLE PRECISION array, dimension (LDAB,N)
! 48: * The upper or lower triangle of the Hermitian band matrix A,
! 49: * stored in the first KD+1 rows of the array. The j-th column
! 50: * of A is stored in the j-th column of the array AB as follows:
! 51: * if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j;
! 52: * if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+kd).
! 53: *
! 54: * LDAB (input) INTEGER
! 55: * The leading dimension of the array AB. LDAB >= KD+1.
! 56: *
! 57: * AFB (input) COMPLEX*16 array, dimension (LDAFB,N)
! 58: * The triangular factor U or L from the Cholesky factorization
! 59: * A = U**H*U or A = L*L**H of the band matrix A as computed by
! 60: * ZPBTRF, in the same storage format as A (see AB).
! 61: *
! 62: * LDAFB (input) INTEGER
! 63: * The leading dimension of the array AFB. LDAFB >= KD+1.
! 64: *
! 65: * B (input) COMPLEX*16 array, dimension (LDB,NRHS)
! 66: * The right hand side matrix B.
! 67: *
! 68: * LDB (input) INTEGER
! 69: * The leading dimension of the array B. LDB >= max(1,N).
! 70: *
! 71: * X (input/output) COMPLEX*16 array, dimension (LDX,NRHS)
! 72: * On entry, the solution matrix X, as computed by ZPBTRS.
! 73: * On exit, the improved solution matrix X.
! 74: *
! 75: * LDX (input) INTEGER
! 76: * The leading dimension of the array X. LDX >= max(1,N).
! 77: *
! 78: * FERR (output) DOUBLE PRECISION array, dimension (NRHS)
! 79: * The estimated forward error bound for each solution vector
! 80: * X(j) (the j-th column of the solution matrix X).
! 81: * If XTRUE is the true solution corresponding to X(j), FERR(j)
! 82: * is an estimated upper bound for the magnitude of the largest
! 83: * element in (X(j) - XTRUE) divided by the magnitude of the
! 84: * largest element in X(j). The estimate is as reliable as
! 85: * the estimate for RCOND, and is almost always a slight
! 86: * overestimate of the true error.
! 87: *
! 88: * BERR (output) DOUBLE PRECISION array, dimension (NRHS)
! 89: * The componentwise relative backward error of each solution
! 90: * vector X(j) (i.e., the smallest relative change in
! 91: * any element of A or B that makes X(j) an exact solution).
! 92: *
! 93: * WORK (workspace) COMPLEX*16 array, dimension (2*N)
! 94: *
! 95: * RWORK (workspace) DOUBLE PRECISION array, dimension (N)
! 96: *
! 97: * INFO (output) INTEGER
! 98: * = 0: successful exit
! 99: * < 0: if INFO = -i, the i-th argument had an illegal value
! 100: *
! 101: * Internal Parameters
! 102: * ===================
! 103: *
! 104: * ITMAX is the maximum number of steps of iterative refinement.
! 105: *
! 106: * =====================================================================
! 107: *
! 108: * .. Parameters ..
! 109: INTEGER ITMAX
! 110: PARAMETER ( ITMAX = 5 )
! 111: DOUBLE PRECISION ZERO
! 112: PARAMETER ( ZERO = 0.0D+0 )
! 113: COMPLEX*16 ONE
! 114: PARAMETER ( ONE = ( 1.0D+0, 0.0D+0 ) )
! 115: DOUBLE PRECISION TWO
! 116: PARAMETER ( TWO = 2.0D+0 )
! 117: DOUBLE PRECISION THREE
! 118: PARAMETER ( THREE = 3.0D+0 )
! 119: * ..
! 120: * .. Local Scalars ..
! 121: LOGICAL UPPER
! 122: INTEGER COUNT, I, J, K, KASE, L, NZ
! 123: DOUBLE PRECISION EPS, LSTRES, S, SAFE1, SAFE2, SAFMIN, XK
! 124: COMPLEX*16 ZDUM
! 125: * ..
! 126: * .. Local Arrays ..
! 127: INTEGER ISAVE( 3 )
! 128: * ..
! 129: * .. External Subroutines ..
! 130: EXTERNAL XERBLA, ZAXPY, ZCOPY, ZHBMV, ZLACN2, ZPBTRS
! 131: * ..
! 132: * .. Intrinsic Functions ..
! 133: INTRINSIC ABS, DBLE, DIMAG, MAX, MIN
! 134: * ..
! 135: * .. External Functions ..
! 136: LOGICAL LSAME
! 137: DOUBLE PRECISION DLAMCH
! 138: EXTERNAL LSAME, DLAMCH
! 139: * ..
! 140: * .. Statement Functions ..
! 141: DOUBLE PRECISION CABS1
! 142: * ..
! 143: * .. Statement Function definitions ..
! 144: CABS1( ZDUM ) = ABS( DBLE( ZDUM ) ) + ABS( DIMAG( ZDUM ) )
! 145: * ..
! 146: * .. Executable Statements ..
! 147: *
! 148: * Test the input parameters.
! 149: *
! 150: INFO = 0
! 151: UPPER = LSAME( UPLO, 'U' )
! 152: IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
! 153: INFO = -1
! 154: ELSE IF( N.LT.0 ) THEN
! 155: INFO = -2
! 156: ELSE IF( KD.LT.0 ) THEN
! 157: INFO = -3
! 158: ELSE IF( NRHS.LT.0 ) THEN
! 159: INFO = -4
! 160: ELSE IF( LDAB.LT.KD+1 ) THEN
! 161: INFO = -6
! 162: ELSE IF( LDAFB.LT.KD+1 ) THEN
! 163: INFO = -8
! 164: ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
! 165: INFO = -10
! 166: ELSE IF( LDX.LT.MAX( 1, N ) ) THEN
! 167: INFO = -12
! 168: END IF
! 169: IF( INFO.NE.0 ) THEN
! 170: CALL XERBLA( 'ZPBRFS', -INFO )
! 171: RETURN
! 172: END IF
! 173: *
! 174: * Quick return if possible
! 175: *
! 176: IF( N.EQ.0 .OR. NRHS.EQ.0 ) THEN
! 177: DO 10 J = 1, NRHS
! 178: FERR( J ) = ZERO
! 179: BERR( J ) = ZERO
! 180: 10 CONTINUE
! 181: RETURN
! 182: END IF
! 183: *
! 184: * NZ = maximum number of nonzero elements in each row of A, plus 1
! 185: *
! 186: NZ = MIN( N+1, 2*KD+2 )
! 187: EPS = DLAMCH( 'Epsilon' )
! 188: SAFMIN = DLAMCH( 'Safe minimum' )
! 189: SAFE1 = NZ*SAFMIN
! 190: SAFE2 = SAFE1 / EPS
! 191: *
! 192: * Do for each right hand side
! 193: *
! 194: DO 140 J = 1, NRHS
! 195: *
! 196: COUNT = 1
! 197: LSTRES = THREE
! 198: 20 CONTINUE
! 199: *
! 200: * Loop until stopping criterion is satisfied.
! 201: *
! 202: * Compute residual R = B - A * X
! 203: *
! 204: CALL ZCOPY( N, B( 1, J ), 1, WORK, 1 )
! 205: CALL ZHBMV( UPLO, N, KD, -ONE, AB, LDAB, X( 1, J ), 1, ONE,
! 206: $ WORK, 1 )
! 207: *
! 208: * Compute componentwise relative backward error from formula
! 209: *
! 210: * max(i) ( abs(R(i)) / ( abs(A)*abs(X) + abs(B) )(i) )
! 211: *
! 212: * where abs(Z) is the componentwise absolute value of the matrix
! 213: * or vector Z. If the i-th component of the denominator is less
! 214: * than SAFE2, then SAFE1 is added to the i-th components of the
! 215: * numerator and denominator before dividing.
! 216: *
! 217: DO 30 I = 1, N
! 218: RWORK( I ) = CABS1( B( I, J ) )
! 219: 30 CONTINUE
! 220: *
! 221: * Compute abs(A)*abs(X) + abs(B).
! 222: *
! 223: IF( UPPER ) THEN
! 224: DO 50 K = 1, N
! 225: S = ZERO
! 226: XK = CABS1( X( K, J ) )
! 227: L = KD + 1 - K
! 228: DO 40 I = MAX( 1, K-KD ), K - 1
! 229: RWORK( I ) = RWORK( I ) + CABS1( AB( L+I, K ) )*XK
! 230: S = S + CABS1( AB( L+I, K ) )*CABS1( X( I, J ) )
! 231: 40 CONTINUE
! 232: RWORK( K ) = RWORK( K ) + ABS( DBLE( AB( KD+1, K ) ) )*
! 233: $ XK + S
! 234: 50 CONTINUE
! 235: ELSE
! 236: DO 70 K = 1, N
! 237: S = ZERO
! 238: XK = CABS1( X( K, J ) )
! 239: RWORK( K ) = RWORK( K ) + ABS( DBLE( AB( 1, K ) ) )*XK
! 240: L = 1 - K
! 241: DO 60 I = K + 1, MIN( N, K+KD )
! 242: RWORK( I ) = RWORK( I ) + CABS1( AB( L+I, K ) )*XK
! 243: S = S + CABS1( AB( L+I, K ) )*CABS1( X( I, J ) )
! 244: 60 CONTINUE
! 245: RWORK( K ) = RWORK( K ) + S
! 246: 70 CONTINUE
! 247: END IF
! 248: S = ZERO
! 249: DO 80 I = 1, N
! 250: IF( RWORK( I ).GT.SAFE2 ) THEN
! 251: S = MAX( S, CABS1( WORK( I ) ) / RWORK( I ) )
! 252: ELSE
! 253: S = MAX( S, ( CABS1( WORK( I ) )+SAFE1 ) /
! 254: $ ( RWORK( I )+SAFE1 ) )
! 255: END IF
! 256: 80 CONTINUE
! 257: BERR( J ) = S
! 258: *
! 259: * Test stopping criterion. Continue iterating if
! 260: * 1) The residual BERR(J) is larger than machine epsilon, and
! 261: * 2) BERR(J) decreased by at least a factor of 2 during the
! 262: * last iteration, and
! 263: * 3) At most ITMAX iterations tried.
! 264: *
! 265: IF( BERR( J ).GT.EPS .AND. TWO*BERR( J ).LE.LSTRES .AND.
! 266: $ COUNT.LE.ITMAX ) THEN
! 267: *
! 268: * Update solution and try again.
! 269: *
! 270: CALL ZPBTRS( UPLO, N, KD, 1, AFB, LDAFB, WORK, N, INFO )
! 271: CALL ZAXPY( N, ONE, WORK, 1, X( 1, J ), 1 )
! 272: LSTRES = BERR( J )
! 273: COUNT = COUNT + 1
! 274: GO TO 20
! 275: END IF
! 276: *
! 277: * Bound error from formula
! 278: *
! 279: * norm(X - XTRUE) / norm(X) .le. FERR =
! 280: * norm( abs(inv(A))*
! 281: * ( abs(R) + NZ*EPS*( abs(A)*abs(X)+abs(B) ))) / norm(X)
! 282: *
! 283: * where
! 284: * norm(Z) is the magnitude of the largest component of Z
! 285: * inv(A) is the inverse of A
! 286: * abs(Z) is the componentwise absolute value of the matrix or
! 287: * vector Z
! 288: * NZ is the maximum number of nonzeros in any row of A, plus 1
! 289: * EPS is machine epsilon
! 290: *
! 291: * The i-th component of abs(R)+NZ*EPS*(abs(A)*abs(X)+abs(B))
! 292: * is incremented by SAFE1 if the i-th component of
! 293: * abs(A)*abs(X) + abs(B) is less than SAFE2.
! 294: *
! 295: * Use ZLACN2 to estimate the infinity-norm of the matrix
! 296: * inv(A) * diag(W),
! 297: * where W = abs(R) + NZ*EPS*( abs(A)*abs(X)+abs(B) )))
! 298: *
! 299: DO 90 I = 1, N
! 300: IF( RWORK( I ).GT.SAFE2 ) THEN
! 301: RWORK( I ) = CABS1( WORK( I ) ) + NZ*EPS*RWORK( I )
! 302: ELSE
! 303: RWORK( I ) = CABS1( WORK( I ) ) + NZ*EPS*RWORK( I ) +
! 304: $ SAFE1
! 305: END IF
! 306: 90 CONTINUE
! 307: *
! 308: KASE = 0
! 309: 100 CONTINUE
! 310: CALL ZLACN2( N, WORK( N+1 ), WORK, FERR( J ), KASE, ISAVE )
! 311: IF( KASE.NE.0 ) THEN
! 312: IF( KASE.EQ.1 ) THEN
! 313: *
! 314: * Multiply by diag(W)*inv(A').
! 315: *
! 316: CALL ZPBTRS( UPLO, N, KD, 1, AFB, LDAFB, WORK, N, INFO )
! 317: DO 110 I = 1, N
! 318: WORK( I ) = RWORK( I )*WORK( I )
! 319: 110 CONTINUE
! 320: ELSE IF( KASE.EQ.2 ) THEN
! 321: *
! 322: * Multiply by inv(A)*diag(W).
! 323: *
! 324: DO 120 I = 1, N
! 325: WORK( I ) = RWORK( I )*WORK( I )
! 326: 120 CONTINUE
! 327: CALL ZPBTRS( UPLO, N, KD, 1, AFB, LDAFB, WORK, N, INFO )
! 328: END IF
! 329: GO TO 100
! 330: END IF
! 331: *
! 332: * Normalize error.
! 333: *
! 334: LSTRES = ZERO
! 335: DO 130 I = 1, N
! 336: LSTRES = MAX( LSTRES, CABS1( X( I, J ) ) )
! 337: 130 CONTINUE
! 338: IF( LSTRES.NE.ZERO )
! 339: $ FERR( J ) = FERR( J ) / LSTRES
! 340: *
! 341: 140 CONTINUE
! 342: *
! 343: RETURN
! 344: *
! 345: * End of ZPBRFS
! 346: *
! 347: END
CVSweb interface <joel.bertrand@systella.fr>