00001 SUBROUTINE CGET07( TRANS, N, NRHS, A, LDA, B, LDB, X, LDX, XACT, 00002 $ LDXACT, FERR, CHKFERR, 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 TRANS 00010 LOGICAL CHKFERR 00011 INTEGER LDA, LDB, LDX, LDXACT, N, NRHS 00012 * .. 00013 * .. Array Arguments .. 00014 REAL BERR( * ), FERR( * ), RESLTS( * ) 00015 COMPLEX A( LDA, * ), B( LDB, * ), X( LDX, * ), 00016 $ XACT( LDXACT, * ) 00017 * .. 00018 * 00019 * Purpose 00020 * ======= 00021 * 00022 * CGET07 tests the error bounds from iterative refinement for the 00023 * computed solution to a system of equations op(A)*X = B, where A is a 00024 * general n by n matrix and op(A) = A or A**T, depending on TRANS. 00025 * 00026 * RESLTS(1) = test of the error bound 00027 * = norm(X - XACT) / ( norm(X) * FERR ) 00028 * 00029 * A large value is returned if this ratio is not less than one. 00030 * 00031 * RESLTS(2) = residual from the iterative refinement routine 00032 * = the maximum of BERR / ( (n+1)*EPS + (*) ), where 00033 * (*) = (n+1)*UNFL / (min_i (abs(op(A))*abs(X) +abs(b))_i ) 00034 * 00035 * Arguments 00036 * ========= 00037 * 00038 * TRANS (input) CHARACTER*1 00039 * Specifies the form of the system of equations. 00040 * = 'N': A * X = B (No transpose) 00041 * = 'T': A**T * X = B (Transpose) 00042 * = 'C': A**H * X = B (Conjugate transpose = Transpose) 00043 * 00044 * N (input) INTEGER 00045 * The number of rows of the matrices X and XACT. N >= 0. 00046 * 00047 * NRHS (input) INTEGER 00048 * The number of columns of the matrices X and XACT. NRHS >= 0. 00049 * 00050 * A (input) COMPLEX array, dimension (LDA,N) 00051 * The original n by n matrix A. 00052 * 00053 * LDA (input) INTEGER 00054 * The leading dimension of the array A. LDA >= max(1,N). 00055 * 00056 * B (input) COMPLEX array, dimension (LDB,NRHS) 00057 * The right hand side vectors for the system of linear 00058 * equations. 00059 * 00060 * LDB (input) INTEGER 00061 * The leading dimension of the array B. LDB >= max(1,N). 00062 * 00063 * X (input) COMPLEX array, dimension (LDX,NRHS) 00064 * The computed solution vectors. Each vector is stored as a 00065 * column of the matrix X. 00066 * 00067 * LDX (input) INTEGER 00068 * The leading dimension of the array X. LDX >= max(1,N). 00069 * 00070 * XACT (input) COMPLEX array, dimension (LDX,NRHS) 00071 * The exact solution vectors. Each vector is stored as a 00072 * column of the matrix XACT. 00073 * 00074 * LDXACT (input) INTEGER 00075 * The leading dimension of the array XACT. LDXACT >= max(1,N). 00076 * 00077 * FERR (input) REAL array, dimension (NRHS) 00078 * The estimated forward error bounds for each solution vector 00079 * X. If XTRUE is the true solution, FERR bounds the magnitude 00080 * of the largest entry in (X - XTRUE) divided by the magnitude 00081 * of the largest entry in X. 00082 * 00083 * CHKFERR (input) LOGICAL 00084 * Set to .TRUE. to check FERR, .FALSE. not to check FERR. 00085 * When the test system is ill-conditioned, the "true" 00086 * solution in XACT may be incorrect. 00087 * 00088 * BERR (input) REAL array, dimension (NRHS) 00089 * The componentwise relative backward error of each solution 00090 * vector (i.e., the smallest relative change in any entry of A 00091 * or B that makes X an exact solution). 00092 * 00093 * RESLTS (output) REAL array, dimension (2) 00094 * The maximum over the NRHS solution vectors of the ratios: 00095 * RESLTS(1) = norm(X - XACT) / ( norm(X) * FERR ) 00096 * RESLTS(2) = BERR / ( (n+1)*EPS + (*) ) 00097 * 00098 * ===================================================================== 00099 * 00100 * .. Parameters .. 00101 REAL ZERO, ONE 00102 PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 ) 00103 * .. 00104 * .. Local Scalars .. 00105 LOGICAL NOTRAN 00106 INTEGER I, IMAX, J, K 00107 REAL AXBI, DIFF, EPS, ERRBND, OVFL, TMP, UNFL, XNORM 00108 COMPLEX ZDUM 00109 * .. 00110 * .. External Functions .. 00111 LOGICAL LSAME 00112 INTEGER ICAMAX 00113 REAL SLAMCH 00114 EXTERNAL LSAME, ICAMAX, SLAMCH 00115 * .. 00116 * .. Intrinsic Functions .. 00117 INTRINSIC ABS, AIMAG, MAX, MIN, REAL 00118 * .. 00119 * .. Statement Functions .. 00120 REAL CABS1 00121 * .. 00122 * .. Statement Function definitions .. 00123 CABS1( ZDUM ) = ABS( REAL( ZDUM ) ) + ABS( AIMAG( ZDUM ) ) 00124 * .. 00125 * .. Executable Statements .. 00126 * 00127 * Quick exit if N = 0 or NRHS = 0. 00128 * 00129 IF( N.LE.0 .OR. NRHS.LE.0 ) THEN 00130 RESLTS( 1 ) = ZERO 00131 RESLTS( 2 ) = ZERO 00132 RETURN 00133 END IF 00134 * 00135 EPS = SLAMCH( 'Epsilon' ) 00136 UNFL = SLAMCH( 'Safe minimum' ) 00137 OVFL = ONE / UNFL 00138 NOTRAN = LSAME( TRANS, 'N' ) 00139 * 00140 * Test 1: Compute the maximum of 00141 * norm(X - XACT) / ( norm(X) * FERR ) 00142 * over all the vectors X and XACT using the infinity-norm. 00143 * 00144 ERRBND = ZERO 00145 IF( CHKFERR ) THEN 00146 DO 30 J = 1, NRHS 00147 IMAX = ICAMAX( N, X( 1, J ), 1 ) 00148 XNORM = MAX( CABS1( X( IMAX, J ) ), UNFL ) 00149 DIFF = ZERO 00150 DO 10 I = 1, N 00151 DIFF = MAX( DIFF, CABS1( X( I, J )-XACT( I, J ) ) ) 00152 10 CONTINUE 00153 * 00154 IF( XNORM.GT.ONE ) THEN 00155 GO TO 20 00156 ELSE IF( DIFF.LE.OVFL*XNORM ) THEN 00157 GO TO 20 00158 ELSE 00159 ERRBND = ONE / EPS 00160 GO TO 30 00161 END IF 00162 * 00163 20 CONTINUE 00164 IF( DIFF / XNORM.LE.FERR( J ) ) THEN 00165 ERRBND = MAX( ERRBND, ( DIFF / XNORM ) / FERR( J ) ) 00166 ELSE 00167 ERRBND = ONE / EPS 00168 END IF 00169 30 CONTINUE 00170 END IF 00171 RESLTS( 1 ) = ERRBND 00172 * 00173 * Test 2: Compute the maximum of BERR / ( (n+1)*EPS + (*) ), where 00174 * (*) = (n+1)*UNFL / (min_i (abs(op(A))*abs(X) +abs(b))_i ) 00175 * 00176 DO 70 K = 1, NRHS 00177 DO 60 I = 1, N 00178 TMP = CABS1( B( I, K ) ) 00179 IF( NOTRAN ) THEN 00180 DO 40 J = 1, N 00181 TMP = TMP + CABS1( A( I, J ) )*CABS1( X( J, K ) ) 00182 40 CONTINUE 00183 ELSE 00184 DO 50 J = 1, N 00185 TMP = TMP + CABS1( A( J, I ) )*CABS1( X( J, K ) ) 00186 50 CONTINUE 00187 END IF 00188 IF( I.EQ.1 ) THEN 00189 AXBI = TMP 00190 ELSE 00191 AXBI = MIN( AXBI, TMP ) 00192 END IF 00193 60 CONTINUE 00194 TMP = BERR( K ) / ( ( N+1 )*EPS+( N+1 )*UNFL / 00195 $ MAX( AXBI, ( N+1 )*UNFL ) ) 00196 IF( K.EQ.1 ) THEN 00197 RESLTS( 2 ) = TMP 00198 ELSE 00199 RESLTS( 2 ) = MAX( RESLTS( 2 ), TMP ) 00200 END IF 00201 70 CONTINUE 00202 * 00203 RETURN 00204 * 00205 * End of CGET07 00206 * 00207 END