LAPACK 3.3.0

ddrvsp.f

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