1*> \brief \b CTPT05 2* 3* =========== DOCUMENTATION =========== 4* 5* Online html documentation available at 6* http://www.netlib.org/lapack/explore-html/ 7* 8* Definition: 9* =========== 10* 11* SUBROUTINE CTPT05( UPLO, TRANS, DIAG, N, NRHS, AP, B, LDB, X, LDX, 12* XACT, LDXACT, FERR, BERR, RESLTS ) 13* 14* .. Scalar Arguments .. 15* CHARACTER DIAG, TRANS, UPLO 16* INTEGER LDB, LDX, LDXACT, N, NRHS 17* .. 18* .. Array Arguments .. 19* REAL BERR( * ), FERR( * ), RESLTS( * ) 20* COMPLEX AP( * ), B( LDB, * ), X( LDX, * ), 21* $ XACT( LDXACT, * ) 22* .. 23* 24* 25*> \par Purpose: 26* ============= 27*> 28*> \verbatim 29*> 30*> CTPT05 tests the error bounds from iterative refinement for the 31*> computed solution to a system of equations A*X = B, where A is a 32*> triangular matrix in packed storage format. 33*> 34*> RESLTS(1) = test of the error bound 35*> = norm(X - XACT) / ( norm(X) * FERR ) 36*> 37*> A large value is returned if this ratio is not less than one. 38*> 39*> RESLTS(2) = residual from the iterative refinement routine 40*> = the maximum of BERR / ( (n+1)*EPS + (*) ), where 41*> (*) = (n+1)*UNFL / (min_i (abs(A)*abs(X) +abs(b))_i ) 42*> \endverbatim 43* 44* Arguments: 45* ========== 46* 47*> \param[in] UPLO 48*> \verbatim 49*> UPLO is CHARACTER*1 50*> Specifies whether the matrix A is upper or lower triangular. 51*> = 'U': Upper triangular 52*> = 'L': Lower triangular 53*> \endverbatim 54*> 55*> \param[in] TRANS 56*> \verbatim 57*> TRANS is CHARACTER*1 58*> Specifies the form of the system of equations. 59*> = 'N': A * X = B (No transpose) 60*> = 'T': A'* X = B (Transpose) 61*> = 'C': A'* X = B (Conjugate transpose = Transpose) 62*> \endverbatim 63*> 64*> \param[in] DIAG 65*> \verbatim 66*> DIAG is CHARACTER*1 67*> Specifies whether or not the matrix A is unit triangular. 68*> = 'N': Non-unit triangular 69*> = 'U': Unit triangular 70*> \endverbatim 71*> 72*> \param[in] N 73*> \verbatim 74*> N is INTEGER 75*> The number of rows of the matrices X, B, and XACT, and the 76*> order of the matrix A. N >= 0. 77*> \endverbatim 78*> 79*> \param[in] NRHS 80*> \verbatim 81*> NRHS is INTEGER 82*> The number of columns of the matrices X, B, and XACT. 83*> NRHS >= 0. 84*> \endverbatim 85*> 86*> \param[in] AP 87*> \verbatim 88*> AP is COMPLEX array, dimension (N*(N+1)/2) 89*> The upper or lower triangular matrix A, packed columnwise in 90*> a linear array. The j-th column of A is stored in the array 91*> AP as follows: 92*> if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; 93*> if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n. 94*> If DIAG = 'U', the diagonal elements of A are not referenced 95*> and are assumed to be 1. 96*> \endverbatim 97*> 98*> \param[in] B 99*> \verbatim 100*> B is COMPLEX array, dimension (LDB,NRHS) 101*> The right hand side vectors for the system of linear 102*> equations. 103*> \endverbatim 104*> 105*> \param[in] LDB 106*> \verbatim 107*> LDB is INTEGER 108*> The leading dimension of the array B. LDB >= max(1,N). 109*> \endverbatim 110*> 111*> \param[in] X 112*> \verbatim 113*> X is COMPLEX array, dimension (LDX,NRHS) 114*> The computed solution vectors. Each vector is stored as a 115*> column of the matrix X. 116*> \endverbatim 117*> 118*> \param[in] LDX 119*> \verbatim 120*> LDX is INTEGER 121*> The leading dimension of the array X. LDX >= max(1,N). 122*> \endverbatim 123*> 124*> \param[in] XACT 125*> \verbatim 126*> XACT is COMPLEX array, dimension (LDX,NRHS) 127*> The exact solution vectors. Each vector is stored as a 128*> column of the matrix XACT. 129*> \endverbatim 130*> 131*> \param[in] LDXACT 132*> \verbatim 133*> LDXACT is INTEGER 134*> The leading dimension of the array XACT. LDXACT >= max(1,N). 135*> \endverbatim 136*> 137*> \param[in] FERR 138*> \verbatim 139*> FERR is REAL array, dimension (NRHS) 140*> The estimated forward error bounds for each solution vector 141*> X. If XTRUE is the true solution, FERR bounds the magnitude 142*> of the largest entry in (X - XTRUE) divided by the magnitude 143*> of the largest entry in X. 144*> \endverbatim 145*> 146*> \param[in] BERR 147*> \verbatim 148*> BERR is REAL array, dimension (NRHS) 149*> The componentwise relative backward error of each solution 150*> vector (i.e., the smallest relative change in any entry of A 151*> or B that makes X an exact solution). 152*> \endverbatim 153*> 154*> \param[out] RESLTS 155*> \verbatim 156*> RESLTS is REAL array, dimension (2) 157*> The maximum over the NRHS solution vectors of the ratios: 158*> RESLTS(1) = norm(X - XACT) / ( norm(X) * FERR ) 159*> RESLTS(2) = BERR / ( (n+1)*EPS + (*) ) 160*> \endverbatim 161* 162* Authors: 163* ======== 164* 165*> \author Univ. of Tennessee 166*> \author Univ. of California Berkeley 167*> \author Univ. of Colorado Denver 168*> \author NAG Ltd. 169* 170*> \ingroup complex_lin 171* 172* ===================================================================== 173 SUBROUTINE CTPT05( UPLO, TRANS, DIAG, N, NRHS, AP, B, LDB, X, LDX, 174 $ XACT, LDXACT, FERR, BERR, RESLTS ) 175* 176* -- LAPACK test routine -- 177* -- LAPACK is a software package provided by Univ. of Tennessee, -- 178* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- 179* 180* .. Scalar Arguments .. 181 CHARACTER DIAG, TRANS, UPLO 182 INTEGER LDB, LDX, LDXACT, N, NRHS 183* .. 184* .. Array Arguments .. 185 REAL BERR( * ), FERR( * ), RESLTS( * ) 186 COMPLEX AP( * ), B( LDB, * ), X( LDX, * ), 187 $ XACT( LDXACT, * ) 188* .. 189* 190* ===================================================================== 191* 192* .. Parameters .. 193 REAL ZERO, ONE 194 PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 ) 195* .. 196* .. Local Scalars .. 197 LOGICAL NOTRAN, UNIT, UPPER 198 INTEGER I, IFU, IMAX, J, JC, K 199 REAL AXBI, DIFF, EPS, ERRBND, OVFL, TMP, UNFL, XNORM 200 COMPLEX ZDUM 201* .. 202* .. External Functions .. 203 LOGICAL LSAME 204 INTEGER ICAMAX 205 REAL SLAMCH 206 EXTERNAL LSAME, ICAMAX, SLAMCH 207* .. 208* .. Intrinsic Functions .. 209 INTRINSIC ABS, AIMAG, MAX, MIN, REAL 210* .. 211* .. Statement Functions .. 212 REAL CABS1 213* .. 214* .. Statement Function definitions .. 215 CABS1( ZDUM ) = ABS( REAL( ZDUM ) ) + ABS( AIMAG( ZDUM ) ) 216* .. 217* .. Executable Statements .. 218* 219* Quick exit if N = 0 or NRHS = 0. 220* 221 IF( N.LE.0 .OR. NRHS.LE.0 ) THEN 222 RESLTS( 1 ) = ZERO 223 RESLTS( 2 ) = ZERO 224 RETURN 225 END IF 226* 227 EPS = SLAMCH( 'Epsilon' ) 228 UNFL = SLAMCH( 'Safe minimum' ) 229 OVFL = ONE / UNFL 230 UPPER = LSAME( UPLO, 'U' ) 231 NOTRAN = LSAME( TRANS, 'N' ) 232 UNIT = LSAME( DIAG, 'U' ) 233* 234* Test 1: Compute the maximum of 235* norm(X - XACT) / ( norm(X) * FERR ) 236* over all the vectors X and XACT using the infinity-norm. 237* 238 ERRBND = ZERO 239 DO 30 J = 1, NRHS 240 IMAX = ICAMAX( N, X( 1, J ), 1 ) 241 XNORM = MAX( CABS1( X( IMAX, J ) ), UNFL ) 242 DIFF = ZERO 243 DO 10 I = 1, N 244 DIFF = MAX( DIFF, CABS1( X( I, J )-XACT( I, J ) ) ) 245 10 CONTINUE 246* 247 IF( XNORM.GT.ONE ) THEN 248 GO TO 20 249 ELSE IF( DIFF.LE.OVFL*XNORM ) THEN 250 GO TO 20 251 ELSE 252 ERRBND = ONE / EPS 253 GO TO 30 254 END IF 255* 256 20 CONTINUE 257 IF( DIFF / XNORM.LE.FERR( J ) ) THEN 258 ERRBND = MAX( ERRBND, ( DIFF / XNORM ) / FERR( J ) ) 259 ELSE 260 ERRBND = ONE / EPS 261 END IF 262 30 CONTINUE 263 RESLTS( 1 ) = ERRBND 264* 265* Test 2: Compute the maximum of BERR / ( (n+1)*EPS + (*) ), where 266* (*) = (n+1)*UNFL / (min_i (abs(A)*abs(X) +abs(b))_i ) 267* 268 IFU = 0 269 IF( UNIT ) 270 $ IFU = 1 271 DO 90 K = 1, NRHS 272 DO 80 I = 1, N 273 TMP = CABS1( B( I, K ) ) 274 IF( UPPER ) THEN 275 JC = ( ( I-1 )*I ) / 2 276 IF( .NOT.NOTRAN ) THEN 277 DO 40 J = 1, I - IFU 278 TMP = TMP + CABS1( AP( JC+J ) )*CABS1( X( J, K ) ) 279 40 CONTINUE 280 IF( UNIT ) 281 $ TMP = TMP + CABS1( X( I, K ) ) 282 ELSE 283 JC = JC + I 284 IF( UNIT ) THEN 285 TMP = TMP + CABS1( X( I, K ) ) 286 JC = JC + I 287 END IF 288 DO 50 J = I + IFU, N 289 TMP = TMP + CABS1( AP( JC ) )*CABS1( X( J, K ) ) 290 JC = JC + J 291 50 CONTINUE 292 END IF 293 ELSE 294 IF( NOTRAN ) THEN 295 JC = I 296 DO 60 J = 1, I - IFU 297 TMP = TMP + CABS1( AP( JC ) )*CABS1( X( J, K ) ) 298 JC = JC + N - J 299 60 CONTINUE 300 IF( UNIT ) 301 $ TMP = TMP + CABS1( X( I, K ) ) 302 ELSE 303 JC = ( I-1 )*( N-I ) + ( I*( I+1 ) ) / 2 304 IF( UNIT ) 305 $ TMP = TMP + CABS1( X( I, K ) ) 306 DO 70 J = I + IFU, N 307 TMP = TMP + CABS1( AP( JC+J-I ) )* 308 $ CABS1( X( J, K ) ) 309 70 CONTINUE 310 END IF 311 END IF 312 IF( I.EQ.1 ) THEN 313 AXBI = TMP 314 ELSE 315 AXBI = MIN( AXBI, TMP ) 316 END IF 317 80 CONTINUE 318 TMP = BERR( K ) / ( ( N+1 )*EPS+( N+1 )*UNFL / 319 $ MAX( AXBI, ( N+1 )*UNFL ) ) 320 IF( K.EQ.1 ) THEN 321 RESLTS( 2 ) = TMP 322 ELSE 323 RESLTS( 2 ) = MAX( RESLTS( 2 ), TMP ) 324 END IF 325 90 CONTINUE 326* 327 RETURN 328* 329* End of CTPT05 330* 331 END 332