LAPACK 3.3.1
Linear Algebra PACKage

zchkhe.f

Go to the documentation of this file.
00001       SUBROUTINE ZCHKHE( 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.1) --
00006 *     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
00007 *  -- April 2011                                                      --
00008 *
00009 *     .. Scalar Arguments ..
00010       LOGICAL            TSTERR
00011       INTEGER            NMAX, NN, NNB, NNS, NOUT
00012       DOUBLE PRECISION   THRESH
00013 *     ..
00014 *     .. Array Arguments ..
00015       LOGICAL            DOTYPE( * )
00016       INTEGER            IWORK( * ), NBVAL( * ), NSVAL( * ), NVAL( * )
00017       DOUBLE PRECISION   RWORK( * )
00018       COMPLEX*16         A( * ), AFAC( * ), AINV( * ), B( * ),
00019      $                   WORK( * ), X( * ), XACT( * )
00020 *     ..
00021 *
00022 *  Purpose
00023 *  =======
00024 *
00025 *  ZCHKHE tests ZHETRF, -TRI2, -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) DOUBLE PRECISION
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*16 array, dimension (NMAX*NMAX)
00066 *
00067 *  AFAC    (workspace) COMPLEX*16 array, dimension (NMAX*NMAX)
00068 *
00069 *  AINV    (workspace) COMPLEX*16 array, dimension (NMAX*NMAX)
00070 *
00071 *  B       (workspace) COMPLEX*16 array, dimension (NMAX*NSMAX)
00072 *          where NSMAX is the largest entry in NSVAL.
00073 *
00074 *  X       (workspace) COMPLEX*16 array, dimension (NMAX*NSMAX)
00075 *
00076 *  XACT    (workspace) COMPLEX*16 array, dimension (NMAX*NSMAX)
00077 *
00078 *  WORK    (workspace) COMPLEX*16 array, dimension
00079 *                      (NMAX*max(3,NSMAX))
00080 *
00081 *  RWORK   (workspace) DOUBLE PRECISION 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       DOUBLE PRECISION   ZERO
00093       PARAMETER          ( ZERO = 0.0D+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       DOUBLE PRECISION   ANORM, CNDNUM, RCOND, RCONDC
00107 *     ..
00108 *     .. Local Arrays ..
00109       CHARACTER          UPLOS( 2 )
00110       INTEGER            ISEED( 4 ), ISEEDY( 4 )
00111       DOUBLE PRECISION   RESULT( NTESTS )
00112 *     ..
00113 *     .. External Functions ..
00114       DOUBLE PRECISION   DGET06, ZLANHE
00115       EXTERNAL           DGET06, ZLANHE
00116 *     ..
00117 *     .. External Subroutines ..
00118       EXTERNAL           ALAERH, ALAHD, ALASUM, XLAENV, ZERRHE, ZGET04,
00119      $                   ZHECON, ZHERFS, ZHET01, ZHETRF, ZHETRI2,
00120      $                   ZHETRS, ZLACPY, ZLAIPD, ZLARHS, ZLATB4, ZLATMS,
00121      $                   ZPOT02, ZPOT03, ZPOT05
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 ) = 'Zomplex 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 ZERRHE( 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 ZLATB4 and generate a test matrix
00188 *              with ZLATMS.
00189 *
00190                CALL ZLATB4( PATH, IMAT, N, N, TYPE, KL, KU, ANORM, MODE,
00191      $                      CNDNUM, DIST )
00192 *
00193                SRNAMT = 'ZLATMS'
00194                CALL ZLATMS( N, N, DIST, ISEED, TYPE, RWORK, MODE,
00195      $                      CNDNUM, ANORM, KL, KU, UPLO, A, LDA, WORK,
00196      $                      INFO )
00197 *
00198 *              Check error code from ZLATMS.
00199 *
00200                IF( INFO.NE.0 ) THEN
00201                   CALL ALAERH( PATH, 'ZLATMS', 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 ZLAIPD( 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 ZLACPY( UPLO, N, N, A, LDA, AFAC, LDA )
00287                   LWORK = MAX( 2, NB )*LDA
00288                   SRNAMT = 'ZHETRF'
00289                   CALL ZHETRF( 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 ZHETRF.
00310 *
00311                   IF( INFO.NE.K )
00312      $               CALL ALAERH( PATH, 'ZHETRF', 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 ZHET01( 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 ZLACPY( UPLO, N, N, AFAC, LDA, AINV, LDA )
00332                      SRNAMT = 'ZHETRI2'
00333                      LWORK = (N+NB+1)*(NB+3)
00334                      CALL ZHETRI2( UPLO, N, AINV, LDA, IWORK, WORK,
00335      $                            LWORK, INFO )
00336 *
00337 *                 Check error code from ZHETRI.
00338 *
00339                      IF( INFO.NE.0 )
00340      $                  CALL ALAERH( PATH, 'ZHETRI', INFO, -1, UPLO, N,
00341      $                               N, -1, -1, -1, IMAT, NFAIL, NERRS,
00342      $                               NOUT )
00343 *
00344                      CALL ZPOT03( UPLO, N, A, LDA, AINV, LDA, WORK, LDA,
00345      $                            RWORK, RCONDC, RESULT( 2 ) )
00346                      NT = 2
00347                   END IF
00348 *
00349 *                 Print information about the tests that did not pass
00350 *                 the threshold.
00351 *
00352                   DO 110 K = 1, NT
00353                      IF( RESULT( K ).GE.THRESH ) THEN
00354                         IF( NFAIL.EQ.0 .AND. NERRS.EQ.0 )
00355      $                     CALL ALAHD( NOUT, PATH )
00356                         WRITE( NOUT, FMT = 9999 )UPLO, N, NB, IMAT, K,
00357      $                     RESULT( K )
00358                         NFAIL = NFAIL + 1
00359                      END IF
00360   110             CONTINUE
00361                   NRUN = NRUN + NT
00362 *
00363 *                 Skip the other tests if this is not the first block
00364 *                 size.
00365 *
00366                   IF( INB.GT.1 )
00367      $               GO TO 150
00368 *
00369 *                 Do only the condition estimate if INFO is not 0.
00370 *
00371                   IF( TRFCON ) THEN
00372                      RCONDC = ZERO
00373                      GO TO 140
00374                   END IF
00375 *
00376                   DO 130 IRHS = 1, NNS
00377                      NRHS = NSVAL( IRHS )
00378 *
00379 *+    TEST 3
00380 *                 Solve and compute residual for  A * X = B.
00381 *
00382                      SRNAMT = 'ZLARHS'
00383                      CALL ZLARHS( PATH, XTYPE, UPLO, ' ', N, N, KL, KU,
00384      $                            NRHS, A, LDA, XACT, LDA, B, LDA,
00385      $                            ISEED, INFO )
00386                      CALL ZLACPY( 'Full', N, NRHS, B, LDA, X, LDA )
00387 *
00388                      SRNAMT = 'ZHETRS'
00389                      CALL ZHETRS( UPLO, N, NRHS, AFAC, LDA, IWORK, X,
00390      $                            LDA, INFO )
00391 *
00392 *                 Check error code from ZHETRS.
00393 *
00394                      IF( INFO.NE.0 )
00395      $                  CALL ALAERH( PATH, 'ZHETRS', INFO, 0, UPLO, N,
00396      $                               N, -1, -1, NRHS, IMAT, NFAIL,
00397      $                               NERRS, NOUT )
00398 *
00399                      CALL ZLACPY( 'Full', N, NRHS, B, LDA, WORK, LDA )
00400                      CALL ZPOT02( UPLO, N, NRHS, A, LDA, X, LDA, WORK,
00401      $                            LDA, RWORK, RESULT( 3 ) )
00402 *
00403 *+    TEST 4
00404 *                 Solve and compute residual for  A * X = B.
00405 *
00406                      SRNAMT = 'ZLARHS'
00407                      CALL ZLARHS( PATH, XTYPE, UPLO, ' ', N, N, KL, KU,
00408      $                            NRHS, A, LDA, XACT, LDA, B, LDA,
00409      $                            ISEED, INFO )
00410                      CALL ZLACPY( 'Full', N, NRHS, B, LDA, X, LDA )
00411 *
00412                      SRNAMT = 'ZHETRS2'
00413                      CALL ZHETRS2( UPLO, N, NRHS, AFAC, LDA, IWORK, X,
00414      $                            LDA, WORK, INFO )
00415 *
00416 *                 Check error code from ZSYTRS2.
00417 *
00418                      IF( INFO.NE.0 )
00419      $                  CALL ALAERH( PATH, 'ZHETRS2', INFO, 0, UPLO, N,
00420      $                               N, -1, -1, NRHS, IMAT, NFAIL,
00421      $                               NERRS, NOUT )
00422 *
00423                      CALL ZLACPY( 'Full', N, NRHS, B, LDA, WORK, LDA )
00424                      CALL ZPOT02( UPLO, N, NRHS, A, LDA, X, LDA, WORK,
00425      $                            LDA, RWORK, RESULT( 4 ) )
00426 *
00427 *+    TEST 5
00428 *                 Check solution from generated exact solution.
00429 *
00430                      CALL ZGET04( N, NRHS, X, LDA, XACT, LDA, RCONDC,
00431      $                            RESULT( 5 ) )
00432 *
00433 *+    TESTS 6, 7, and 8
00434 *                 Use iterative refinement to improve the solution.
00435 *
00436                      SRNAMT = 'ZHERFS'
00437                      CALL ZHERFS( UPLO, N, NRHS, A, LDA, AFAC, LDA,
00438      $                            IWORK, B, LDA, X, LDA, RWORK,
00439      $                            RWORK( NRHS+1 ), WORK,
00440      $                            RWORK( 2*NRHS+1 ), INFO )
00441 *
00442 *                 Check error code from ZHERFS.
00443 *
00444                      IF( INFO.NE.0 )
00445      $                  CALL ALAERH( PATH, 'ZHERFS', INFO, 0, UPLO, N,
00446      $                               N, -1, -1, NRHS, IMAT, NFAIL,
00447      $                               NERRS, NOUT )
00448 *
00449                      CALL ZGET04( N, NRHS, X, LDA, XACT, LDA, RCONDC,
00450      $                            RESULT( 6 ) )
00451                      CALL ZPOT05( UPLO, N, NRHS, A, LDA, B, LDA, X, LDA,
00452      $                            XACT, LDA, RWORK, RWORK( NRHS+1 ),
00453      $                            RESULT( 7 ) )
00454 *
00455 *                    Print information about the tests that did not pass
00456 *                    the threshold.
00457 *
00458                      DO 120 K = 3, 8
00459                         IF( RESULT( K ).GE.THRESH ) THEN
00460                            IF( NFAIL.EQ.0 .AND. NERRS.EQ.0 )
00461      $                        CALL ALAHD( NOUT, PATH )
00462                            WRITE( NOUT, FMT = 9998 )UPLO, N, NRHS,
00463      $                        IMAT, K, RESULT( K )
00464                            NFAIL = NFAIL + 1
00465                         END IF
00466   120                CONTINUE
00467                      NRUN = NRUN + 5
00468   130             CONTINUE
00469 *
00470 *+    TEST 9
00471 *                 Get an estimate of RCOND = 1/CNDNUM.
00472 *
00473   140             CONTINUE
00474                   ANORM = ZLANHE( '1', UPLO, N, A, LDA, RWORK )
00475                   SRNAMT = 'ZHECON'
00476                   CALL ZHECON( UPLO, N, AFAC, LDA, IWORK, ANORM, RCOND,
00477      $                         WORK, INFO )
00478 *
00479 *                 Check error code from ZHECON.
00480 *
00481                   IF( INFO.NE.0 )
00482      $               CALL ALAERH( PATH, 'ZHECON', INFO, 0, UPLO, N, N,
00483      $                            -1, -1, -1, IMAT, NFAIL, NERRS, NOUT )
00484 *
00485                   RESULT( 9 ) = DGET06( RCOND, RCONDC )
00486 *
00487 *                 Print information about the tests that did not pass
00488 *                 the threshold.
00489 *
00490                   IF( RESULT( 9 ).GE.THRESH ) THEN
00491                      IF( NFAIL.EQ.0 .AND. NERRS.EQ.0 )
00492      $                  CALL ALAHD( NOUT, PATH )
00493                      WRITE( NOUT, FMT = 9997 )UPLO, N, IMAT, 9,
00494      $                  RESULT( 9 )
00495                      NFAIL = NFAIL + 1
00496                   END IF
00497                   NRUN = NRUN + 1
00498   150          CONTINUE
00499   160       CONTINUE
00500   170    CONTINUE
00501   180 CONTINUE
00502 *
00503 *     Print a summary of the results.
00504 *
00505       CALL ALASUM( PATH, NOUT, NFAIL, NRUN, NERRS )
00506 *
00507  9999 FORMAT( ' UPLO = ''', A1, ''', N =', I5, ', NB =', I4, ', type ',
00508      $      I2, ', test ', I2, ', ratio =', G12.5 )
00509  9998 FORMAT( ' UPLO = ''', A1, ''', N =', I5, ', NRHS=', I3, ', type ',
00510      $      I2, ', test(', I2, ') =', G12.5 )
00511  9997 FORMAT( ' UPLO = ''', A1, ''', N =', I5, ',', 10X, ' type ', I2,
00512      $      ', test(', I2, ') =', G12.5 )
00513       RETURN
00514 *
00515 *     End of ZCHKHE
00516 *
00517       END
 All Files Functions