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