1
       2
       3
       4
       5
       6
       7
       8
       9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      20
      21
      22
      23
      24
      25
      26
      27
      28
      29
      30
      31
      32
      33
      34
      35
      36
      37
      38
      39
      40
      41
      42
      43
      44
      45
      46
      47
      48
      49
      50
      51
      52
      53
      54
      55
      56
      57
      58
      59
      60
      61
      62
      63
      64
      65
      66
      67
      68
      69
      70
      71
      72
      73
      74
      75
      76
      77
      78
      79
      80
      81
      82
      83
      84
      85
      86
      87
      88
      89
      90
      91
      92
      93
      94
      95
      96
      97
      98
      99
     100
     101
     102
     103
     104
     105
     106
     107
     108
     109
     110
     111
     112
     113
     114
     115
     116
     117
     118
     119
     120
     121
     122
     123
     124
     125
     126
     127
     128
     129
     130
     131
     132
     133
     134
     135
     136
     137
     138
     139
     140
     141
     142
     143
     144
     145
     146
     147
     148
     149
     150
     151
     152
     153
     154
     155
     156
     157
     158
     159
     160
     161
     162
     163
     164
     165
     166
     167
     168
     169
     170
     171
     172
     173
     174
     175
     176
     177
     178
     179
     180
     181
     182
     183
     184
     185
     186
     187
     188
     189
     190
     191
     192
     193
     194
     195
     196
     197
     198
     199
     200
     201
     202
     203
     204
     205
     206
     207
     208
     209
     210
     211
     212
     213
     214
     215
     216
     217
     218
     219
     220
     221
     222
     223
     224
     225
     226
     227
     228
     229
     230
     231
     232
     233
     234
     235
     236
     237
     238
     239
     240
     241
     242
     243
     244
     245
     246
     247
     248
     249
     250
     251
     252
     253
     254
     255
     256
     257
     258
     259
     260
     261
     262
     263
     264
     265
     266
     267
     268
     269
     270
     271
     272
     273
     274
     275
     276
     277
     278
     279
     280
     281
     282
     283
     284
     285
     286
     287
     288
     289
     290
     291
     292
     293
     294
     295
     296
     297
     298
     299
     300
     301
     302
     303
     304
     305
     306
     307
     308
     309
     310
     311
     312
     313
     314
     315
     316
     317
     318
     319
     320
     321
     322
     323
     324
     325
     326
     327
     328
     329
     330
     331
     332
     333
     334
     335
     336
     337
     338
     339
     340
     341
     342
     343
     344
     345
     346
     347
     348
     349
     350
     351
     352
     353
     354
     355
     356
     357
     358
     359
     360
     361
     362
     363
     364
     365
     366
     367
     368
     369
     370
     371
     372
     373
     374
     375
     376
     377
     378
     379
     380
     381
     382
     383
     384
     385
     386
     387
     388
     389
     390
     391
     392
     393
     394
     395
     396
     397
     398
     399
     400
     401
     402
     403
     404
     405
     406
     407
     408
     409
     410
     411
     412
     413
     414
     415
     416
     417
     418
     419
     420
     421
     422
     423
     424
     425
     426
     427
     428
     429
     430
     431
     432
     433
     434
     435
     436
     437
     438
     439
     440
     441
     442
     443
     444
     445
     446
      SUBROUTINE DDRVRFPNOUTNNNVALNNSNSVALNNTNTVAL,
     +              THRESHAASAVAFACAINVB,
     +              BSAVXACTXARFARFINV,
     +              D_WORK_DLATMSD_WORK_DPOT01D_TEMP_DPOT02,
     +              D_TEMP_DPOT03D_WORK_DLANSY,
     +              D_WORK_DPOT02D_WORK_DPOT03 )
*
*  -- LAPACK test routine (version 3.2.0) --
*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
*     November 2008
*
*     .. Scalar Arguments ..
      INTEGER            NNNNSNNTNOUT
      DOUBLE PRECISION   THRESH
*     ..
*     .. Array Arguments ..
      INTEGER            NVALNN ), NSVALNNS ), NTVALNNT )
      DOUBLE PRECISION   A* )
      DOUBLE PRECISION   AINV* )
      DOUBLE PRECISION   ASAV* )
      DOUBLE PRECISION   B* )
      DOUBLE PRECISION   BSAV* )
      DOUBLE PRECISION   AFAC* )
      DOUBLE PRECISION   ARF* )
      DOUBLE PRECISION   ARFINV* )
      DOUBLE PRECISION   XACT* )
      DOUBLE PRECISION   X* )
      DOUBLE PRECISION   D_WORK_DLATMS* )
      DOUBLE PRECISION   D_WORK_DPOT01* )
      DOUBLE PRECISION   D_TEMP_DPOT02* )
      DOUBLE PRECISION   D_TEMP_DPOT03* )
      DOUBLE PRECISION   D_WORK_DLANSY* )
      DOUBLE PRECISION   D_WORK_DPOT02* )
      DOUBLE PRECISION   D_WORK_DPOT03* )
*     ..
*
*  Purpose
*  =======
*
*  DDRVRFP tests the LAPACK RFP routines:
*      DPFTRF, DPFTRS, and DPFTRI.
*
*  This testing routine follow the same tests as DDRVPO (test for the full
*  format Symmetric Positive Definite solver).
*
*  The tests are performed in Full Format, convertion back and forth from
*  full format to RFP format are performed using the routines DTRTTF and
*  DTFTTR.
*
*  First, a specific matrix A of size N is created. There is nine types of 
*  different matrixes possible.
*   1. Diagonal                        6. Random, CNDNUM = sqrt(0.1/EPS)
*   2. Random, CNDNUM = 2              7. Random, CNDNUM = 0.1/EPS
*  *3. First row and column zero       8. Scaled near underflow
*  *4. Last row and column zero        9. Scaled near overflow
*  *5. Middle row and column zero
*  (* - tests error exits from DPFTRF, no test ratios are computed)
*  A solution XACT of size N-by-NRHS is created and the associated right
*  hand side B as well. Then DPFTRF is called to compute L (or U), the
*  Cholesky factor of A. Then L (or U) is used to solve the linear system
*  of equations AX = B. This gives X. Then L (or U) is used to compute the
*  inverse of A, AINV. The following four tests are then performed:
*  (1) norm( L*L' - A ) / ( N * norm(A) * EPS ) or
*      norm( U'*U - A ) / ( N * norm(A) * EPS ),
*  (2) norm(B - A*X) / ( norm(A) * norm(X) * EPS ),
*  (3) norm( I - A*AINV ) / ( N * norm(A) * norm(AINV) * EPS ),
*  (4) ( norm(X-XACT) * RCOND ) / ( norm(XACT) * EPS ),
*  where EPS is the machine precision, RCOND the condition number of A, and
*  norm( . ) the 1-norm for (1,2,3) and the inf-norm for (4).
*  Errors occur when INFO parameter is not as expected. Failures occur when
*  a test ratios is greater than THRES.
*
*  Arguments
*  =========
*
*  NOUT          (input) INTEGER
*                The unit number for output.
*
*  NN            (input) INTEGER
*                The number of values of N contained in the vector NVAL.
*
*  NVAL          (input) INTEGER array, dimension (NN)
*                The values of the matrix dimension N.
*
*  NNS           (input) INTEGER
*                The number of values of NRHS contained in the vector NSVAL.
*
*  NSVAL         (input) INTEGER array, dimension (NNS)
*                The values of the number of right-hand sides NRHS.
*
*  NNT           (input) INTEGER
*                The number of values of MATRIX TYPE contained in the vector NTVAL.
*
*  NTVAL         (input) INTEGER array, dimension (NNT)
*                The values of matrix type (between 0 and 9 for PO/PP/PF matrices).
*
*  THRESH        (input) DOUBLE PRECISION
*                The threshold value for the test ratios.  A result is
*                included in the output file if RESULT >= THRESH.  To have
*                every test ratio printed, use THRESH = 0.
*
*  A             (workspace) DOUBLE PRECISION array, dimension (NMAX*NMAX)
*
*  ASAV          (workspace) DOUBLE PRECISION array, dimension (NMAX*NMAX)
*
*  AFAC          (workspace) DOUBLE PRECISION array, dimension (NMAX*NMAX)
*
*  AINV          (workspace) DOUBLE PRECISION array, dimension (NMAX*NMAX)
*
*  B             (workspace) DOUBLE PRECISION array, dimension (NMAX*MAXRHS)
*
*  BSAV          (workspace) DOUBLE PRECISION array, dimension (NMAX*MAXRHS)
*
*  XACT          (workspace) DOUBLE PRECISION array, dimension (NMAX*MAXRHS)
*
*  X             (workspace) DOUBLE PRECISION array, dimension (NMAX*MAXRHS)
*
*  ARF           (workspace) DOUBLE PRECISION array, dimension ((NMAX*(NMAX+1))/2)
*
*  ARFINV        (workspace) DOUBLE PRECISION array, dimension ((NMAX*(NMAX+1))/2)
*
*  D_WORK_DLATMS (workspace) DOUBLE PRECISION array, dimension ( 3*NMAX )
*
*  D_WORK_DPOT01 (workspace) DOUBLE PRECISION array, dimension ( NMAX )
*
*  D_TEMP_DPOT02 (workspace) DOUBLE PRECISION array, dimension ( NMAX*MAXRHS )
*
*  D_TEMP_DPOT03 (workspace) DOUBLE PRECISION array, dimension ( NMAX*NMAX )
*
*  D_WORK_DLATMS (workspace) DOUBLE PRECISION array, dimension ( NMAX )
*
*  D_WORK_DLANSY (workspace) DOUBLE PRECISION array, dimension ( NMAX )
*
*  D_WORK_DPOT02 (workspace) DOUBLE PRECISION array, dimension ( NMAX )
*
*  D_WORK_DPOT03 (workspace) DOUBLE PRECISION array, dimension ( NMAX )
*
*  =====================================================================
*
*     .. Parameters ..
      DOUBLE PRECISION   ONEZERO
      PARAMETER          ( ONE = 1.0D+0ZERO = 0.0D+0 )
      INTEGER            NTESTS
      PARAMETER          ( NTESTS = 4 )
*     ..
*     .. Local Scalars ..
      LOGICAL            ZEROT
      INTEGER            IINFOIUPLOLDALDBIMATNERRSNFAIL,
     +                   NRHSNRUNIZEROIOFFKNTNIFORMIIN,
     +                   IITIIS
      CHARACTER          DISTCTYPEUPLOCFORM
      INTEGER            KLKUMODE
      DOUBLE PRECISION   ANORMAINVNMCNDNUMRCONDC
*     ..
*     .. Local Arrays ..
      CHARACTER          UPLOS2 ), FORMS2 )
      INTEGER            ISEED4 ), ISEEDY4 )
      DOUBLE PRECISION   RESULTNTESTS )
*     ..
*     .. External Functions ..
      DOUBLE PRECISION   DLANSY
      EXTERNAL           DLANSY
*     ..
*     .. External Subroutines ..
      EXTERNAL           ALADHDALAERHALASVMDGET04DTFTTRDLACPY,
     +                   DLARHSDLATB4DLATMSDPFTRIDPFTRFDPFTRS,
     +                   DPOT01DPOT02DPOT03DPOTRIDPOTRFDTRTTF
*     ..
*     .. Scalars in Common ..
      CHARACTER*32       SRNAMT
*     ..
*     .. Common blocks ..
      COMMON             / SRNAMC / SRNAMT
*     ..
*     .. Data statements ..
      DATA               ISEEDY / 1988198919901991 /
      DATA               UPLOS / 'U''L' /
      DATA               FORMS / 'N''T' /
*     ..
*     .. Executable Statements ..
*
*     Initialize constants and the random number seed.
*
      NRUN = 0
      NFAIL = 0
      NERRS = 0
      DO 10 I = 14
         ISEEDI ) = ISEEDYI )
   10 CONTINUE
*
      DO 130 IIN = 1NN
*
         N = NVALIIN )
         LDA = MAX( N1 )
         LDB = MAX( N1 )
*
         DO 980 IIS = 1NNS
*
            NRHS = NSVALIIS )
*
            DO 120 IIT = 1NNT
*
               IMAT = NTVALIIT )
*
*              If N.EQ.0, only consider the first type
*
               IFN.EQ.0 .AND. IIT.GT.1 ) GO TO 120
*
*              Skip types 3, 4, or 5 if the matrix size is too small.
*
               IFIMAT.EQ.4 .AND. N.LE.1 ) GO TO 120
               IFIMAT.EQ.5 .AND. N.LE.2 ) GO TO 120
*
*              Do first for UPLO = 'U', then for UPLO = 'L'
*
               DO 110 IUPLO = 12
                  UPLO = UPLOSIUPLO )
*
*                 Do first for CFORM = 'N', then for CFORM = 'C'
*
                  DO 100 IFORM = 12
                     CFORM = FORMSIFORM )
*
*                    Set up parameters with DLATB4 and generate a test
*                    matrix with DLATMS.
*
                     CALL DLATB4'DPO'IMATNNCTYPEKLKU,
     +                            ANORMMODECNDNUMDIST )
*
                     SRNAMT = 'DLATMS'
                     CALL DLATMSNNDISTISEEDCTYPE,
     +                            D_WORK_DLATMS,
     +                            MODECNDNUMANORMKLKUUPLOA,
     +                            LDAD_WORK_DLATMSINFO )
*
*                    Check error code from DLATMS.
*
                     IFINFO.NE.0 ) THEN
                        CALL ALAERH'DPF''DLATMS'INFO0UPLON,
     +                               N-1-1-1IITNFAILNERRS,
     +                               NOUT )
                        GO TO 100
                     END IF
*
*                    For types 3-5, zero one row and column of the matrix to
*                    test that INFO is returned correctly.
*
                     ZEROT = IMAT.GE.3 .AND. IMAT.LE.5
                     IFZEROT ) THEN
                        IFIIT.EQ.3 ) THEN
                           IZERO = 1
                        ELSE IFIIT.EQ.4 ) THEN
                           IZERO = N
                        ELSE
                           IZERO = N / 2 + 1
                        END IF
                        IOFF = ( IZERO-1 )*LDA
*
*                       Set row and column IZERO of A to 0.
*
                        IFIUPLO.EQ.1 ) THEN
                           DO 20 I = 1IZERO - 1
                              AIOFF+I ) = ZERO
   20                      CONTINUE
                           IOFF = IOFF + IZERO
                           DO 30 I = IZERON
                              AIOFF ) = ZERO
                              IOFF = IOFF + LDA
   30                      CONTINUE
                        ELSE
                           IOFF = IZERO
                           DO 40 I = 1IZERO - 1
                              AIOFF ) = ZERO
                              IOFF = IOFF + LDA
   40                      CONTINUE
                           IOFF = IOFF - IZERO
                           DO 50 I = IZERON
                              AIOFF+I ) = ZERO
   50                      CONTINUE
                        END IF
                     ELSE
                        IZERO = 0
                     END IF
*
*                    Save a copy of the matrix A in ASAV.
*
                     CALL DLACPYUPLONNALDAASAVLDA )
*
*                    Compute the condition number of A (RCONDC).
*
                     IFZEROT ) THEN
                        RCONDC = ZERO
                     ELSE
*
*                       Compute the 1-norm of A.
*
                        ANORM = DLANSY'1'UPLONALDA,
     +                         D_WORK_DLANSY )
*
*                       Factor the matrix A.
*
                        CALL DPOTRFUPLONALDAINFO )
*
*                       Form the inverse of A.
*
                        CALL DPOTRIUPLONALDAINFO )
*
*                       Compute the 1-norm condition number of A.
*
                        AINVNM = DLANSY'1'UPLONALDA,
     +                           D_WORK_DLANSY )
                        RCONDC = ( ONE / ANORM ) / AINVNM
*
*                       Restore the matrix A.
*
                        CALL DLACPYUPLONNASAVLDAALDA )
*
                     END IF
*
*                    Form an exact solution and set the right hand side.
*
                     SRNAMT = 'DLARHS'
                     CALL DLARHS'DPO''N'UPLO' 'NNKLKU,
     +                            NRHSALDAXACTLDABLDA,
     +                            ISEEDINFO )
                     CALL DLACPY'Full'NNRHSBLDABSAVLDA )
*
*                    Compute the L*L' or U'*U factorization of the
*                    matrix and solve the system.
*
                     CALL DLACPYUPLONNALDAAFACLDA )
                     CALL DLACPY'Full'NNRHSBLDBXLDB )
*
                     SRNAMT = 'DTRTTF'
                     CALL DTRTTFCFORMUPLONAFACLDAARFINFO )
                     SRNAMT = 'DPFTRF'
                     CALL DPFTRFCFORMUPLONARFINFO )
*
*                    Check error code from DPFTRF.
*
                     IFINFO.NE.IZERO ) THEN
*
*                       LANGOU: there is a small hick here: IZERO should
*                       always be INFO however if INFO is ZERO, ALAERH does not
*                       complain.
*
                         CALL ALAERH'DPF''DPFSV 'INFOIZERO,
     +                                UPLONN-1-1NRHSIIT,
     +                                NFAILNERRSNOUT )
                         GO TO 100
                      END IF
*
*                    Skip the tests if INFO is not 0.
*
                     IFINFO.NE.0 ) THEN
                        GO TO 100
                     END IF
*
                     SRNAMT = 'DPFTRS'
                     CALL DPFTRSCFORMUPLONNRHSARFXLDB,
     +                            INFO )
*
                     SRNAMT = 'DTFTTR'
                     CALL DTFTTRCFORMUPLONARFAFACLDAINFO )
*
*                    Reconstruct matrix from factors and compute
*                    residual.
*
                     CALL DLACPYUPLONNAFACLDAASAVLDA )
                     CALL DPOT01UPLONALDAAFACLDA,
     +                             D_WORK_DPOT01RESULT1 ) )
                     CALL DLACPYUPLONNASAVLDAAFACLDA )
*
*                    Form the inverse and compute the residual.
*
                     IF(MOD(N,2).EQ.0)THEN 
                        CALL DLACPY'A'N+1N/2ARFN+1ARFINV,
     +                               N+1 )
                     ELSE
                        CALL DLACPY'A'N, (N+1)/2ARFNARFINV,
     +                               N )
                     END IF
*
                     SRNAMT = 'DPFTRI'
                     CALL DPFTRICFORMUPLONARFINV , INFO )
*
                     SRNAMT = 'DTFTTR'
                     CALL DTFTTRCFORMUPLONARFINVAINVLDA,
     +                            INFO )
*
*                    Check error code from DPFTRI.
*
                     IFINFO.NE.0 )
     +                  CALL ALAERH'DPO''DPFTRI'INFO0UPLON,
     +                               N-1-1-1IMATNFAILNERRS,
     +                               NOUT )
*
                     CALL DPOT03UPLONALDAAINVLDA,
     +                            D_TEMP_DPOT03LDAD_WORK_DPOT03,
     +                            RCONDCRESULT2 ) )
*
*                    Compute residual of the computed solution.
*
                     CALL DLACPY'Full'NNRHSBLDA,
     +                            D_TEMP_DPOT02LDA )
                     CALL DPOT02UPLONNRHSALDAXLDA,
     +                            D_TEMP_DPOT02LDAD_WORK_DPOT02,
     +                            RESULT3 ) )
*
*                    Check solution from generated exact solution.
 
                     CALL DGET04NNRHSXLDAXACTLDARCONDC,
     +                         RESULT4 ) )
                     NT = 4
*
*                    Print information about the tests that did not
*                    pass the threshold.
*
                     DO 60 K = 1NT
                        IFRESULTK ).GE.THRESH ) THEN
                           IFNFAIL.EQ.0 .AND. NERRS.EQ.0 )
     +                        CALL ALADHDNOUT'DPF' )
                           WRITENOUT, FMT = 9999 )'DPFSV ', UPLO,
     +                            N, IIT, K, RESULT( K )
                           NFAIL = NFAIL + 1
                        END IF
   60                CONTINUE
                     NRUN = NRUN + NT
  100             CONTINUE
  110          CONTINUE
  120       CONTINUE
  980    CONTINUE
  130 CONTINUE
*
*     Print a summary of the results.
*
      CALL ALASVM'DPF'NOUTNFAILNRUNNERRS )
*
 9999 FORMAT( 1X, A6, ', UPLO=''', A1, ''', N =', I5, ', type ', I1,
     +      ', test(', I1, ')=', G12.5 )
*
      RETURN
*
*     End of DDRVRFP
*
      END