LAPACK 3.3.1
Linear Algebra PACKage

cchkgt.f

Go to the documentation of this file.
00001       SUBROUTINE CCHKGT( DOTYPE, NN, NVAL, NNS, NSVAL, THRESH, TSTERR,
00002      $                   A, AF, B, X, XACT, WORK, RWORK, IWORK, NOUT )
00003 *
00004 *  -- LAPACK test routine (version 3.1.1) --
00005 *     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
00006 *     January 2007
00007 *
00008 *     .. Scalar Arguments ..
00009       LOGICAL            TSTERR
00010       INTEGER            NN, NNS, NOUT
00011       REAL               THRESH
00012 *     ..
00013 *     .. Array Arguments ..
00014       LOGICAL            DOTYPE( * )
00015       INTEGER            IWORK( * ), NSVAL( * ), NVAL( * )
00016       REAL               RWORK( * )
00017       COMPLEX            A( * ), AF( * ), B( * ), WORK( * ), X( * ),
00018      $                   XACT( * )
00019 *     ..
00020 *
00021 *  Purpose
00022 *  =======
00023 *
00024 *  CCHKGT tests CGTTRF, -TRS, -RFS, and -CON
00025 *
00026 *  Arguments
00027 *  =========
00028 *
00029 *  DOTYPE  (input) LOGICAL array, dimension (NTYPES)
00030 *          The matrix types to be used for testing.  Matrices of type j
00031 *          (for 1 <= j <= NTYPES) are used for testing if DOTYPE(j) =
00032 *          .TRUE.; if DOTYPE(j) = .FALSE., then type j is not used.
00033 *
00034 *  NN      (input) INTEGER
00035 *          The number of values of N contained in the vector NVAL.
00036 *
00037 *  NVAL    (input) INTEGER array, dimension (NN)
00038 *          The values of the matrix dimension N.
00039 *
00040 *  NNS     (input) INTEGER
00041 *          The number of values of NRHS contained in the vector NSVAL.
00042 *
00043 *  NSVAL   (input) INTEGER array, dimension (NNS)
00044 *          The values of the number of right hand sides NRHS.
00045 *
00046 *  THRESH  (input) REAL
00047 *          The threshold value for the test ratios.  A result is
00048 *          included in the output file if RESULT >= THRESH.  To have
00049 *          every test ratio printed, use THRESH = 0.
00050 *
00051 *  TSTERR  (input) LOGICAL
00052 *          Flag that indicates whether error exits are to be tested.
00053 *
00054 *  A       (workspace) COMPLEX array, dimension (NMAX*4)
00055 *
00056 *  AF      (workspace) COMPLEX array, dimension (NMAX*4)
00057 *
00058 *  B       (workspace) COMPLEX array, dimension (NMAX*NSMAX)
00059 *          where NSMAX is the largest entry in NSVAL.
00060 *
00061 *  X       (workspace) COMPLEX array, dimension (NMAX*NSMAX)
00062 *
00063 *  XACT    (workspace) COMPLEX array, dimension (NMAX*NSMAX)
00064 *
00065 *  WORK    (workspace) COMPLEX array, dimension
00066 *                      (NMAX*max(3,NSMAX))
00067 *
00068 *  RWORK   (workspace) REAL array, dimension
00069 *                      (max(NMAX)+2*NSMAX)
00070 *
00071 *  IWORK   (workspace) INTEGER array, dimension (NMAX)
00072 *
00073 *  NOUT    (input) INTEGER
00074 *          The unit number for output.
00075 *
00076 *  =====================================================================
00077 *
00078 *     .. Parameters ..
00079       REAL               ONE, ZERO
00080       PARAMETER          ( ONE = 1.0E+0, ZERO = 0.0E+0 )
00081       INTEGER            NTYPES
00082       PARAMETER          ( NTYPES = 12 )
00083       INTEGER            NTESTS
00084       PARAMETER          ( NTESTS = 7 )
00085 *     ..
00086 *     .. Local Scalars ..
00087       LOGICAL            TRFCON, ZEROT
00088       CHARACTER          DIST, NORM, TRANS, TYPE
00089       CHARACTER*3        PATH
00090       INTEGER            I, IMAT, IN, INFO, IRHS, ITRAN, IX, IZERO, J,
00091      $                   K, KL, KOFF, KU, LDA, M, MODE, N, NERRS, NFAIL,
00092      $                   NIMAT, NRHS, NRUN
00093       REAL               AINVNM, ANORM, COND, RCOND, RCONDC, RCONDI,
00094      $                   RCONDO
00095 *     ..
00096 *     .. Local Arrays ..
00097       CHARACTER          TRANSS( 3 )
00098       INTEGER            ISEED( 4 ), ISEEDY( 4 )
00099       REAL               RESULT( NTESTS )
00100       COMPLEX            Z( 3 )
00101 *     ..
00102 *     .. External Functions ..
00103       REAL               CLANGT, SCASUM, SGET06
00104       EXTERNAL           CLANGT, SCASUM, SGET06
00105 *     ..
00106 *     .. External Subroutines ..
00107       EXTERNAL           ALAERH, ALAHD, ALASUM, CCOPY, CERRGE, CGET04,
00108      $                   CGTCON, CGTRFS, CGTT01, CGTT02, CGTT05, CGTTRF,
00109      $                   CGTTRS, CLACPY, CLAGTM, CLARNV, CLATB4, CLATMS,
00110      $                   CSSCAL
00111 *     ..
00112 *     .. Intrinsic Functions ..
00113       INTRINSIC          MAX
00114 *     ..
00115 *     .. Scalars in Common ..
00116       LOGICAL            LERR, OK
00117       CHARACTER*32       SRNAMT
00118       INTEGER            INFOT, NUNIT
00119 *     ..
00120 *     .. Common blocks ..
00121       COMMON             / INFOC / INFOT, NUNIT, OK, LERR
00122       COMMON             / SRNAMC / SRNAMT
00123 *     ..
00124 *     .. Data statements ..
00125       DATA               ISEEDY / 0, 0, 0, 1 / , TRANSS / 'N', 'T',
00126      $                   'C' /
00127 *     ..
00128 *     .. Executable Statements ..
00129 *
00130       PATH( 1: 1 ) = 'Complex precision'
00131       PATH( 2: 3 ) = 'GT'
00132       NRUN = 0
00133       NFAIL = 0
00134       NERRS = 0
00135       DO 10 I = 1, 4
00136          ISEED( I ) = ISEEDY( I )
00137    10 CONTINUE
00138 *
00139 *     Test the error exits
00140 *
00141       IF( TSTERR )
00142      $   CALL CERRGE( PATH, NOUT )
00143       INFOT = 0
00144 *
00145       DO 110 IN = 1, NN
00146 *
00147 *        Do for each value of N in NVAL.
00148 *
00149          N = NVAL( IN )
00150          M = MAX( N-1, 0 )
00151          LDA = MAX( 1, N )
00152          NIMAT = NTYPES
00153          IF( N.LE.0 )
00154      $      NIMAT = 1
00155 *
00156          DO 100 IMAT = 1, NIMAT
00157 *
00158 *           Do the tests only if DOTYPE( IMAT ) is true.
00159 *
00160             IF( .NOT.DOTYPE( IMAT ) )
00161      $         GO TO 100
00162 *
00163 *           Set up parameters with CLATB4.
00164 *
00165             CALL CLATB4( PATH, IMAT, N, N, TYPE, KL, KU, ANORM, MODE,
00166      $                   COND, DIST )
00167 *
00168             ZEROT = IMAT.GE.8 .AND. IMAT.LE.10
00169             IF( IMAT.LE.6 ) THEN
00170 *
00171 *              Types 1-6:  generate matrices of known condition number.
00172 *
00173                KOFF = MAX( 2-KU, 3-MAX( 1, N ) )
00174                SRNAMT = 'CLATMS'
00175                CALL CLATMS( N, N, DIST, ISEED, TYPE, RWORK, MODE, COND,
00176      $                      ANORM, KL, KU, 'Z', AF( KOFF ), 3, WORK,
00177      $                      INFO )
00178 *
00179 *              Check the error code from CLATMS.
00180 *
00181                IF( INFO.NE.0 ) THEN
00182                   CALL ALAERH( PATH, 'CLATMS', INFO, 0, ' ', N, N, KL,
00183      $                         KU, -1, IMAT, NFAIL, NERRS, NOUT )
00184                   GO TO 100
00185                END IF
00186                IZERO = 0
00187 *
00188                IF( N.GT.1 ) THEN
00189                   CALL CCOPY( N-1, AF( 4 ), 3, A, 1 )
00190                   CALL CCOPY( N-1, AF( 3 ), 3, A( N+M+1 ), 1 )
00191                END IF
00192                CALL CCOPY( N, AF( 2 ), 3, A( M+1 ), 1 )
00193             ELSE
00194 *
00195 *              Types 7-12:  generate tridiagonal matrices with
00196 *              unknown condition numbers.
00197 *
00198                IF( .NOT.ZEROT .OR. .NOT.DOTYPE( 7 ) ) THEN
00199 *
00200 *                 Generate a matrix with elements whose real and
00201 *                 imaginary parts are from [-1,1].
00202 *
00203                   CALL CLARNV( 2, ISEED, N+2*M, A )
00204                   IF( ANORM.NE.ONE )
00205      $               CALL CSSCAL( N+2*M, ANORM, A, 1 )
00206                ELSE IF( IZERO.GT.0 ) THEN
00207 *
00208 *                 Reuse the last matrix by copying back the zeroed out
00209 *                 elements.
00210 *
00211                   IF( IZERO.EQ.1 ) THEN
00212                      A( N ) = Z( 2 )
00213                      IF( N.GT.1 )
00214      $                  A( 1 ) = Z( 3 )
00215                   ELSE IF( IZERO.EQ.N ) THEN
00216                      A( 3*N-2 ) = Z( 1 )
00217                      A( 2*N-1 ) = Z( 2 )
00218                   ELSE
00219                      A( 2*N-2+IZERO ) = Z( 1 )
00220                      A( N-1+IZERO ) = Z( 2 )
00221                      A( IZERO ) = Z( 3 )
00222                   END IF
00223                END IF
00224 *
00225 *              If IMAT > 7, set one column of the matrix to 0.
00226 *
00227                IF( .NOT.ZEROT ) THEN
00228                   IZERO = 0
00229                ELSE IF( IMAT.EQ.8 ) THEN
00230                   IZERO = 1
00231                   Z( 2 ) = A( N )
00232                   A( N ) = ZERO
00233                   IF( N.GT.1 ) THEN
00234                      Z( 3 ) = A( 1 )
00235                      A( 1 ) = ZERO
00236                   END IF
00237                ELSE IF( IMAT.EQ.9 ) THEN
00238                   IZERO = N
00239                   Z( 1 ) = A( 3*N-2 )
00240                   Z( 2 ) = A( 2*N-1 )
00241                   A( 3*N-2 ) = ZERO
00242                   A( 2*N-1 ) = ZERO
00243                ELSE
00244                   IZERO = ( N+1 ) / 2
00245                   DO 20 I = IZERO, N - 1
00246                      A( 2*N-2+I ) = ZERO
00247                      A( N-1+I ) = ZERO
00248                      A( I ) = ZERO
00249    20             CONTINUE
00250                   A( 3*N-2 ) = ZERO
00251                   A( 2*N-1 ) = ZERO
00252                END IF
00253             END IF
00254 *
00255 *+    TEST 1
00256 *           Factor A as L*U and compute the ratio
00257 *              norm(L*U - A) / (n * norm(A) * EPS )
00258 *
00259             CALL CCOPY( N+2*M, A, 1, AF, 1 )
00260             SRNAMT = 'CGTTRF'
00261             CALL CGTTRF( N, AF, AF( M+1 ), AF( N+M+1 ), AF( N+2*M+1 ),
00262      $                   IWORK, INFO )
00263 *
00264 *           Check error code from CGTTRF.
00265 *
00266             IF( INFO.NE.IZERO )
00267      $         CALL ALAERH( PATH, 'CGTTRF', INFO, IZERO, ' ', N, N, 1,
00268      $                      1, -1, IMAT, NFAIL, NERRS, NOUT )
00269             TRFCON = INFO.NE.0
00270 *
00271             CALL CGTT01( N, A, A( M+1 ), A( N+M+1 ), AF, AF( M+1 ),
00272      $                   AF( N+M+1 ), AF( N+2*M+1 ), IWORK, WORK, LDA,
00273      $                   RWORK, RESULT( 1 ) )
00274 *
00275 *           Print the test ratio if it is .GE. THRESH.
00276 *
00277             IF( RESULT( 1 ).GE.THRESH ) THEN
00278                IF( NFAIL.EQ.0 .AND. NERRS.EQ.0 )
00279      $            CALL ALAHD( NOUT, PATH )
00280                WRITE( NOUT, FMT = 9999 )N, IMAT, 1, RESULT( 1 )
00281                NFAIL = NFAIL + 1
00282             END IF
00283             NRUN = NRUN + 1
00284 *
00285             DO 50 ITRAN = 1, 2
00286                TRANS = TRANSS( ITRAN )
00287                IF( ITRAN.EQ.1 ) THEN
00288                   NORM = 'O'
00289                ELSE
00290                   NORM = 'I'
00291                END IF
00292                ANORM = CLANGT( NORM, N, A, A( M+1 ), A( N+M+1 ) )
00293 *
00294                IF( .NOT.TRFCON ) THEN
00295 *
00296 *                 Use CGTTRS to solve for one column at a time of
00297 *                 inv(A), computing the maximum column sum as we go.
00298 *
00299                   AINVNM = ZERO
00300                   DO 40 I = 1, N
00301                      DO 30 J = 1, N
00302                         X( J ) = ZERO
00303    30                CONTINUE
00304                      X( I ) = ONE
00305                      CALL CGTTRS( TRANS, N, 1, AF, AF( M+1 ),
00306      $                            AF( N+M+1 ), AF( N+2*M+1 ), IWORK, X,
00307      $                            LDA, INFO )
00308                      AINVNM = MAX( AINVNM, SCASUM( N, X, 1 ) )
00309    40             CONTINUE
00310 *
00311 *                 Compute RCONDC = 1 / (norm(A) * norm(inv(A))
00312 *
00313                   IF( ANORM.LE.ZERO .OR. AINVNM.LE.ZERO ) THEN
00314                      RCONDC = ONE
00315                   ELSE
00316                      RCONDC = ( ONE / ANORM ) / AINVNM
00317                   END IF
00318                   IF( ITRAN.EQ.1 ) THEN
00319                      RCONDO = RCONDC
00320                   ELSE
00321                      RCONDI = RCONDC
00322                   END IF
00323                ELSE
00324                   RCONDC = ZERO
00325                END IF
00326 *
00327 *+    TEST 7
00328 *              Estimate the reciprocal of the condition number of the
00329 *              matrix.
00330 *
00331                SRNAMT = 'CGTCON'
00332                CALL CGTCON( NORM, N, AF, AF( M+1 ), AF( N+M+1 ),
00333      $                      AF( N+2*M+1 ), IWORK, ANORM, RCOND, WORK,
00334      $                      INFO )
00335 *
00336 *              Check error code from CGTCON.
00337 *
00338                IF( INFO.NE.0 )
00339      $            CALL ALAERH( PATH, 'CGTCON', INFO, 0, NORM, N, N, -1,
00340      $                         -1, -1, IMAT, NFAIL, NERRS, NOUT )
00341 *
00342                RESULT( 7 ) = SGET06( RCOND, RCONDC )
00343 *
00344 *              Print the test ratio if it is .GE. THRESH.
00345 *
00346                IF( RESULT( 7 ).GE.THRESH ) THEN
00347                   IF( NFAIL.EQ.0 .AND. NERRS.EQ.0 )
00348      $               CALL ALAHD( NOUT, PATH )
00349                   WRITE( NOUT, FMT = 9997 )NORM, N, IMAT, 7,
00350      $               RESULT( 7 )
00351                   NFAIL = NFAIL + 1
00352                END IF
00353                NRUN = NRUN + 1
00354    50       CONTINUE
00355 *
00356 *           Skip the remaining tests if the matrix is singular.
00357 *
00358             IF( TRFCON )
00359      $         GO TO 100
00360 *
00361             DO 90 IRHS = 1, NNS
00362                NRHS = NSVAL( IRHS )
00363 *
00364 *              Generate NRHS random solution vectors.
00365 *
00366                IX = 1
00367                DO 60 J = 1, NRHS
00368                   CALL CLARNV( 2, ISEED, N, XACT( IX ) )
00369                   IX = IX + LDA
00370    60          CONTINUE
00371 *
00372                DO 80 ITRAN = 1, 3
00373                   TRANS = TRANSS( ITRAN )
00374                   IF( ITRAN.EQ.1 ) THEN
00375                      RCONDC = RCONDO
00376                   ELSE
00377                      RCONDC = RCONDI
00378                   END IF
00379 *
00380 *                 Set the right hand side.
00381 *
00382                   CALL CLAGTM( TRANS, N, NRHS, ONE, A,
00383      $                         A( M+1 ), A( N+M+1 ), XACT, LDA,
00384      $                         ZERO, B, LDA )
00385 *
00386 *+    TEST 2
00387 *              Solve op(A) * X = B and compute the residual.
00388 *
00389                   CALL CLACPY( 'Full', N, NRHS, B, LDA, X, LDA )
00390                   SRNAMT = 'CGTTRS'
00391                   CALL CGTTRS( TRANS, N, NRHS, AF, AF( M+1 ),
00392      $                         AF( N+M+1 ), AF( N+2*M+1 ), IWORK, X,
00393      $                         LDA, INFO )
00394 *
00395 *              Check error code from CGTTRS.
00396 *
00397                   IF( INFO.NE.0 )
00398      $               CALL ALAERH( PATH, 'CGTTRS', INFO, 0, TRANS, N, N,
00399      $                            -1, -1, NRHS, IMAT, NFAIL, NERRS,
00400      $                            NOUT )
00401 *
00402                   CALL CLACPY( 'Full', N, NRHS, B, LDA, WORK, LDA )
00403                   CALL CGTT02( TRANS, N, NRHS, A, A( M+1 ), A( N+M+1 ),
00404      $                         X, LDA, WORK, LDA, RWORK, RESULT( 2 ) )
00405 *
00406 *+    TEST 3
00407 *              Check solution from generated exact solution.
00408 *
00409                   CALL CGET04( N, NRHS, X, LDA, XACT, LDA, RCONDC,
00410      $                         RESULT( 3 ) )
00411 *
00412 *+    TESTS 4, 5, and 6
00413 *              Use iterative refinement to improve the solution.
00414 *
00415                   SRNAMT = 'CGTRFS'
00416                   CALL CGTRFS( TRANS, N, NRHS, A, A( M+1 ), A( N+M+1 ),
00417      $                         AF, AF( M+1 ), AF( N+M+1 ),
00418      $                         AF( N+2*M+1 ), IWORK, B, LDA, X, LDA,
00419      $                         RWORK, RWORK( NRHS+1 ), WORK,
00420      $                         RWORK( 2*NRHS+1 ), INFO )
00421 *
00422 *              Check error code from CGTRFS.
00423 *
00424                   IF( INFO.NE.0 )
00425      $               CALL ALAERH( PATH, 'CGTRFS', INFO, 0, TRANS, N, N,
00426      $                            -1, -1, NRHS, IMAT, NFAIL, NERRS,
00427      $                            NOUT )
00428 *
00429                   CALL CGET04( N, NRHS, X, LDA, XACT, LDA, RCONDC,
00430      $                         RESULT( 4 ) )
00431                   CALL CGTT05( TRANS, N, NRHS, A, A( M+1 ), A( N+M+1 ),
00432      $                         B, LDA, X, LDA, XACT, LDA, RWORK,
00433      $                         RWORK( NRHS+1 ), RESULT( 5 ) )
00434 *
00435 *              Print information about the tests that did not pass the
00436 *              threshold.
00437 *
00438                   DO 70 K = 2, 6
00439                      IF( RESULT( K ).GE.THRESH ) THEN
00440                         IF( NFAIL.EQ.0 .AND. NERRS.EQ.0 )
00441      $                     CALL ALAHD( NOUT, PATH )
00442                         WRITE( NOUT, FMT = 9998 )TRANS, N, NRHS, IMAT,
00443      $                     K, RESULT( K )
00444                         NFAIL = NFAIL + 1
00445                      END IF
00446    70             CONTINUE
00447                   NRUN = NRUN + 5
00448    80          CONTINUE
00449    90       CONTINUE
00450   100    CONTINUE
00451   110 CONTINUE
00452 *
00453 *     Print a summary of the results.
00454 *
00455       CALL ALASUM( PATH, NOUT, NFAIL, NRUN, NERRS )
00456 *
00457  9999 FORMAT( 12X, 'N =', I5, ',', 10X, ' type ', I2, ', test(', I2,
00458      $      ') = ', G12.5 )
00459  9998 FORMAT( ' TRANS=''', A1, ''', N =', I5, ', NRHS=', I3, ', type ',
00460      $      I2, ', test(', I2, ') = ', G12.5 )
00461  9997 FORMAT( ' NORM =''', A1, ''', N =', I5, ',', 10X, ' type ', I2,
00462      $      ', test(', I2, ') = ', G12.5 )
00463       RETURN
00464 *
00465 *     End of CCHKGT
00466 *
00467       END
 All Files Functions