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