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