LAPACK 3.3.1
Linear Algebra PACKage

cdrvhe.f

Go to the documentation of this file.
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.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, 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, CHETRI2, CLACPY,
00110      $                   CLAIPD, CLARHS, CLASET, CLATB4, CLATMS, CPOT02,
00111      $                   CPOT05, 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                      LWORK = (N+NB+1)*(NB+3)
00304                      CALL CHETRI2( UPLO, N, AINV, LDA, IWORK, WORK,
00305      $                            LWORK, INFO )
00306                      AINVNM = CLANHE( '1', UPLO, N, AINV, LDA, RWORK )
00307 *
00308 *                    Compute the 1-norm condition number of A.
00309 *
00310                      IF( ANORM.LE.ZERO .OR. AINVNM.LE.ZERO ) THEN
00311                         RCONDC = ONE
00312                      ELSE
00313                         RCONDC = ( ONE / ANORM ) / AINVNM
00314                      END IF
00315                   END IF
00316 *
00317 *                 Form an exact solution and set the right hand side.
00318 *
00319                   SRNAMT = 'CLARHS'
00320                   CALL CLARHS( PATH, XTYPE, UPLO, ' ', N, N, KL, KU,
00321      $                         NRHS, A, LDA, XACT, LDA, B, LDA, ISEED,
00322      $                         INFO )
00323                   XTYPE = 'C'
00324 *
00325 *                 --- Test CHESV  ---
00326 *
00327                   IF( IFACT.EQ.2 ) THEN
00328                      CALL CLACPY( UPLO, N, N, A, LDA, AFAC, LDA )
00329                      CALL CLACPY( 'Full', N, NRHS, B, LDA, X, LDA )
00330 *
00331 *                    Factor the matrix and solve the system using CHESV.
00332 *
00333                      SRNAMT = 'CHESV '
00334                      CALL CHESV( UPLO, N, NRHS, AFAC, LDA, IWORK, X,
00335      $                           LDA, WORK, LWORK, INFO )
00336 *
00337 *                    Adjust the expected value of INFO to account for
00338 *                    pivoting.
00339 *
00340                      K = IZERO
00341                      IF( K.GT.0 ) THEN
00342   100                   CONTINUE
00343                         IF( IWORK( K ).LT.0 ) THEN
00344                            IF( IWORK( K ).NE.-K ) THEN
00345                               K = -IWORK( K )
00346                               GO TO 100
00347                            END IF
00348                         ELSE IF( IWORK( K ).NE.K ) THEN
00349                            K = IWORK( K )
00350                            GO TO 100
00351                         END IF
00352                      END IF
00353 *
00354 *                    Check error code from CHESV .
00355 *
00356                      IF( INFO.NE.K ) THEN
00357                         CALL ALAERH( PATH, 'CHESV ', INFO, K, UPLO, N,
00358      $                               N, -1, -1, NRHS, IMAT, NFAIL,
00359      $                               NERRS, NOUT )
00360                         GO TO 120
00361                      ELSE IF( INFO.NE.0 ) THEN
00362                         GO TO 120
00363                      END IF
00364 *
00365 *                    Reconstruct matrix from factors and compute
00366 *                    residual.
00367 *
00368                      CALL CHET01( UPLO, N, A, LDA, AFAC, LDA, IWORK,
00369      $                            AINV, LDA, RWORK, RESULT( 1 ) )
00370 *
00371 *                    Compute residual of the computed solution.
00372 *
00373                      CALL CLACPY( 'Full', N, NRHS, B, LDA, WORK, LDA )
00374                      CALL CPOT02( UPLO, N, NRHS, A, LDA, X, LDA, WORK,
00375      $                            LDA, RWORK, RESULT( 2 ) )
00376 *
00377 *                    Check solution from generated exact solution.
00378 *
00379                      CALL CGET04( N, NRHS, X, LDA, XACT, LDA, RCONDC,
00380      $                            RESULT( 3 ) )
00381                      NT = 3
00382 *
00383 *                    Print information about the tests that did not pass
00384 *                    the threshold.
00385 *
00386                      DO 110 K = 1, NT
00387                         IF( RESULT( K ).GE.THRESH ) THEN
00388                            IF( NFAIL.EQ.0 .AND. NERRS.EQ.0 )
00389      $                        CALL ALADHD( NOUT, PATH )
00390                            WRITE( NOUT, FMT = 9999 )'CHESV ', UPLO, N,
00391      $                        IMAT, K, RESULT( K )
00392                            NFAIL = NFAIL + 1
00393                         END IF
00394   110                CONTINUE
00395                      NRUN = NRUN + NT
00396   120                CONTINUE
00397                   END IF
00398 *
00399 *                 --- Test CHESVX ---
00400 *
00401                   IF( IFACT.EQ.2 )
00402      $               CALL CLASET( UPLO, N, N, CMPLX( ZERO ),
00403      $                            CMPLX( ZERO ), AFAC, LDA )
00404                   CALL CLASET( 'Full', N, NRHS, CMPLX( ZERO ),
00405      $                         CMPLX( ZERO ), X, LDA )
00406 *
00407 *                 Solve the system and compute the condition number and
00408 *                 error bounds using CHESVX.
00409 *
00410                   SRNAMT = 'CHESVX'
00411                   CALL CHESVX( FACT, UPLO, N, NRHS, A, LDA, AFAC, LDA,
00412      $                         IWORK, B, LDA, X, LDA, RCOND, RWORK,
00413      $                         RWORK( NRHS+1 ), WORK, LWORK,
00414      $                         RWORK( 2*NRHS+1 ), INFO )
00415 *
00416 *                 Adjust the expected value of INFO to account for
00417 *                 pivoting.
00418 *
00419                   K = IZERO
00420                   IF( K.GT.0 ) THEN
00421   130                CONTINUE
00422                      IF( IWORK( K ).LT.0 ) THEN
00423                         IF( IWORK( K ).NE.-K ) THEN
00424                            K = -IWORK( K )
00425                            GO TO 130
00426                         END IF
00427                      ELSE IF( IWORK( K ).NE.K ) THEN
00428                         K = IWORK( K )
00429                         GO TO 130
00430                      END IF
00431                   END IF
00432 *
00433 *                 Check the error code from CHESVX.
00434 *
00435                   IF( INFO.NE.K ) THEN
00436                      CALL ALAERH( PATH, 'CHESVX', INFO, K, FACT // UPLO,
00437      $                            N, N, -1, -1, NRHS, IMAT, NFAIL,
00438      $                            NERRS, NOUT )
00439                      GO TO 150
00440                   END IF
00441 *
00442                   IF( INFO.EQ.0 ) THEN
00443                      IF( IFACT.GE.2 ) THEN
00444 *
00445 *                       Reconstruct matrix from factors and compute
00446 *                       residual.
00447 *
00448                         CALL CHET01( UPLO, N, A, LDA, AFAC, LDA, IWORK,
00449      $                               AINV, LDA, RWORK( 2*NRHS+1 ),
00450      $                               RESULT( 1 ) )
00451                         K1 = 1
00452                      ELSE
00453                         K1 = 2
00454                      END IF
00455 *
00456 *                    Compute residual of the computed solution.
00457 *
00458                      CALL CLACPY( 'Full', N, NRHS, B, LDA, WORK, LDA )
00459                      CALL CPOT02( UPLO, N, NRHS, A, LDA, X, LDA, WORK,
00460      $                            LDA, RWORK( 2*NRHS+1 ), RESULT( 2 ) )
00461 *
00462 *                    Check solution from generated exact solution.
00463 *
00464                      CALL CGET04( N, NRHS, X, LDA, XACT, LDA, RCONDC,
00465      $                            RESULT( 3 ) )
00466 *
00467 *                    Check the error bounds from iterative refinement.
00468 *
00469                      CALL CPOT05( UPLO, N, NRHS, A, LDA, B, LDA, X, LDA,
00470      $                            XACT, LDA, RWORK, RWORK( NRHS+1 ),
00471      $                            RESULT( 4 ) )
00472                   ELSE
00473                      K1 = 6
00474                   END IF
00475 *
00476 *                 Compare RCOND from CHESVX with the computed value
00477 *                 in RCONDC.
00478 *
00479                   RESULT( 6 ) = SGET06( RCOND, RCONDC )
00480 *
00481 *                 Print information about the tests that did not pass
00482 *                 the threshold.
00483 *
00484                   DO 140 K = K1, 6
00485                      IF( RESULT( K ).GE.THRESH ) THEN
00486                         IF( NFAIL.EQ.0 .AND. NERRS.EQ.0 )
00487      $                     CALL ALADHD( NOUT, PATH )
00488                         WRITE( NOUT, FMT = 9998 )'CHESVX', FACT, UPLO,
00489      $                     N, IMAT, K, RESULT( K )
00490                         NFAIL = NFAIL + 1
00491                      END IF
00492   140             CONTINUE
00493                   NRUN = NRUN + 7 - K1
00494 *
00495   150          CONTINUE
00496 *
00497   160       CONTINUE
00498   170    CONTINUE
00499   180 CONTINUE
00500 *
00501 *     Print a summary of the results.
00502 *
00503       CALL ALASVM( PATH, NOUT, NFAIL, NRUN, NERRS )
00504 *
00505  9999 FORMAT( 1X, A, ', UPLO=''', A1, ''', N =', I5, ', type ', I2,
00506      $      ', test ', I2, ', ratio =', G12.5 )
00507  9998 FORMAT( 1X, A, ', FACT=''', A1, ''', UPLO=''', A1, ''', N =', I5,
00508      $      ', type ', I2, ', test ', I2, ', ratio =', G12.5 )
00509       RETURN
00510 *
00511 *     End of CDRVHE
00512 *
00513       END
 All Files Functions