LAPACK 3.3.0
|
00001 SUBROUTINE ZTBT05( UPLO, TRANS, DIAG, N, KD, NRHS, AB, LDAB, B, 00002 $ LDB, X, LDX, XACT, LDXACT, FERR, BERR, RESLTS ) 00003 * 00004 * -- LAPACK test routine (version 3.1) -- 00005 * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. 00006 * November 2006 00007 * 00008 * .. Scalar Arguments .. 00009 CHARACTER DIAG, TRANS, UPLO 00010 INTEGER KD, LDAB, LDB, LDX, LDXACT, N, NRHS 00011 * .. 00012 * .. Array Arguments .. 00013 DOUBLE PRECISION BERR( * ), FERR( * ), RESLTS( * ) 00014 COMPLEX*16 AB( LDAB, * ), B( LDB, * ), X( LDX, * ), 00015 $ XACT( LDXACT, * ) 00016 * .. 00017 * 00018 * Purpose 00019 * ======= 00020 * 00021 * ZTBT05 tests the error bounds from iterative refinement for the 00022 * computed solution to a system of equations A*X = B, where A is a 00023 * triangular band matrix. 00024 * 00025 * RESLTS(1) = test of the error bound 00026 * = norm(X - XACT) / ( norm(X) * FERR ) 00027 * 00028 * A large value is returned if this ratio is not less than one. 00029 * 00030 * RESLTS(2) = residual from the iterative refinement routine 00031 * = the maximum of BERR / ( NZ*EPS + (*) ), where 00032 * (*) = NZ*UNFL / (min_i (abs(A)*abs(X) +abs(b))_i ) 00033 * and NZ = max. number of nonzeros in any row of A, plus 1 00034 * 00035 * Arguments 00036 * ========= 00037 * 00038 * UPLO (input) CHARACTER*1 00039 * Specifies whether the matrix A is upper or lower triangular. 00040 * = 'U': Upper triangular 00041 * = 'L': Lower triangular 00042 * 00043 * TRANS (input) CHARACTER*1 00044 * Specifies the form of the system of equations. 00045 * = 'N': A * X = B (No transpose) 00046 * = 'T': A'* X = B (Transpose) 00047 * = 'C': A'* X = B (Conjugate transpose = Transpose) 00048 * 00049 * DIAG (input) CHARACTER*1 00050 * Specifies whether or not the matrix A is unit triangular. 00051 * = 'N': Non-unit triangular 00052 * = 'U': Unit triangular 00053 * 00054 * N (input) INTEGER 00055 * The number of rows of the matrices X, B, and XACT, and the 00056 * order of the matrix A. N >= 0. 00057 * 00058 * KD (input) INTEGER 00059 * The number of super-diagonals of the matrix A if UPLO = 'U', 00060 * or the number of sub-diagonals if UPLO = 'L'. KD >= 0. 00061 * 00062 * NRHS (input) INTEGER 00063 * The number of columns of the matrices X, B, and XACT. 00064 * NRHS >= 0. 00065 * 00066 * AB (input) COMPLEX*16 array, dimension (LDAB,N) 00067 * The upper or lower triangular band matrix A, stored in the 00068 * first kd+1 rows of the array. The j-th column of A is stored 00069 * in the j-th column of the array AB as follows: 00070 * if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j; 00071 * if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+kd). 00072 * If DIAG = 'U', the diagonal elements of A are not referenced 00073 * and are assumed to be 1. 00074 * 00075 * LDAB (input) INTEGER 00076 * The leading dimension of the array AB. LDAB >= KD+1. 00077 * 00078 * B (input) COMPLEX*16 array, dimension (LDB,NRHS) 00079 * The right hand side vectors for the system of linear 00080 * equations. 00081 * 00082 * LDB (input) INTEGER 00083 * The leading dimension of the array B. LDB >= max(1,N). 00084 * 00085 * X (input) COMPLEX*16 array, dimension (LDX,NRHS) 00086 * The computed solution vectors. Each vector is stored as a 00087 * column of the matrix X. 00088 * 00089 * LDX (input) INTEGER 00090 * The leading dimension of the array X. LDX >= max(1,N). 00091 * 00092 * XACT (input) COMPLEX*16 array, dimension (LDX,NRHS) 00093 * The exact solution vectors. Each vector is stored as a 00094 * column of the matrix XACT. 00095 * 00096 * LDXACT (input) INTEGER 00097 * The leading dimension of the array XACT. LDXACT >= max(1,N). 00098 * 00099 * FERR (input) DOUBLE PRECISION array, dimension (NRHS) 00100 * The estimated forward error bounds for each solution vector 00101 * X. If XTRUE is the true solution, FERR bounds the magnitude 00102 * of the largest entry in (X - XTRUE) divided by the magnitude 00103 * of the largest entry in X. 00104 * 00105 * BERR (input) DOUBLE PRECISION array, dimension (NRHS) 00106 * The componentwise relative backward error of each solution 00107 * vector (i.e., the smallest relative change in any entry of A 00108 * or B that makes X an exact solution). 00109 * 00110 * RESLTS (output) DOUBLE PRECISION array, dimension (2) 00111 * The maximum over the NRHS solution vectors of the ratios: 00112 * RESLTS(1) = norm(X - XACT) / ( norm(X) * FERR ) 00113 * RESLTS(2) = BERR / ( NZ*EPS + (*) ) 00114 * 00115 * ===================================================================== 00116 * 00117 * .. Parameters .. 00118 DOUBLE PRECISION ZERO, ONE 00119 PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 ) 00120 * .. 00121 * .. Local Scalars .. 00122 LOGICAL NOTRAN, UNIT, UPPER 00123 INTEGER I, IFU, IMAX, J, K, NZ 00124 DOUBLE PRECISION AXBI, DIFF, EPS, ERRBND, OVFL, TMP, UNFL, XNORM 00125 COMPLEX*16 ZDUM 00126 * .. 00127 * .. External Functions .. 00128 LOGICAL LSAME 00129 INTEGER IZAMAX 00130 DOUBLE PRECISION DLAMCH 00131 EXTERNAL LSAME, IZAMAX, DLAMCH 00132 * .. 00133 * .. Intrinsic Functions .. 00134 INTRINSIC ABS, DBLE, DIMAG, MAX, MIN 00135 * .. 00136 * .. Statement Functions .. 00137 DOUBLE PRECISION CABS1 00138 * .. 00139 * .. Statement Function definitions .. 00140 CABS1( ZDUM ) = ABS( DBLE( ZDUM ) ) + ABS( DIMAG( ZDUM ) ) 00141 * .. 00142 * .. Executable Statements .. 00143 * 00144 * Quick exit if N = 0 or NRHS = 0. 00145 * 00146 IF( N.LE.0 .OR. NRHS.LE.0 ) THEN 00147 RESLTS( 1 ) = ZERO 00148 RESLTS( 2 ) = ZERO 00149 RETURN 00150 END IF 00151 * 00152 EPS = DLAMCH( 'Epsilon' ) 00153 UNFL = DLAMCH( 'Safe minimum' ) 00154 OVFL = ONE / UNFL 00155 UPPER = LSAME( UPLO, 'U' ) 00156 NOTRAN = LSAME( TRANS, 'N' ) 00157 UNIT = LSAME( DIAG, 'U' ) 00158 NZ = MIN( KD, N-1 ) + 1 00159 * 00160 * Test 1: Compute the maximum of 00161 * norm(X - XACT) / ( norm(X) * FERR ) 00162 * over all the vectors X and XACT using the infinity-norm. 00163 * 00164 ERRBND = ZERO 00165 DO 30 J = 1, NRHS 00166 IMAX = IZAMAX( N, X( 1, J ), 1 ) 00167 XNORM = MAX( CABS1( X( IMAX, J ) ), UNFL ) 00168 DIFF = ZERO 00169 DO 10 I = 1, N 00170 DIFF = MAX( DIFF, CABS1( X( I, J )-XACT( I, J ) ) ) 00171 10 CONTINUE 00172 * 00173 IF( XNORM.GT.ONE ) THEN 00174 GO TO 20 00175 ELSE IF( DIFF.LE.OVFL*XNORM ) THEN 00176 GO TO 20 00177 ELSE 00178 ERRBND = ONE / EPS 00179 GO TO 30 00180 END IF 00181 * 00182 20 CONTINUE 00183 IF( DIFF / XNORM.LE.FERR( J ) ) THEN 00184 ERRBND = MAX( ERRBND, ( DIFF / XNORM ) / FERR( J ) ) 00185 ELSE 00186 ERRBND = ONE / EPS 00187 END IF 00188 30 CONTINUE 00189 RESLTS( 1 ) = ERRBND 00190 * 00191 * Test 2: Compute the maximum of BERR / ( NZ*EPS + (*) ), where 00192 * (*) = NZ*UNFL / (min_i (abs(A)*abs(X) +abs(b))_i ) 00193 * 00194 IFU = 0 00195 IF( UNIT ) 00196 $ IFU = 1 00197 DO 90 K = 1, NRHS 00198 DO 80 I = 1, N 00199 TMP = CABS1( B( I, K ) ) 00200 IF( UPPER ) THEN 00201 IF( .NOT.NOTRAN ) THEN 00202 DO 40 J = MAX( I-KD, 1 ), I - IFU 00203 TMP = TMP + CABS1( AB( KD+1-I+J, I ) )* 00204 $ CABS1( X( J, K ) ) 00205 40 CONTINUE 00206 IF( UNIT ) 00207 $ TMP = TMP + CABS1( X( I, K ) ) 00208 ELSE 00209 IF( UNIT ) 00210 $ TMP = TMP + CABS1( X( I, K ) ) 00211 DO 50 J = I + IFU, MIN( I+KD, N ) 00212 TMP = TMP + CABS1( AB( KD+1+I-J, J ) )* 00213 $ CABS1( X( J, K ) ) 00214 50 CONTINUE 00215 END IF 00216 ELSE 00217 IF( NOTRAN ) THEN 00218 DO 60 J = MAX( I-KD, 1 ), I - IFU 00219 TMP = TMP + CABS1( AB( 1+I-J, J ) )* 00220 $ CABS1( X( J, K ) ) 00221 60 CONTINUE 00222 IF( UNIT ) 00223 $ TMP = TMP + CABS1( X( I, K ) ) 00224 ELSE 00225 IF( UNIT ) 00226 $ TMP = TMP + CABS1( X( I, K ) ) 00227 DO 70 J = I + IFU, MIN( I+KD, N ) 00228 TMP = TMP + CABS1( AB( 1+J-I, I ) )* 00229 $ CABS1( X( J, K ) ) 00230 70 CONTINUE 00231 END IF 00232 END IF 00233 IF( I.EQ.1 ) THEN 00234 AXBI = TMP 00235 ELSE 00236 AXBI = MIN( AXBI, TMP ) 00237 END IF 00238 80 CONTINUE 00239 TMP = BERR( K ) / ( NZ*EPS+NZ*UNFL / MAX( AXBI, NZ*UNFL ) ) 00240 IF( K.EQ.1 ) THEN 00241 RESLTS( 2 ) = TMP 00242 ELSE 00243 RESLTS( 2 ) = MAX( RESLTS( 2 ), TMP ) 00244 END IF 00245 90 CONTINUE 00246 * 00247 RETURN 00248 * 00249 * End of ZTBT05 00250 * 00251 END