1*> \brief \b ZCHKPP
2*
3*  =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6*            http://www.netlib.org/lapack/explore-html/
7*
8*  Definition:
9*  ===========
10*
11*       SUBROUTINE ZCHKPP( DOTYPE, NN, NVAL, NNS, NSVAL, THRESH, TSTERR,
12*                          NMAX, A, AFAC, AINV, B, X, XACT, WORK, RWORK,
13*                          NOUT )
14*
15*       .. Scalar Arguments ..
16*       LOGICAL            TSTERR
17*       INTEGER            NMAX, NN, NNS, NOUT
18*       DOUBLE PRECISION   THRESH
19*       ..
20*       .. Array Arguments ..
21*       LOGICAL            DOTYPE( * )
22*       INTEGER            NSVAL( * ), NVAL( * )
23*       DOUBLE PRECISION   RWORK( * )
24*       COMPLEX*16         A( * ), AFAC( * ), AINV( * ), B( * ),
25*      $                   WORK( * ), X( * ), XACT( * )
26*       ..
27*
28*
29*> \par Purpose:
30*  =============
31*>
32*> \verbatim
33*>
34*> ZCHKPP tests ZPPTRF, -TRI, -TRS, -RFS, and -CON
35*> \endverbatim
36*
37*  Arguments:
38*  ==========
39*
40*> \param[in] DOTYPE
41*> \verbatim
42*>          DOTYPE is LOGICAL array, dimension (NTYPES)
43*>          The matrix types to be used for testing.  Matrices of type j
44*>          (for 1 <= j <= NTYPES) are used for testing if DOTYPE(j) =
45*>          .TRUE.; if DOTYPE(j) = .FALSE., then type j is not used.
46*> \endverbatim
47*>
48*> \param[in] NN
49*> \verbatim
50*>          NN is INTEGER
51*>          The number of values of N contained in the vector NVAL.
52*> \endverbatim
53*>
54*> \param[in] NVAL
55*> \verbatim
56*>          NVAL is INTEGER array, dimension (NN)
57*>          The values of the matrix dimension N.
58*> \endverbatim
59*>
60*> \param[in] NNS
61*> \verbatim
62*>          NNS is INTEGER
63*>          The number of values of NRHS contained in the vector NSVAL.
64*> \endverbatim
65*>
66*> \param[in] NSVAL
67*> \verbatim
68*>          NSVAL is INTEGER array, dimension (NNS)
69*>          The values of the number of right hand sides NRHS.
70*> \endverbatim
71*>
72*> \param[in] THRESH
73*> \verbatim
74*>          THRESH is DOUBLE PRECISION
75*>          The threshold value for the test ratios.  A result is
76*>          included in the output file if RESULT >= THRESH.  To have
77*>          every test ratio printed, use THRESH = 0.
78*> \endverbatim
79*>
80*> \param[in] TSTERR
81*> \verbatim
82*>          TSTERR is LOGICAL
83*>          Flag that indicates whether error exits are to be tested.
84*> \endverbatim
85*>
86*> \param[in] NMAX
87*> \verbatim
88*>          NMAX is INTEGER
89*>          The maximum value permitted for N, used in dimensioning the
90*>          work arrays.
91*> \endverbatim
92*>
93*> \param[out] A
94*> \verbatim
95*>          A is COMPLEX*16 array, dimension
96*>                      (NMAX*(NMAX+1)/2)
97*> \endverbatim
98*>
99*> \param[out] AFAC
100*> \verbatim
101*>          AFAC is COMPLEX*16 array, dimension
102*>                      (NMAX*(NMAX+1)/2)
103*> \endverbatim
104*>
105*> \param[out] AINV
106*> \verbatim
107*>          AINV is COMPLEX*16 array, dimension
108*>                      (NMAX*(NMAX+1)/2)
109*> \endverbatim
110*>
111*> \param[out] B
112*> \verbatim
113*>          B is COMPLEX*16 array, dimension (NMAX*NSMAX)
114*>          where NSMAX is the largest entry in NSVAL.
115*> \endverbatim
116*>
117*> \param[out] X
118*> \verbatim
119*>          X is COMPLEX*16 array, dimension (NMAX*NSMAX)
120*> \endverbatim
121*>
122*> \param[out] XACT
123*> \verbatim
124*>          XACT is COMPLEX*16 array, dimension (NMAX*NSMAX)
125*> \endverbatim
126*>
127*> \param[out] WORK
128*> \verbatim
129*>          WORK is COMPLEX*16 array, dimension
130*>                      (NMAX*max(3,NSMAX))
131*> \endverbatim
132*>
133*> \param[out] RWORK
134*> \verbatim
135*>          RWORK is DOUBLE PRECISION array, dimension
136*>                      (max(NMAX,2*NSMAX))
137*> \endverbatim
138*>
139*> \param[in] NOUT
140*> \verbatim
141*>          NOUT is INTEGER
142*>          The unit number for output.
143*> \endverbatim
144*
145*  Authors:
146*  ========
147*
148*> \author Univ. of Tennessee
149*> \author Univ. of California Berkeley
150*> \author Univ. of Colorado Denver
151*> \author NAG Ltd.
152*
153*> \ingroup complex16_lin
154*
155*  =====================================================================
156      SUBROUTINE ZCHKPP( DOTYPE, NN, NVAL, NNS, NSVAL, THRESH, TSTERR,
157     $                   NMAX, A, AFAC, AINV, B, X, XACT, WORK, RWORK,
158     $                   NOUT )
159*
160*  -- LAPACK test routine --
161*  -- LAPACK is a software package provided by Univ. of Tennessee,    --
162*  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
163*
164*     .. Scalar Arguments ..
165      LOGICAL            TSTERR
166      INTEGER            NMAX, NN, NNS, NOUT
167      DOUBLE PRECISION   THRESH
168*     ..
169*     .. Array Arguments ..
170      LOGICAL            DOTYPE( * )
171      INTEGER            NSVAL( * ), NVAL( * )
172      DOUBLE PRECISION   RWORK( * )
173      COMPLEX*16         A( * ), AFAC( * ), AINV( * ), B( * ),
174     $                   WORK( * ), X( * ), XACT( * )
175*     ..
176*
177*  =====================================================================
178*
179*     .. Parameters ..
180      DOUBLE PRECISION   ZERO
181      PARAMETER          ( ZERO = 0.0D+0 )
182      INTEGER            NTYPES
183      PARAMETER          ( NTYPES = 9 )
184      INTEGER            NTESTS
185      PARAMETER          ( NTESTS = 8 )
186*     ..
187*     .. Local Scalars ..
188      LOGICAL            ZEROT
189      CHARACTER          DIST, PACKIT, TYPE, UPLO, XTYPE
190      CHARACTER*3        PATH
191      INTEGER            I, IMAT, IN, INFO, IOFF, IRHS, IUPLO, IZERO, K,
192     $                   KL, KU, LDA, MODE, N, NERRS, NFAIL, NIMAT, NPP,
193     $                   NRHS, NRUN
194      DOUBLE PRECISION   ANORM, CNDNUM, RCOND, RCONDC
195*     ..
196*     .. Local Arrays ..
197      CHARACTER          PACKS( 2 ), UPLOS( 2 )
198      INTEGER            ISEED( 4 ), ISEEDY( 4 )
199      DOUBLE PRECISION   RESULT( NTESTS )
200*     ..
201*     .. External Functions ..
202      DOUBLE PRECISION   DGET06, ZLANHP
203      EXTERNAL           DGET06, ZLANHP
204*     ..
205*     .. External Subroutines ..
206      EXTERNAL           ALAERH, ALAHD, ALASUM, ZCOPY, ZERRPO, ZGET04,
207     $                   ZLACPY, ZLAIPD, ZLARHS, ZLATB4, ZLATMS, ZPPCON,
208     $                   ZPPRFS, ZPPT01, ZPPT02, ZPPT03, ZPPT05, ZPPTRF,
209     $                   ZPPTRI, ZPPTRS
210*     ..
211*     .. Scalars in Common ..
212      LOGICAL            LERR, OK
213      CHARACTER*32       SRNAMT
214      INTEGER            INFOT, NUNIT
215*     ..
216*     .. Common blocks ..
217      COMMON             / INFOC / INFOT, NUNIT, OK, LERR
218      COMMON             / SRNAMC / SRNAMT
219*     ..
220*     .. Intrinsic Functions ..
221      INTRINSIC          MAX
222*     ..
223*     .. Data statements ..
224      DATA               ISEEDY / 1988, 1989, 1990, 1991 /
225      DATA               UPLOS / 'U', 'L' / , PACKS / 'C', 'R' /
226*     ..
227*     .. Executable Statements ..
228*
229*     Initialize constants and the random number seed.
230*
231      PATH( 1: 1 ) = 'Zomplex precision'
232      PATH( 2: 3 ) = 'PP'
233      NRUN = 0
234      NFAIL = 0
235      NERRS = 0
236      DO 10 I = 1, 4
237         ISEED( I ) = ISEEDY( I )
238   10 CONTINUE
239*
240*     Test the error exits
241*
242      IF( TSTERR )
243     $   CALL ZERRPO( PATH, NOUT )
244      INFOT = 0
245*
246*     Do for each value of N in NVAL
247*
248      DO 110 IN = 1, NN
249         N = NVAL( IN )
250         LDA = MAX( N, 1 )
251         XTYPE = 'N'
252         NIMAT = NTYPES
253         IF( N.LE.0 )
254     $      NIMAT = 1
255*
256         DO 100 IMAT = 1, NIMAT
257*
258*           Do the tests only if DOTYPE( IMAT ) is true.
259*
260            IF( .NOT.DOTYPE( IMAT ) )
261     $         GO TO 100
262*
263*           Skip types 3, 4, or 5 if the matrix size is too small.
264*
265            ZEROT = IMAT.GE.3 .AND. IMAT.LE.5
266            IF( ZEROT .AND. N.LT.IMAT-2 )
267     $         GO TO 100
268*
269*           Do first for UPLO = 'U', then for UPLO = 'L'
270*
271            DO 90 IUPLO = 1, 2
272               UPLO = UPLOS( IUPLO )
273               PACKIT = PACKS( IUPLO )
274*
275*              Set up parameters with ZLATB4 and generate a test matrix
276*              with ZLATMS.
277*
278               CALL ZLATB4( PATH, IMAT, N, N, TYPE, KL, KU, ANORM, MODE,
279     $                      CNDNUM, DIST )
280*
281               SRNAMT = 'ZLATMS'
282               CALL ZLATMS( N, N, DIST, ISEED, TYPE, RWORK, MODE,
283     $                      CNDNUM, ANORM, KL, KU, PACKIT, A, LDA, WORK,
284     $                      INFO )
285*
286*              Check error code from ZLATMS.
287*
288               IF( INFO.NE.0 ) THEN
289                  CALL ALAERH( PATH, 'ZLATMS', INFO, 0, UPLO, N, N, -1,
290     $                         -1, -1, IMAT, NFAIL, NERRS, NOUT )
291                  GO TO 90
292               END IF
293*
294*              For types 3-5, zero one row and column of the matrix to
295*              test that INFO is returned correctly.
296*
297               IF( ZEROT ) THEN
298                  IF( IMAT.EQ.3 ) THEN
299                     IZERO = 1
300                  ELSE IF( IMAT.EQ.4 ) THEN
301                     IZERO = N
302                  ELSE
303                     IZERO = N / 2 + 1
304                  END IF
305*
306*                 Set row and column IZERO of A to 0.
307*
308                  IF( IUPLO.EQ.1 ) THEN
309                     IOFF = ( IZERO-1 )*IZERO / 2
310                     DO 20 I = 1, IZERO - 1
311                        A( IOFF+I ) = ZERO
312   20                CONTINUE
313                     IOFF = IOFF + IZERO
314                     DO 30 I = IZERO, N
315                        A( IOFF ) = ZERO
316                        IOFF = IOFF + I
317   30                CONTINUE
318                  ELSE
319                     IOFF = IZERO
320                     DO 40 I = 1, IZERO - 1
321                        A( IOFF ) = ZERO
322                        IOFF = IOFF + N - I
323   40                CONTINUE
324                     IOFF = IOFF - IZERO
325                     DO 50 I = IZERO, N
326                        A( IOFF+I ) = ZERO
327   50                CONTINUE
328                  END IF
329               ELSE
330                  IZERO = 0
331               END IF
332*
333*              Set the imaginary part of the diagonals.
334*
335               IF( IUPLO.EQ.1 ) THEN
336                  CALL ZLAIPD( N, A, 2, 1 )
337               ELSE
338                  CALL ZLAIPD( N, A, N, -1 )
339               END IF
340*
341*              Compute the L*L' or U'*U factorization of the matrix.
342*
343               NPP = N*( N+1 ) / 2
344               CALL ZCOPY( NPP, A, 1, AFAC, 1 )
345               SRNAMT = 'ZPPTRF'
346               CALL ZPPTRF( UPLO, N, AFAC, INFO )
347*
348*              Check error code from ZPPTRF.
349*
350               IF( INFO.NE.IZERO ) THEN
351                  CALL ALAERH( PATH, 'ZPPTRF', INFO, IZERO, UPLO, N, N,
352     $                         -1, -1, -1, IMAT, NFAIL, NERRS, NOUT )
353                  GO TO 90
354               END IF
355*
356*              Skip the tests if INFO is not 0.
357*
358               IF( INFO.NE.0 )
359     $            GO TO 90
360*
361*+    TEST 1
362*              Reconstruct matrix from factors and compute residual.
363*
364               CALL ZCOPY( NPP, AFAC, 1, AINV, 1 )
365               CALL ZPPT01( UPLO, N, A, AINV, RWORK, RESULT( 1 ) )
366*
367*+    TEST 2
368*              Form the inverse and compute the residual.
369*
370               CALL ZCOPY( NPP, AFAC, 1, AINV, 1 )
371               SRNAMT = 'ZPPTRI'
372               CALL ZPPTRI( UPLO, N, AINV, INFO )
373*
374*              Check error code from ZPPTRI.
375*
376               IF( INFO.NE.0 )
377     $            CALL ALAERH( PATH, 'ZPPTRI', INFO, 0, UPLO, N, N, -1,
378     $                         -1, -1, IMAT, NFAIL, NERRS, NOUT )
379*
380               CALL ZPPT03( UPLO, N, A, AINV, WORK, LDA, RWORK, RCONDC,
381     $                      RESULT( 2 ) )
382*
383*              Print information about the tests that did not pass
384*              the threshold.
385*
386               DO 60 K = 1, 2
387                  IF( RESULT( K ).GE.THRESH ) THEN
388                     IF( NFAIL.EQ.0 .AND. NERRS.EQ.0 )
389     $                  CALL ALAHD( NOUT, PATH )
390                     WRITE( NOUT, FMT = 9999 )UPLO, N, IMAT, K,
391     $                  RESULT( K )
392                     NFAIL = NFAIL + 1
393                  END IF
394   60          CONTINUE
395               NRUN = NRUN + 2
396*
397               DO 80 IRHS = 1, NNS
398                  NRHS = NSVAL( IRHS )
399*
400*+    TEST 3
401*              Solve and compute residual for  A * X = B.
402*
403                  SRNAMT = 'ZLARHS'
404                  CALL ZLARHS( PATH, XTYPE, UPLO, ' ', N, N, KL, KU,
405     $                         NRHS, A, LDA, XACT, LDA, B, LDA, ISEED,
406     $                         INFO )
407                  CALL ZLACPY( 'Full', N, NRHS, B, LDA, X, LDA )
408*
409                  SRNAMT = 'ZPPTRS'
410                  CALL ZPPTRS( UPLO, N, NRHS, AFAC, X, LDA, INFO )
411*
412*              Check error code from ZPPTRS.
413*
414                  IF( INFO.NE.0 )
415     $               CALL ALAERH( PATH, 'ZPPTRS', INFO, 0, UPLO, N, N,
416     $                            -1, -1, NRHS, IMAT, NFAIL, NERRS,
417     $                            NOUT )
418*
419                  CALL ZLACPY( 'Full', N, NRHS, B, LDA, WORK, LDA )
420                  CALL ZPPT02( UPLO, N, NRHS, A, X, LDA, WORK, LDA,
421     $                         RWORK, RESULT( 3 ) )
422*
423*+    TEST 4
424*              Check solution from generated exact solution.
425*
426                  CALL ZGET04( N, NRHS, X, LDA, XACT, LDA, RCONDC,
427     $                         RESULT( 4 ) )
428*
429*+    TESTS 5, 6, and 7
430*              Use iterative refinement to improve the solution.
431*
432                  SRNAMT = 'ZPPRFS'
433                  CALL ZPPRFS( UPLO, N, NRHS, A, AFAC, B, LDA, X, LDA,
434     $                         RWORK, RWORK( NRHS+1 ), WORK,
435     $                         RWORK( 2*NRHS+1 ), INFO )
436*
437*              Check error code from ZPPRFS.
438*
439                  IF( INFO.NE.0 )
440     $               CALL ALAERH( PATH, 'ZPPRFS', INFO, 0, UPLO, N, N,
441     $                            -1, -1, NRHS, IMAT, NFAIL, NERRS,
442     $                            NOUT )
443*
444                  CALL ZGET04( N, NRHS, X, LDA, XACT, LDA, RCONDC,
445     $                         RESULT( 5 ) )
446                  CALL ZPPT05( UPLO, N, NRHS, A, B, LDA, X, LDA, XACT,
447     $                         LDA, RWORK, RWORK( NRHS+1 ),
448     $                         RESULT( 6 ) )
449*
450*                 Print information about the tests that did not pass
451*                 the threshold.
452*
453                  DO 70 K = 3, 7
454                     IF( RESULT( K ).GE.THRESH ) THEN
455                        IF( NFAIL.EQ.0 .AND. NERRS.EQ.0 )
456     $                     CALL ALAHD( NOUT, PATH )
457                        WRITE( NOUT, FMT = 9998 )UPLO, N, NRHS, IMAT,
458     $                     K, RESULT( K )
459                        NFAIL = NFAIL + 1
460                     END IF
461   70             CONTINUE
462                  NRUN = NRUN + 5
463   80          CONTINUE
464*
465*+    TEST 8
466*              Get an estimate of RCOND = 1/CNDNUM.
467*
468               ANORM = ZLANHP( '1', UPLO, N, A, RWORK )
469               SRNAMT = 'ZPPCON'
470               CALL ZPPCON( UPLO, N, AFAC, ANORM, RCOND, WORK, RWORK,
471     $                      INFO )
472*
473*              Check error code from ZPPCON.
474*
475               IF( INFO.NE.0 )
476     $            CALL ALAERH( PATH, 'ZPPCON', INFO, 0, UPLO, N, N, -1,
477     $                         -1, -1, IMAT, NFAIL, NERRS, NOUT )
478*
479               RESULT( 8 ) = DGET06( RCOND, RCONDC )
480*
481*              Print the test ratio if greater than or equal to THRESH.
482*
483               IF( RESULT( 8 ).GE.THRESH ) THEN
484                  IF( NFAIL.EQ.0 .AND. NERRS.EQ.0 )
485     $               CALL ALAHD( NOUT, PATH )
486                  WRITE( NOUT, FMT = 9999 )UPLO, N, IMAT, 8,
487     $               RESULT( 8 )
488                  NFAIL = NFAIL + 1
489               END IF
490               NRUN = NRUN + 1
491*
492   90       CONTINUE
493  100    CONTINUE
494  110 CONTINUE
495*
496*     Print a summary of the results.
497*
498      CALL ALASUM( PATH, NOUT, NFAIL, NRUN, NERRS )
499*
500 9999 FORMAT( ' UPLO = ''', A1, ''', N =', I5, ', type ', I2, ', test ',
501     $      I2, ', ratio =', G12.5 )
502 9998 FORMAT( ' UPLO = ''', A1, ''', N =', I5, ', NRHS=', I3, ', type ',
503     $      I2, ', test(', I2, ') =', G12.5 )
504      RETURN
505*
506*     End of ZCHKPP
507*
508      END
509