LAPACK 3.3.1
Linear Algebra PACKage
|
00001 SUBROUTINE CGTT05( TRANS, N, NRHS, DL, D, DU, B, LDB, X, LDX, 00002 $ 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 TRANS 00010 INTEGER LDB, LDX, LDXACT, N, NRHS 00011 * .. 00012 * .. Array Arguments .. 00013 REAL BERR( * ), FERR( * ), RESLTS( * ) 00014 COMPLEX B( LDB, * ), D( * ), DL( * ), DU( * ), 00015 $ X( LDX, * ), XACT( LDXACT, * ) 00016 * .. 00017 * 00018 * Purpose 00019 * ======= 00020 * 00021 * CGTT05 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 * general tridiagonal matrix of order n and op(A) = A or A**T, 00024 * 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 / ( NZ*EPS + (*) ), where 00033 * (*) = NZ*UNFL / (min_i (abs(op(A))*abs(X) +abs(b))_i ) 00034 * and NZ = max. number of nonzeros in any row of A, plus 1 00035 * 00036 * Arguments 00037 * ========= 00038 * 00039 * TRANS (input) CHARACTER*1 00040 * Specifies the form of the system of equations. 00041 * = 'N': A * X = B (No transpose) 00042 * = 'T': A**T * X = B (Transpose) 00043 * = 'C': A**H * X = B (Conjugate transpose = Transpose) 00044 * 00045 * N (input) INTEGER 00046 * The number of rows of the matrices X and XACT. N >= 0. 00047 * 00048 * NRHS (input) INTEGER 00049 * The number of columns of the matrices X and XACT. NRHS >= 0. 00050 * 00051 * DL (input) COMPLEX array, dimension (N-1) 00052 * The (n-1) sub-diagonal elements of A. 00053 * 00054 * D (input) COMPLEX array, dimension (N) 00055 * The diagonal elements of A. 00056 * 00057 * DU (input) COMPLEX array, dimension (N-1) 00058 * The (n-1) super-diagonal elements of A. 00059 * 00060 * B (input) COMPLEX array, dimension (LDB,NRHS) 00061 * The right hand side vectors for the system of linear 00062 * equations. 00063 * 00064 * LDB (input) INTEGER 00065 * The leading dimension of the array B. LDB >= max(1,N). 00066 * 00067 * X (input) COMPLEX array, dimension (LDX,NRHS) 00068 * The computed solution vectors. Each vector is stored as a 00069 * column of the matrix X. 00070 * 00071 * LDX (input) INTEGER 00072 * The leading dimension of the array X. LDX >= max(1,N). 00073 * 00074 * XACT (input) COMPLEX array, dimension (LDX,NRHS) 00075 * The exact solution vectors. Each vector is stored as a 00076 * column of the matrix XACT. 00077 * 00078 * LDXACT (input) INTEGER 00079 * The leading dimension of the array XACT. LDXACT >= max(1,N). 00080 * 00081 * FERR (input) REAL array, dimension (NRHS) 00082 * The estimated forward error bounds for each solution vector 00083 * X. If XTRUE is the true solution, FERR bounds the magnitude 00084 * of the largest entry in (X - XTRUE) divided by the magnitude 00085 * of the largest entry in X. 00086 * 00087 * BERR (input) REAL array, dimension (NRHS) 00088 * The componentwise relative backward error of each solution 00089 * vector (i.e., the smallest relative change in any entry of A 00090 * or B that makes X an exact solution). 00091 * 00092 * RESLTS (output) REAL array, dimension (2) 00093 * The maximum over the NRHS solution vectors of the ratios: 00094 * RESLTS(1) = norm(X - XACT) / ( norm(X) * FERR ) 00095 * RESLTS(2) = BERR / ( NZ*EPS + (*) ) 00096 * 00097 * ===================================================================== 00098 * 00099 * .. Parameters .. 00100 REAL ZERO, ONE 00101 PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 ) 00102 * .. 00103 * .. Local Scalars .. 00104 LOGICAL NOTRAN 00105 INTEGER I, IMAX, J, K, NZ 00106 REAL AXBI, DIFF, EPS, ERRBND, OVFL, TMP, UNFL, XNORM 00107 COMPLEX ZDUM 00108 * .. 00109 * .. External Functions .. 00110 LOGICAL LSAME 00111 INTEGER ICAMAX 00112 REAL SLAMCH 00113 EXTERNAL LSAME, ICAMAX, SLAMCH 00114 * .. 00115 * .. Intrinsic Functions .. 00116 INTRINSIC ABS, AIMAG, MAX, MIN, REAL 00117 * .. 00118 * .. Statement Functions .. 00119 REAL CABS1 00120 * .. 00121 * .. Statement Function definitions .. 00122 CABS1( ZDUM ) = ABS( REAL( ZDUM ) ) + ABS( AIMAG( ZDUM ) ) 00123 * .. 00124 * .. Executable Statements .. 00125 * 00126 * Quick exit if N = 0 or NRHS = 0. 00127 * 00128 IF( N.LE.0 .OR. NRHS.LE.0 ) THEN 00129 RESLTS( 1 ) = ZERO 00130 RESLTS( 2 ) = ZERO 00131 RETURN 00132 END IF 00133 * 00134 EPS = SLAMCH( 'Epsilon' ) 00135 UNFL = SLAMCH( 'Safe minimum' ) 00136 OVFL = ONE / UNFL 00137 NOTRAN = LSAME( TRANS, 'N' ) 00138 NZ = 4 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 DO 30 J = 1, NRHS 00146 IMAX = ICAMAX( N, X( 1, J ), 1 ) 00147 XNORM = MAX( CABS1( X( IMAX, J ) ), UNFL ) 00148 DIFF = ZERO 00149 DO 10 I = 1, N 00150 DIFF = MAX( DIFF, CABS1( X( I, J )-XACT( I, J ) ) ) 00151 10 CONTINUE 00152 * 00153 IF( XNORM.GT.ONE ) THEN 00154 GO TO 20 00155 ELSE IF( DIFF.LE.OVFL*XNORM ) THEN 00156 GO TO 20 00157 ELSE 00158 ERRBND = ONE / EPS 00159 GO TO 30 00160 END IF 00161 * 00162 20 CONTINUE 00163 IF( DIFF / XNORM.LE.FERR( J ) ) THEN 00164 ERRBND = MAX( ERRBND, ( DIFF / XNORM ) / FERR( J ) ) 00165 ELSE 00166 ERRBND = ONE / EPS 00167 END IF 00168 30 CONTINUE 00169 RESLTS( 1 ) = ERRBND 00170 * 00171 * Test 2: Compute the maximum of BERR / ( NZ*EPS + (*) ), where 00172 * (*) = NZ*UNFL / (min_i (abs(op(A))*abs(X) +abs(b))_i ) 00173 * 00174 DO 60 K = 1, NRHS 00175 IF( NOTRAN ) THEN 00176 IF( N.EQ.1 ) THEN 00177 AXBI = CABS1( B( 1, K ) ) + 00178 $ CABS1( D( 1 ) )*CABS1( X( 1, K ) ) 00179 ELSE 00180 AXBI = CABS1( B( 1, K ) ) + 00181 $ CABS1( D( 1 ) )*CABS1( X( 1, K ) ) + 00182 $ CABS1( DU( 1 ) )*CABS1( X( 2, K ) ) 00183 DO 40 I = 2, N - 1 00184 TMP = CABS1( B( I, K ) ) + 00185 $ CABS1( DL( I-1 ) )*CABS1( X( I-1, K ) ) + 00186 $ CABS1( D( I ) )*CABS1( X( I, K ) ) + 00187 $ CABS1( DU( I ) )*CABS1( X( I+1, K ) ) 00188 AXBI = MIN( AXBI, TMP ) 00189 40 CONTINUE 00190 TMP = CABS1( B( N, K ) ) + CABS1( DL( N-1 ) )* 00191 $ CABS1( X( N-1, K ) ) + CABS1( D( N ) )* 00192 $ CABS1( X( N, K ) ) 00193 AXBI = MIN( AXBI, TMP ) 00194 END IF 00195 ELSE 00196 IF( N.EQ.1 ) THEN 00197 AXBI = CABS1( B( 1, K ) ) + 00198 $ CABS1( D( 1 ) )*CABS1( X( 1, K ) ) 00199 ELSE 00200 AXBI = CABS1( B( 1, K ) ) + 00201 $ CABS1( D( 1 ) )*CABS1( X( 1, K ) ) + 00202 $ CABS1( DL( 1 ) )*CABS1( X( 2, K ) ) 00203 DO 50 I = 2, N - 1 00204 TMP = CABS1( B( I, K ) ) + 00205 $ CABS1( DU( I-1 ) )*CABS1( X( I-1, K ) ) + 00206 $ CABS1( D( I ) )*CABS1( X( I, K ) ) + 00207 $ CABS1( DL( I ) )*CABS1( X( I+1, K ) ) 00208 AXBI = MIN( AXBI, TMP ) 00209 50 CONTINUE 00210 TMP = CABS1( B( N, K ) ) + CABS1( DU( N-1 ) )* 00211 $ CABS1( X( N-1, K ) ) + CABS1( D( N ) )* 00212 $ CABS1( X( N, K ) ) 00213 AXBI = MIN( AXBI, TMP ) 00214 END IF 00215 END IF 00216 TMP = BERR( K ) / ( NZ*EPS+NZ*UNFL / MAX( AXBI, NZ*UNFL ) ) 00217 IF( K.EQ.1 ) THEN 00218 RESLTS( 2 ) = TMP 00219 ELSE 00220 RESLTS( 2 ) = MAX( RESLTS( 2 ), TMP ) 00221 END IF 00222 60 CONTINUE 00223 * 00224 RETURN 00225 * 00226 * End of CGTT05 00227 * 00228 END