LAPACK 3.3.0
|
00001 SUBROUTINE CCHKHE( DOTYPE, NN, NVAL, NNB, NBVAL, NNS, NSVAL, 00002 $ THRESH, TSTERR, NMAX, A, AFAC, AINV, B, X, 00003 $ XACT, WORK, RWORK, IWORK, NOUT ) 00004 * 00005 * -- LAPACK test routine (version 3.3.0) -- 00006 * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. 00007 * November 2010 00008 * 00009 * .. Scalar Arguments .. 00010 LOGICAL TSTERR 00011 INTEGER NMAX, NN, NNB, NNS, NOUT 00012 REAL THRESH 00013 * .. 00014 * .. Array Arguments .. 00015 LOGICAL DOTYPE( * ) 00016 INTEGER IWORK( * ), NBVAL( * ), NSVAL( * ), NVAL( * ) 00017 REAL RWORK( * ) 00018 COMPLEX A( * ), AFAC( * ), AINV( * ), B( * ), 00019 $ WORK( * ), X( * ), XACT( * ) 00020 * .. 00021 * 00022 * Purpose 00023 * ======= 00024 * 00025 * CCHKHE tests CHETRF, -TRI, -TRS, -TRS2, -RFS, and -CON. 00026 * 00027 * Arguments 00028 * ========= 00029 * 00030 * DOTYPE (input) LOGICAL array, dimension (NTYPES) 00031 * The matrix types to be used for testing. Matrices of type j 00032 * (for 1 <= j <= NTYPES) are used for testing if DOTYPE(j) = 00033 * .TRUE.; if DOTYPE(j) = .FALSE., then type j is not used. 00034 * 00035 * NN (input) INTEGER 00036 * The number of values of N contained in the vector NVAL. 00037 * 00038 * NVAL (input) INTEGER array, dimension (NN) 00039 * The values of the matrix dimension N. 00040 * 00041 * NNB (input) INTEGER 00042 * The number of values of NB contained in the vector NBVAL. 00043 * 00044 * NBVAL (input) INTEGER array, dimension (NBVAL) 00045 * The values of the blocksize NB. 00046 * 00047 * NNS (input) INTEGER 00048 * The number of values of NRHS contained in the vector NSVAL. 00049 * 00050 * NSVAL (input) INTEGER array, dimension (NNS) 00051 * The values of the number of right hand sides NRHS. 00052 * 00053 * THRESH (input) REAL 00054 * The threshold value for the test ratios. A result is 00055 * included in the output file if RESULT >= THRESH. To have 00056 * every test ratio printed, use THRESH = 0. 00057 * 00058 * TSTERR (input) LOGICAL 00059 * Flag that indicates whether error exits are to be tested. 00060 * 00061 * NMAX (input) INTEGER 00062 * The maximum value permitted for N, used in dimensioning the 00063 * work arrays. 00064 * 00065 * A (workspace) COMPLEX array, dimension (NMAX*NMAX) 00066 * 00067 * AFAC (workspace) COMPLEX array, dimension (NMAX*NMAX) 00068 * 00069 * AINV (workspace) COMPLEX array, dimension (NMAX*NMAX) 00070 * 00071 * B (workspace) COMPLEX array, dimension (NMAX*NSMAX) 00072 * where NSMAX is the largest entry in NSVAL. 00073 * 00074 * X (workspace) COMPLEX array, dimension (NMAX*NSMAX) 00075 * 00076 * XACT (workspace) COMPLEX array, dimension (NMAX*NSMAX) 00077 * 00078 * WORK (workspace) COMPLEX array, dimension 00079 * (NMAX*max(3,NSMAX)) 00080 * 00081 * RWORK (workspace) REAL array, dimension 00082 * (max(NMAX,2*NSMAX)) 00083 * 00084 * IWORK (workspace) INTEGER array, dimension (NMAX) 00085 * 00086 * NOUT (input) INTEGER 00087 * The unit number for output. 00088 * 00089 * ===================================================================== 00090 * 00091 * .. Parameters .. 00092 REAL ZERO 00093 PARAMETER ( ZERO = 0.0E+0 ) 00094 INTEGER NTYPES 00095 PARAMETER ( NTYPES = 10 ) 00096 INTEGER NTESTS 00097 PARAMETER ( NTESTS = 9 ) 00098 * .. 00099 * .. Local Scalars .. 00100 LOGICAL TRFCON, ZEROT 00101 CHARACTER DIST, TYPE, UPLO, XTYPE 00102 CHARACTER*3 PATH 00103 INTEGER I, I1, I2, IMAT, IN, INB, INFO, IOFF, IRHS, 00104 $ IUPLO, IZERO, J, K, KL, KU, LDA, LWORK, MODE, 00105 $ N, NB, NERRS, NFAIL, NIMAT, NRHS, NRUN, NT 00106 REAL ANORM, CNDNUM, RCOND, RCONDC 00107 * .. 00108 * .. Local Arrays .. 00109 CHARACTER UPLOS( 2 ) 00110 INTEGER ISEED( 4 ), ISEEDY( 4 ) 00111 REAL RESULT( NTESTS ) 00112 * .. 00113 * .. External Functions .. 00114 REAL CLANHE, SGET06 00115 EXTERNAL CLANHE, SGET06 00116 * .. 00117 * .. External Subroutines .. 00118 EXTERNAL ALAERH, ALAHD, ALASUM, CERRHE, CGET04, CHECON, 00119 $ CHERFS, CHET01, CHETRF, CHETRI, CHETRS, CLACPY, 00120 $ CLAIPD, CLARHS, CLATB4, CLATMS, CPOT02, CPOT03, 00121 $ CPOT05, XLAENV 00122 * .. 00123 * .. Intrinsic Functions .. 00124 INTRINSIC MAX, MIN 00125 * .. 00126 * .. Scalars in Common .. 00127 LOGICAL LERR, OK 00128 CHARACTER*32 SRNAMT 00129 INTEGER INFOT, NUNIT 00130 * .. 00131 * .. Common blocks .. 00132 COMMON / INFOC / INFOT, NUNIT, OK, LERR 00133 COMMON / SRNAMC / SRNAMT 00134 * .. 00135 * .. Data statements .. 00136 DATA ISEEDY / 1988, 1989, 1990, 1991 / 00137 DATA UPLOS / 'U', 'L' / 00138 * .. 00139 * .. Executable Statements .. 00140 * 00141 * Initialize constants and the random number seed. 00142 * 00143 PATH( 1: 1 ) = 'Complex precision' 00144 PATH( 2: 3 ) = 'HE' 00145 NRUN = 0 00146 NFAIL = 0 00147 NERRS = 0 00148 DO 10 I = 1, 4 00149 ISEED( I ) = ISEEDY( I ) 00150 10 CONTINUE 00151 * 00152 * Test the error exits 00153 * 00154 IF( TSTERR ) 00155 $ CALL CERRHE( PATH, NOUT ) 00156 INFOT = 0 00157 * 00158 * Do for each value of N in NVAL 00159 * 00160 DO 180 IN = 1, NN 00161 N = NVAL( IN ) 00162 LDA = MAX( N, 1 ) 00163 XTYPE = 'N' 00164 NIMAT = NTYPES 00165 IF( N.LE.0 ) 00166 $ NIMAT = 1 00167 * 00168 IZERO = 0 00169 DO 170 IMAT = 1, NIMAT 00170 * 00171 * Do the tests only if DOTYPE( IMAT ) is true. 00172 * 00173 IF( .NOT.DOTYPE( IMAT ) ) 00174 $ GO TO 170 00175 * 00176 * Skip types 3, 4, 5, or 6 if the matrix size is too small. 00177 * 00178 ZEROT = IMAT.GE.3 .AND. IMAT.LE.6 00179 IF( ZEROT .AND. N.LT.IMAT-2 ) 00180 $ GO TO 170 00181 * 00182 * Do first for UPLO = 'U', then for UPLO = 'L' 00183 * 00184 DO 160 IUPLO = 1, 2 00185 UPLO = UPLOS( IUPLO ) 00186 * 00187 * Set up parameters with CLATB4 and generate a test matrix 00188 * with CLATMS. 00189 * 00190 CALL CLATB4( PATH, IMAT, N, N, TYPE, KL, KU, ANORM, MODE, 00191 $ CNDNUM, DIST ) 00192 * 00193 SRNAMT = 'CLATMS' 00194 CALL CLATMS( N, N, DIST, ISEED, TYPE, RWORK, MODE, 00195 $ CNDNUM, ANORM, KL, KU, UPLO, A, LDA, WORK, 00196 $ INFO ) 00197 * 00198 * Check error code from CLATMS. 00199 * 00200 IF( INFO.NE.0 ) THEN 00201 CALL ALAERH( PATH, 'CLATMS', INFO, 0, UPLO, N, N, -1, 00202 $ -1, -1, IMAT, NFAIL, NERRS, NOUT ) 00203 GO TO 160 00204 END IF 00205 * 00206 * For types 3-6, zero one or more rows and columns of 00207 * the matrix to test that INFO is returned correctly. 00208 * 00209 IF( ZEROT ) THEN 00210 IF( IMAT.EQ.3 ) THEN 00211 IZERO = 1 00212 ELSE IF( IMAT.EQ.4 ) THEN 00213 IZERO = N 00214 ELSE 00215 IZERO = N / 2 + 1 00216 END IF 00217 * 00218 IF( IMAT.LT.6 ) THEN 00219 * 00220 * Set row and column IZERO to zero. 00221 * 00222 IF( IUPLO.EQ.1 ) THEN 00223 IOFF = ( IZERO-1 )*LDA 00224 DO 20 I = 1, IZERO - 1 00225 A( IOFF+I ) = ZERO 00226 20 CONTINUE 00227 IOFF = IOFF + IZERO 00228 DO 30 I = IZERO, N 00229 A( IOFF ) = ZERO 00230 IOFF = IOFF + LDA 00231 30 CONTINUE 00232 ELSE 00233 IOFF = IZERO 00234 DO 40 I = 1, IZERO - 1 00235 A( IOFF ) = ZERO 00236 IOFF = IOFF + LDA 00237 40 CONTINUE 00238 IOFF = IOFF - IZERO 00239 DO 50 I = IZERO, N 00240 A( IOFF+I ) = ZERO 00241 50 CONTINUE 00242 END IF 00243 ELSE 00244 IOFF = 0 00245 IF( IUPLO.EQ.1 ) THEN 00246 * 00247 * Set the first IZERO rows and columns to zero. 00248 * 00249 DO 70 J = 1, N 00250 I2 = MIN( J, IZERO ) 00251 DO 60 I = 1, I2 00252 A( IOFF+I ) = ZERO 00253 60 CONTINUE 00254 IOFF = IOFF + LDA 00255 70 CONTINUE 00256 ELSE 00257 * 00258 * Set the last IZERO rows and columns to zero. 00259 * 00260 DO 90 J = 1, N 00261 I1 = MAX( J, IZERO ) 00262 DO 80 I = I1, N 00263 A( IOFF+I ) = ZERO 00264 80 CONTINUE 00265 IOFF = IOFF + LDA 00266 90 CONTINUE 00267 END IF 00268 END IF 00269 ELSE 00270 IZERO = 0 00271 END IF 00272 * 00273 * Set the imaginary part of the diagonals. 00274 * 00275 CALL CLAIPD( N, A, LDA+1, 0 ) 00276 * 00277 * Do for each value of NB in NBVAL 00278 * 00279 DO 150 INB = 1, NNB 00280 NB = NBVAL( INB ) 00281 CALL XLAENV( 1, NB ) 00282 * 00283 * Compute the L*D*L' or U*D*U' factorization of the 00284 * matrix. 00285 * 00286 CALL CLACPY( UPLO, N, N, A, LDA, AFAC, LDA ) 00287 LWORK = MAX( 2, NB )*LDA 00288 SRNAMT = 'CHETRF' 00289 CALL CHETRF( UPLO, N, AFAC, LDA, IWORK, AINV, LWORK, 00290 $ INFO ) 00291 * 00292 * Adjust the expected value of INFO to account for 00293 * pivoting. 00294 * 00295 K = IZERO 00296 IF( K.GT.0 ) THEN 00297 100 CONTINUE 00298 IF( IWORK( K ).LT.0 ) THEN 00299 IF( IWORK( K ).NE.-K ) THEN 00300 K = -IWORK( K ) 00301 GO TO 100 00302 END IF 00303 ELSE IF( IWORK( K ).NE.K ) THEN 00304 K = IWORK( K ) 00305 GO TO 100 00306 END IF 00307 END IF 00308 * 00309 * Check error code from CHETRF. 00310 * 00311 IF( INFO.NE.K ) 00312 $ CALL ALAERH( PATH, 'CHETRF', INFO, K, UPLO, N, N, 00313 $ -1, -1, NB, IMAT, NFAIL, NERRS, NOUT ) 00314 IF( INFO.NE.0 ) THEN 00315 TRFCON = .TRUE. 00316 ELSE 00317 TRFCON = .FALSE. 00318 END IF 00319 * 00320 *+ TEST 1 00321 * Reconstruct matrix from factors and compute residual. 00322 * 00323 CALL CHET01( UPLO, N, A, LDA, AFAC, LDA, IWORK, AINV, 00324 $ LDA, RWORK, RESULT( 1 ) ) 00325 NT = 1 00326 * 00327 *+ TEST 2 00328 * Form the inverse and compute the residual. 00329 * 00330 IF( INB.EQ.1 .AND. .NOT.TRFCON ) THEN 00331 CALL CLACPY( UPLO, N, N, AFAC, LDA, AINV, LDA ) 00332 SRNAMT = 'CHETRI' 00333 CALL CHETRI( UPLO, N, AINV, LDA, IWORK, WORK, 00334 $ INFO ) 00335 * 00336 * Check error code from CHETRI. 00337 * 00338 IF( INFO.NE.0 ) 00339 $ CALL ALAERH( PATH, 'CHETRI', INFO, -1, UPLO, N, 00340 $ N, -1, -1, -1, IMAT, NFAIL, NERRS, 00341 $ NOUT ) 00342 * 00343 CALL CPOT03( UPLO, N, A, LDA, AINV, LDA, WORK, LDA, 00344 $ RWORK, RCONDC, RESULT( 2 ) ) 00345 NT = 2 00346 END IF 00347 * 00348 * Print information about the tests that did not pass 00349 * the threshold. 00350 * 00351 DO 110 K = 1, NT 00352 IF( RESULT( K ).GE.THRESH ) THEN 00353 IF( NFAIL.EQ.0 .AND. NERRS.EQ.0 ) 00354 $ CALL ALAHD( NOUT, PATH ) 00355 WRITE( NOUT, FMT = 9999 )UPLO, N, NB, IMAT, K, 00356 $ RESULT( K ) 00357 NFAIL = NFAIL + 1 00358 END IF 00359 110 CONTINUE 00360 NRUN = NRUN + NT 00361 * 00362 * Skip the other tests if this is not the first block 00363 * size. 00364 * 00365 IF( INB.GT.1 ) 00366 $ GO TO 150 00367 * 00368 * Do only the condition estimate if INFO is not 0. 00369 * 00370 IF( TRFCON ) THEN 00371 RCONDC = ZERO 00372 GO TO 140 00373 END IF 00374 * 00375 DO 130 IRHS = 1, NNS 00376 NRHS = NSVAL( IRHS ) 00377 * 00378 *+ TEST 3 00379 * Solve and compute residual for A * X = B. 00380 * 00381 SRNAMT = 'CLARHS' 00382 CALL CLARHS( PATH, XTYPE, UPLO, ' ', N, N, KL, KU, 00383 $ NRHS, A, LDA, XACT, LDA, B, LDA, 00384 $ ISEED, INFO ) 00385 CALL CLACPY( 'Full', N, NRHS, B, LDA, X, LDA ) 00386 * 00387 SRNAMT = 'CHETRS' 00388 CALL CHETRS( UPLO, N, NRHS, AFAC, LDA, IWORK, X, 00389 $ LDA, INFO ) 00390 * 00391 * Check error code from CHETRS. 00392 * 00393 IF( INFO.NE.0 ) 00394 $ CALL ALAERH( PATH, 'CHETRS', INFO, 0, UPLO, N, 00395 $ N, -1, -1, NRHS, IMAT, NFAIL, 00396 $ NERRS, NOUT ) 00397 * 00398 CALL CLACPY( 'Full', N, NRHS, B, LDA, WORK, LDA ) 00399 CALL CPOT02( UPLO, N, NRHS, A, LDA, X, LDA, WORK, 00400 $ LDA, RWORK, RESULT( 3 ) ) 00401 * 00402 *+ TEST 4 00403 * Solve and compute residual for A * X = B. 00404 * 00405 SRNAMT = 'CLARHS' 00406 CALL CLARHS( PATH, XTYPE, UPLO, ' ', N, N, KL, KU, 00407 $ NRHS, A, LDA, XACT, LDA, B, LDA, 00408 $ ISEED, INFO ) 00409 CALL CLACPY( 'Full', N, NRHS, B, LDA, X, LDA ) 00410 * 00411 SRNAMT = 'CHETRS2' 00412 CALL CHETRS2( UPLO, N, NRHS, AFAC, LDA, IWORK, X, 00413 $ LDA, WORK, INFO ) 00414 * 00415 * Check error code from CHETRS2. 00416 * 00417 IF( INFO.NE.0 ) 00418 $ CALL ALAERH( PATH, 'CHETRS2', INFO, 0, UPLO, N, 00419 $ N, -1, -1, NRHS, IMAT, NFAIL, 00420 $ NERRS, NOUT ) 00421 * 00422 CALL CLACPY( 'Full', N, NRHS, B, LDA, WORK, LDA ) 00423 CALL CPOT02( UPLO, N, NRHS, A, LDA, X, LDA, WORK, 00424 $ LDA, RWORK, RESULT( 4 ) ) 00425 * 00426 *+ TEST 5 00427 * Check solution from generated exact solution. 00428 * 00429 CALL CGET04( N, NRHS, X, LDA, XACT, LDA, RCONDC, 00430 $ RESULT( 5 ) ) 00431 * 00432 *+ TESTS 6, 7, and 8 00433 * Use iterative refinement to improve the solution. 00434 * 00435 SRNAMT = 'CHERFS' 00436 CALL CHERFS( UPLO, N, NRHS, A, LDA, AFAC, LDA, 00437 $ IWORK, B, LDA, X, LDA, RWORK, 00438 $ RWORK( NRHS+1 ), WORK, 00439 $ RWORK( 2*NRHS+1 ), INFO ) 00440 * 00441 * Check error code from CHERFS. 00442 * 00443 IF( INFO.NE.0 ) 00444 $ CALL ALAERH( PATH, 'CHERFS', INFO, 0, UPLO, N, 00445 $ N, -1, -1, NRHS, IMAT, NFAIL, 00446 $ NERRS, NOUT ) 00447 * 00448 CALL CGET04( N, NRHS, X, LDA, XACT, LDA, RCONDC, 00449 $ RESULT( 6 ) ) 00450 CALL CPOT05( UPLO, N, NRHS, A, LDA, B, LDA, X, LDA, 00451 $ XACT, LDA, RWORK, RWORK( NRHS+1 ), 00452 $ RESULT( 7 ) ) 00453 * 00454 * Print information about the tests that did not pass 00455 * the threshold. 00456 * 00457 DO 120 K = 3, 8 00458 IF( RESULT( K ).GE.THRESH ) THEN 00459 IF( NFAIL.EQ.0 .AND. NERRS.EQ.0 ) 00460 $ CALL ALAHD( NOUT, PATH ) 00461 WRITE( NOUT, FMT = 9998 )UPLO, N, NRHS, 00462 $ IMAT, K, RESULT( K ) 00463 NFAIL = NFAIL + 1 00464 END IF 00465 120 CONTINUE 00466 NRUN = NRUN + 5 00467 130 CONTINUE 00468 * 00469 *+ TEST 9 00470 * Get an estimate of RCOND = 1/CNDNUM. 00471 * 00472 140 CONTINUE 00473 ANORM = CLANHE( '1', UPLO, N, A, LDA, RWORK ) 00474 SRNAMT = 'CHECON' 00475 CALL CHECON( UPLO, N, AFAC, LDA, IWORK, ANORM, RCOND, 00476 $ WORK, INFO ) 00477 * 00478 * Check error code from CHECON. 00479 * 00480 IF( INFO.NE.0 ) 00481 $ CALL ALAERH( PATH, 'CHECON', INFO, 0, UPLO, N, N, 00482 $ -1, -1, -1, IMAT, NFAIL, NERRS, NOUT ) 00483 * 00484 RESULT( 9 ) = SGET06( RCOND, RCONDC ) 00485 * 00486 * Print information about the tests that did not pass 00487 * the threshold. 00488 * 00489 IF( RESULT( 9 ).GE.THRESH ) THEN 00490 IF( NFAIL.EQ.0 .AND. NERRS.EQ.0 ) 00491 $ CALL ALAHD( NOUT, PATH ) 00492 WRITE( NOUT, FMT = 9997 )UPLO, N, IMAT, 8, 00493 $ RESULT( 9 ) 00494 NFAIL = NFAIL + 1 00495 END IF 00496 NRUN = NRUN + 1 00497 150 CONTINUE 00498 160 CONTINUE 00499 170 CONTINUE 00500 180 CONTINUE 00501 * 00502 * Print a summary of the results. 00503 * 00504 CALL ALASUM( PATH, NOUT, NFAIL, NRUN, NERRS ) 00505 * 00506 9999 FORMAT( ' UPLO = ''', A1, ''', N =', I5, ', NB =', I4, ', type ', 00507 $ I2, ', test ', I2, ', ratio =', G12.5 ) 00508 9998 FORMAT( ' UPLO = ''', A1, ''', N =', I5, ', NRHS=', I3, ', type ', 00509 $ I2, ', test(', I2, ') =', G12.5 ) 00510 9997 FORMAT( ' UPLO = ''', A1, ''', N =', I5, ',', 10X, ' type ', I2, 00511 $ ', test(', I2, ') =', G12.5 ) 00512 RETURN 00513 * 00514 * End of CCHKHE 00515 * 00516 END