1*> \brief \b ZDRVSY_AA
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 ZDRVSY_AA( DOTYPE, NN, NVAL, NRHS, THRESH, TSTERR, NMAX,
12*                             A, AFAC, AINV, B, X, XACT, WORK, RWORK, IWORK,
13*                             NOUT )
14*
15*       .. Scalar Arguments ..
16*       LOGICAL            TSTERR
17*       INTEGER            NMAX, NN, NOUT, NRHS
18*       DOUBLE PRECISION   THRESH
19*       ..
20*       .. Array Arguments ..
21*       LOGICAL            DOTYPE( * )
22*       INTEGER            IWORK( * ), 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*> ZDRVSY_AA tests the driver routine ZSYSV_AA.
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] NRHS
61*> \verbatim
62*>          NRHS is INTEGER
63*>          The number of right hand side vectors to be generated for
64*>          each linear system.
65*> \endverbatim
66*>
67*> \param[in] THRESH
68*> \verbatim
69*>          THRESH is COMPLEX*16
70*>          The threshold value for the test ratios.  A result is
71*>          included in the output file if RESULT >= THRESH.  To have
72*>          every test ratio printed, use THRESH = 0.
73*> \endverbatim
74*>
75*> \param[in] TSTERR
76*> \verbatim
77*>          TSTERR is LOGICAL
78*>          Flag that indicates whether error exits are to be tested.
79*> \endverbatim
80*>
81*> \param[in] NMAX
82*> \verbatim
83*>          NMAX is INTEGER
84*>          The maximum value permitted for N, used in dimensioning the
85*>          work arrays.
86*> \endverbatim
87*>
88*> \param[out] A
89*> \verbatim
90*>          A is COMPLEX*16 array, dimension (NMAX*NMAX)
91*> \endverbatim
92*>
93*> \param[out] AFAC
94*> \verbatim
95*>          AFAC is COMPLEX*16 array, dimension (NMAX*NMAX)
96*> \endverbatim
97*>
98*> \param[out] AINV
99*> \verbatim
100*>          AINV is COMPLEX*16 array, dimension (NMAX*NMAX)
101*> \endverbatim
102*>
103*> \param[out] B
104*> \verbatim
105*>          B is COMPLEX*16 array, dimension (NMAX*NRHS)
106*> \endverbatim
107*>
108*> \param[out] X
109*> \verbatim
110*>          X is COMPLEX*16 array, dimension (NMAX*NRHS)
111*> \endverbatim
112*>
113*> \param[out] XACT
114*> \verbatim
115*>          XACT is COMPLEX*16 array, dimension (NMAX*NRHS)
116*> \endverbatim
117*>
118*> \param[out] WORK
119*> \verbatim
120*>          WORK is COMPLEX*16 array, dimension (NMAX*max(2,NRHS))
121*> \endverbatim
122*>
123*> \param[out] RWORK
124*> \verbatim
125*>          RWORK is COMPLEX*16 array, dimension (NMAX+2*NRHS)
126*> \endverbatim
127*>
128*> \param[out] IWORK
129*> \verbatim
130*>          IWORK is INTEGER array, dimension (2*NMAX)
131*> \endverbatim
132*>
133*> \param[in] NOUT
134*> \verbatim
135*>          NOUT is INTEGER
136*>          The unit number for output.
137*> \endverbatim
138*
139*  Authors:
140*  ========
141*
142*> \author Univ. of Tennessee
143*> \author Univ. of California Berkeley
144*> \author Univ. of Colorado Denver
145*> \author NAG Ltd.
146*
147*> \ingroup complex16_lin
148*
149*  =====================================================================
150      SUBROUTINE ZDRVSY_AA( DOTYPE, NN, NVAL, NRHS, THRESH, TSTERR,
151     $                      NMAX, A, AFAC, AINV, B, X, XACT, WORK,
152     $                      RWORK, IWORK, NOUT )
153*
154*  -- LAPACK test routine --
155*  -- LAPACK is a software package provided by Univ. of Tennessee,    --
156*  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
157*
158*     .. Scalar Arguments ..
159      LOGICAL            TSTERR
160      INTEGER            NMAX, NN, NOUT, NRHS
161      DOUBLE PRECISION   THRESH
162*     ..
163*     .. Array Arguments ..
164      LOGICAL            DOTYPE( * )
165      INTEGER            IWORK( * ), NVAL( * )
166      DOUBLE PRECISION   RWORK( * )
167      COMPLEX*16         A( * ), AFAC( * ), AINV( * ), B( * ),
168     $                   WORK( * ), X( * ), XACT( * )
169*     ..
170*
171*  =====================================================================
172*
173*     .. Parameters ..
174      DOUBLE PRECISION   ZERO
175      PARAMETER          ( ZERO = 0.0D+0 )
176      COMPLEX*16         CZERO
177      PARAMETER          ( CZERO = 0.0E+0 )
178      INTEGER            NTYPES, NTESTS
179      PARAMETER          ( NTYPES = 10, NTESTS = 3 )
180      INTEGER            NFACT
181      PARAMETER          ( NFACT = 2 )
182*     ..
183*     .. Local Scalars ..
184      LOGICAL            ZEROT
185      CHARACTER          DIST, FACT, TYPE, UPLO, XTYPE
186      CHARACTER*3        MATPATH, PATH
187      INTEGER            I, I1, I2, IFACT, IMAT, IN, INFO, IOFF, IUPLO,
188     $                   IZERO, J, K, KL, KU, LDA, LWORK, MODE, N,
189     $                   NB, NBMIN, NERRS, NFAIL, NIMAT, NRUN, NT
190      DOUBLE PRECISION   ANORM, CNDNUM
191*     ..
192*     .. Local Arrays ..
193      CHARACTER          FACTS( NFACT ), UPLOS( 2 )
194      INTEGER            ISEED( 4 ), ISEEDY( 4 )
195      DOUBLE PRECISION   RESULT( NTESTS )
196*     ..
197*     .. External Functions ..
198      DOUBLE PRECISION   DGET06, ZLANSY
199      EXTERNAL           DGET06, ZLANSY
200*     ..
201*     .. External Subroutines ..
202      EXTERNAL           ALADHD, ALAERH, ALASVM, ZERRVX, ZGET04, ZLACPY,
203     $                   ZLARHS, ZLASET, ZLATB4, ZLATMS, ZSYT02,
204     $                   ZSYSV_AA, ZSYT01_AA, ZSYTRF_AA, XLAENV
205*     ..
206*     .. Scalars in Common ..
207      LOGICAL            LERR, OK
208      CHARACTER*32       SRNAMT
209      INTEGER            INFOT, NUNIT
210*     ..
211*     .. Common blocks ..
212      COMMON             / INFOC / INFOT, NUNIT, OK, LERR
213      COMMON             / SRNAMC / SRNAMT
214*     ..
215*     .. Intrinsic Functions ..
216      INTRINSIC          MAX, MIN
217*     ..
218*     .. Data statements ..
219      DATA               ISEEDY / 1988, 1989, 1990, 1991 /
220      DATA               UPLOS / 'U', 'L' / , FACTS / 'F', 'N' /
221*     ..
222*     .. Executable Statements ..
223*
224*     Initialize constants and the random number seed.
225*
226*     Test path
227*
228      PATH( 1: 1 ) = 'Zomplex precision'
229      PATH( 2: 3 ) = 'SA'
230*
231*     Path to generate matrices
232*
233      MATPATH( 1: 1 ) = 'Zomplex precision'
234      MATPATH( 2: 3 ) = 'SY'
235*
236      NRUN = 0
237      NFAIL = 0
238      NERRS = 0
239      DO 10 I = 1, 4
240         ISEED( I ) = ISEEDY( I )
241   10 CONTINUE
242*
243*     Test the error exits
244*
245      IF( TSTERR )
246     $   CALL ZERRVX( PATH, NOUT )
247      INFOT = 0
248*
249*     Set the block size and minimum block size for testing.
250*
251      NB = 1
252      NBMIN = 2
253      CALL XLAENV( 1, NB )
254      CALL XLAENV( 2, NBMIN )
255*
256*     Do for each value of N in NVAL
257*
258      DO 180 IN = 1, NN
259         N = NVAL( IN )
260         LWORK = MAX( 3*N-2, N*(1+NB) )
261         LWORK = MAX( LWORK, 1 )
262         LDA = MAX( N, 1 )
263         XTYPE = 'N'
264         NIMAT = NTYPES
265         IF( N.LE.0 )
266     $      NIMAT = 1
267*
268         DO 170 IMAT = 1, NIMAT
269*
270*           Do the tests only if DOTYPE( IMAT ) is true.
271*
272            IF( .NOT.DOTYPE( IMAT ) )
273     $         GO TO 170
274*
275*           Skip types 3, 4, 5, or 6 if the matrix size is too small.
276*
277            ZEROT = IMAT.GE.3 .AND. IMAT.LE.6
278            IF( ZEROT .AND. N.LT.IMAT-2 )
279     $         GO TO 170
280*
281*           Do first for UPLO = 'U', then for UPLO = 'L'
282*
283            DO 160 IUPLO = 1, 2
284               UPLO = UPLOS( IUPLO )
285*
286*              Set up parameters with ZLATB4 and generate a test matrix
287*              with ZLATMS.
288*
289               CALL ZLATB4( MATPATH, IMAT, N, N, TYPE, KL, KU, ANORM,
290     $                      MODE, CNDNUM, DIST )
291*
292               SRNAMT = 'ZLATMS'
293               CALL ZLATMS( N, N, DIST, ISEED, TYPE, RWORK, MODE,
294     $                      CNDNUM, ANORM, KL, KU, UPLO, A, LDA, WORK,
295     $                      INFO )
296*
297*              Check error code from ZLATMS.
298*
299               IF( INFO.NE.0 ) THEN
300                  CALL ALAERH( PATH, 'ZLATMS', INFO, 0, UPLO, N, N, -1,
301     $                         -1, -1, IMAT, NFAIL, NERRS, NOUT )
302                  GO TO 160
303               END IF
304*
305*              For types 3-6, zero one or more rows and columns of the
306*              matrix to test that INFO is returned correctly.
307*
308               IF( ZEROT ) THEN
309                  IF( IMAT.EQ.3 ) THEN
310                     IZERO = 1
311                  ELSE IF( IMAT.EQ.4 ) THEN
312                     IZERO = N
313                  ELSE
314                     IZERO = N / 2 + 1
315                  END IF
316*
317                  IF( IMAT.LT.6 ) THEN
318*
319*                    Set row and column IZERO to zero.
320*
321                     IF( IUPLO.EQ.1 ) THEN
322                        IOFF = ( IZERO-1 )*LDA
323                        DO 20 I = 1, IZERO - 1
324                           A( IOFF+I ) = CZERO
325   20                   CONTINUE
326                        IOFF = IOFF + IZERO
327                        DO 30 I = IZERO, N
328                           A( IOFF ) = CZERO
329                           IOFF = IOFF + LDA
330   30                   CONTINUE
331                     ELSE
332                        IOFF = IZERO
333                        DO 40 I = 1, IZERO - 1
334                           A( IOFF ) = CZERO
335                           IOFF = IOFF + LDA
336   40                   CONTINUE
337                        IOFF = IOFF - IZERO
338                        DO 50 I = IZERO, N
339                           A( IOFF+I ) = CZERO
340   50                   CONTINUE
341                     END IF
342                  ELSE
343                     IOFF = 0
344                     IF( IUPLO.EQ.1 ) THEN
345*
346*                       Set the first IZERO rows and columns to zero.
347*
348                        DO 70 J = 1, N
349                           I2 = MIN( J, IZERO )
350                           DO 60 I = 1, I2
351                              A( IOFF+I ) = CZERO
352   60                      CONTINUE
353                           IOFF = IOFF + LDA
354   70                   CONTINUE
355                        IZERO = 1
356                     ELSE
357*
358*                       Set the last IZERO rows and columns to zero.
359*
360                        DO 90 J = 1, N
361                           I1 = MAX( J, IZERO )
362                           DO 80 I = I1, N
363                              A( IOFF+I ) = CZERO
364   80                      CONTINUE
365                           IOFF = IOFF + LDA
366   90                   CONTINUE
367                     END IF
368                  END IF
369               ELSE
370                  IZERO = 0
371               END IF
372*
373               DO 150 IFACT = 1, NFACT
374*
375*                 Do first for FACT = 'F', then for other values.
376*
377                  FACT = FACTS( IFACT )
378*
379*                 Form an exact solution and set the right hand side.
380*
381                  SRNAMT = 'ZLARHS'
382                  CALL ZLARHS( MATPATH, XTYPE, UPLO, ' ', N, N, KL, KU,
383     $                         NRHS, A, LDA, XACT, LDA, B, LDA, ISEED,
384     $                         INFO )
385                  XTYPE = 'C'
386*
387*                 --- Test ZSYSV_AA  ---
388*
389                  IF( IFACT.EQ.2 ) THEN
390                     CALL ZLACPY( UPLO, N, N, A, LDA, AFAC, LDA )
391                     CALL ZLACPY( 'Full', N, NRHS, B, LDA, X, LDA )
392*
393*                    Factor the matrix and solve the system using ZSYSV_AA.
394*
395                     SRNAMT = 'ZSYSV_AA'
396                     CALL ZSYSV_AA( UPLO, N, NRHS, AFAC, LDA, IWORK,
397     $                                 X, LDA, WORK, LWORK, INFO )
398*
399*                    Adjust the expected value of INFO to account for
400*                    pivoting.
401*
402                     IF( IZERO.GT.0 ) THEN
403                        J = 1
404                        K = IZERO
405  100                   CONTINUE
406                        IF( J.EQ.K ) THEN
407                           K = IWORK( J )
408                        ELSE IF( IWORK( J ).EQ.K ) THEN
409                           K = J
410                        END IF
411                        IF( J.LT.K ) THEN
412                           J = J + 1
413                           GO TO 100
414                        END IF
415                     ELSE
416                        K = 0
417                     END IF
418*
419*                    Check error code from ZSYSV_AA .
420*
421                     IF( INFO.NE.K ) THEN
422                        CALL ALAERH( PATH, 'ZSYSV_AA ', INFO, K,
423     $                               UPLO, N, N, -1, -1, NRHS,
424     $                               IMAT, NFAIL, NERRS, NOUT )
425                        GO TO 120
426                     ELSE IF( INFO.NE.0 ) THEN
427                        GO TO 120
428                     END IF
429*
430*                    Reconstruct matrix from factors and compute
431*                    residual.
432*
433                     CALL ZSYT01_AA( UPLO, N, A, LDA, AFAC, LDA,
434     $                               IWORK, AINV, LDA, RWORK,
435     $                               RESULT( 1 ) )
436*
437*                    Compute residual of the computed solution.
438*
439                     CALL ZLACPY( 'Full', N, NRHS, B, LDA, WORK, LDA )
440                     CALL ZSYT02( UPLO, N, NRHS, A, LDA, X, LDA, WORK,
441     $                            LDA, RWORK, RESULT( 2 ) )
442                     NT = 2
443*
444*                    Print information about the tests that did not pass
445*                    the threshold.
446*
447                     DO 110 K = 1, NT
448                        IF( RESULT( K ).GE.THRESH ) THEN
449                           IF( NFAIL.EQ.0 .AND. NERRS.EQ.0 )
450     $                        CALL ALADHD( NOUT, PATH )
451                           WRITE( NOUT, FMT = 9999 )'ZSYSV_AA ',
452     $                        UPLO, N, IMAT, K, RESULT( K )
453                           NFAIL = NFAIL + 1
454                        END IF
455  110                CONTINUE
456                     NRUN = NRUN + NT
457  120                CONTINUE
458                  END IF
459*
460  150          CONTINUE
461*
462  160       CONTINUE
463  170    CONTINUE
464  180 CONTINUE
465*
466*     Print a summary of the results.
467*
468      CALL ALASVM( PATH, NOUT, NFAIL, NRUN, NERRS )
469*
470 9999 FORMAT( 1X, A, ', UPLO=''', A1, ''', N =', I5, ', type ', I2,
471     $      ', test ', I2, ', ratio =', G12.5 )
472      RETURN
473*
474*     End of ZDRVSY_AA
475*
476      END
477