LAPACK  3.4.2
LAPACK: Linear Algebra PACKage
 All Files Functions Groups
zchksy.f
Go to the documentation of this file.
1 *> \brief \b ZCHKSY
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 ZCHKSY( DOTYPE, NN, NVAL, NNB, NBVAL, NNS, NSVAL,
12 * THRESH, TSTERR, NMAX, A, AFAC, AINV, B, X,
13 * XACT, WORK, RWORK, IWORK, NOUT )
14 *
15 * .. Scalar Arguments ..
16 * LOGICAL TSTERR
17 * INTEGER NMAX, NN, NNB, NNS, NOUT
18 * DOUBLE PRECISION THRESH
19 * ..
20 * .. Array Arguments ..
21 * LOGICAL DOTYPE( * )
22 * INTEGER IWORK( * ), NBVAL( * ), 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 *> ZCHKSY tests ZSYTRF, -TRI2, -TRS, -TRS2, -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] NNB
61 *> \verbatim
62 *> NNB is INTEGER
63 *> The number of values of NB contained in the vector NBVAL.
64 *> \endverbatim
65 *>
66 *> \param[in] NBVAL
67 *> \verbatim
68 *> NBVAL is INTEGER array, dimension (NBVAL)
69 *> The values of the blocksize NB.
70 *> \endverbatim
71 *>
72 *> \param[in] NNS
73 *> \verbatim
74 *> NNS is INTEGER
75 *> The number of values of NRHS contained in the vector NSVAL.
76 *> \endverbatim
77 *>
78 *> \param[in] NSVAL
79 *> \verbatim
80 *> NSVAL is INTEGER array, dimension (NNS)
81 *> The values of the number of right hand sides NRHS.
82 *> \endverbatim
83 *>
84 *> \param[in] THRESH
85 *> \verbatim
86 *> THRESH is DOUBLE PRECISION
87 *> The threshold value for the test ratios. A result is
88 *> included in the output file if RESULT >= THRESH. To have
89 *> every test ratio printed, use THRESH = 0.
90 *> \endverbatim
91 *>
92 *> \param[in] TSTERR
93 *> \verbatim
94 *> TSTERR is LOGICAL
95 *> Flag that indicates whether error exits are to be tested.
96 *> \endverbatim
97 *>
98 *> \param[in] NMAX
99 *> \verbatim
100 *> NMAX is INTEGER
101 *> The maximum value permitted for N, used in dimensioning the
102 *> work arrays.
103 *> \endverbatim
104 *>
105 *> \param[out] A
106 *> \verbatim
107 *> A is COMPLEX*16 array, dimension (NMAX*NMAX)
108 *> \endverbatim
109 *>
110 *> \param[out] AFAC
111 *> \verbatim
112 *> AFAC is COMPLEX*16 array, dimension (NMAX*NMAX)
113 *> \endverbatim
114 *>
115 *> \param[out] AINV
116 *> \verbatim
117 *> AINV is COMPLEX*16 array, dimension (NMAX*NMAX)
118 *> \endverbatim
119 *>
120 *> \param[out] B
121 *> \verbatim
122 *> B is COMPLEX*16 array, dimension (NMAX*NSMAX)
123 *> where NSMAX is the largest entry in NSVAL.
124 *> \endverbatim
125 *>
126 *> \param[out] X
127 *> \verbatim
128 *> X is COMPLEX*16 array, dimension (NMAX*NSMAX)
129 *> \endverbatim
130 *>
131 *> \param[out] XACT
132 *> \verbatim
133 *> XACT is COMPLEX*16 array, dimension (NMAX*NSMAX)
134 *> \endverbatim
135 *>
136 *> \param[out] WORK
137 *> \verbatim
138 *> WORK is COMPLEX*16 array, dimension
139 *> (NMAX*max(2,NSMAX))
140 *> \endverbatim
141 *>
142 *> \param[out] RWORK
143 *> \verbatim
144 *> RWORK is DOUBLE PRECISION array,
145 *> dimension (NMAX+2*NSMAX)
146 *> \endverbatim
147 *>
148 *> \param[out] IWORK
149 *> \verbatim
150 *> IWORK is INTEGER array, dimension (NMAX)
151 *> \endverbatim
152 *>
153 *> \param[in] NOUT
154 *> \verbatim
155 *> NOUT is INTEGER
156 *> The unit number for output.
157 *> \endverbatim
158 *
159 * Authors:
160 * ========
161 *
162 *> \author Univ. of Tennessee
163 *> \author Univ. of California Berkeley
164 *> \author Univ. of Colorado Denver
165 *> \author NAG Ltd.
166 *
167 *> \date April 2012
168 *
169 *> \ingroup complex16_lin
170 *
171 * =====================================================================
172  SUBROUTINE zchksy( DOTYPE, NN, NVAL, NNB, NBVAL, NNS, NSVAL,
173  $ thresh, tsterr, nmax, a, afac, ainv, b, x,
174  $ xact, work, rwork, iwork, nout )
175 *
176 * -- LAPACK test routine (version 3.4.1) --
177 * -- LAPACK is a software package provided by Univ. of Tennessee, --
178 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
179 * April 2012
180 *
181 * .. Scalar Arguments ..
182  LOGICAL tsterr
183  INTEGER nmax, nn, nnb, nns, nout
184  DOUBLE PRECISION thresh
185 * ..
186 * .. Array Arguments ..
187  LOGICAL dotype( * )
188  INTEGER iwork( * ), nbval( * ), nsval( * ), nval( * )
189  DOUBLE PRECISION rwork( * )
190  COMPLEX*16 a( * ), afac( * ), ainv( * ), b( * ),
191  $ work( * ), x( * ), xact( * )
192 * ..
193 *
194 * =====================================================================
195 *
196 * .. Parameters ..
197  DOUBLE PRECISION zero
198  parameter( zero = 0.0d+0 )
199  COMPLEX*16 czero
200  parameter( czero = ( 0.0d+0, 0.0d+0 ) )
201  INTEGER ntypes
202  parameter( ntypes = 11 )
203  INTEGER ntests
204  parameter( ntests = 9 )
205 * ..
206 * .. Local Scalars ..
207  LOGICAL trfcon, zerot
208  CHARACTER dist, type, uplo, xtype
209  CHARACTER*3 path
210  INTEGER i, i1, i2, imat, in, inb, info, ioff, irhs,
211  $ iuplo, izero, j, k, kl, ku, lda, lwork, mode,
212  $ n, nb, nerrs, nfail, nimat, nrhs, nrun, nt
213  DOUBLE PRECISION anorm, cndnum, rcond, rcondc
214 * ..
215 * .. Local Arrays ..
216  CHARACTER uplos( 2 )
217  INTEGER iseed( 4 ), iseedy( 4 )
218  DOUBLE PRECISION result( ntests )
219 * ..
220 * .. External Functions ..
221  DOUBLE PRECISION dget06, zlansy
222  EXTERNAL dget06, zlansy
223 * ..
224 * .. External Subroutines ..
225  EXTERNAL alaerh, alahd, alasum, xlaenv, zerrsy, zget04,
229 * ..
230 * .. Intrinsic Functions ..
231  INTRINSIC max, min
232 * ..
233 * .. Scalars in Common ..
234  LOGICAL lerr, ok
235  CHARACTER*32 srnamt
236  INTEGER infot, nunit
237 * ..
238 * .. Common blocks ..
239  common / infoc / infot, nunit, ok, lerr
240  common / srnamc / srnamt
241 * ..
242 * .. Data statements ..
243  DATA iseedy / 1988, 1989, 1990, 1991 /
244  DATA uplos / 'U', 'L' /
245 * ..
246 * .. Executable Statements ..
247 *
248 * Initialize constants and the random number seed.
249 *
250  path( 1: 1 ) = 'Zomplex precision'
251  path( 2: 3 ) = 'SY'
252  nrun = 0
253  nfail = 0
254  nerrs = 0
255  DO 10 i = 1, 4
256  iseed( i ) = iseedy( i )
257  10 continue
258 *
259 * Test the error exits
260 *
261  IF( tsterr )
262  $ CALL zerrsy( path, nout )
263  infot = 0
264 *
265 * Set the minimum block size for which the block routine should
266 * be used, which will be later returned by ILAENV
267 *
268  CALL xlaenv( 2, 2 )
269 *
270 * Do for each value of N in NVAL
271 *
272  DO 180 in = 1, nn
273  n = nval( in )
274  lda = max( n, 1 )
275  xtype = 'N'
276  nimat = ntypes
277  IF( n.LE.0 )
278  $ nimat = 1
279 *
280  izero = 0
281 *
282 * Do for each value of matrix type IMAT
283 *
284  DO 170 imat = 1, nimat
285 *
286 * Do the tests only if DOTYPE( IMAT ) is true.
287 *
288  IF( .NOT.dotype( imat ) )
289  $ go to 170
290 *
291 * Skip types 3, 4, 5, or 6 if the matrix size is too small.
292 *
293  zerot = imat.GE.3 .AND. imat.LE.6
294  IF( zerot .AND. n.LT.imat-2 )
295  $ go to 170
296 *
297 * Do first for UPLO = 'U', then for UPLO = 'L'
298 *
299  DO 160 iuplo = 1, 2
300  uplo = uplos( iuplo )
301 *
302  IF( imat.NE.ntypes ) THEN
303 *
304 * Set up parameters with ZLATB4 and generate a test
305 * matrix with ZLATMS.
306 *
307  CALL zlatb4( path, imat, n, n, type, kl, ku, anorm,
308  $ mode, cndnum, dist )
309 *
310 * Generate a matrix with ZLATMS.
311 *
312  srnamt = 'ZLATMS'
313  CALL zlatms( n, n, dist, iseed, type, rwork, mode,
314  $ cndnum, anorm, kl, ku, 'N', a, lda, work,
315  $ info )
316 *
317 * Check error code from ZLATMS and handle error.
318 *
319  IF( info.NE.0 ) THEN
320  CALL alaerh( path, 'ZLATMS', info, 0, uplo, n, n,
321  $ -1, -1, -1, imat, nfail, nerrs, nout )
322  go to 160
323  END IF
324 *
325 * For matrix types 3-6, zero one or more rows and
326 * columns of the matrix to test that INFO is returned
327 * correctly.
328 *
329  IF( zerot ) THEN
330  IF( imat.EQ.3 ) THEN
331  izero = 1
332  ELSE IF( imat.EQ.4 ) THEN
333  izero = n
334  ELSE
335  izero = n / 2 + 1
336  END IF
337 *
338  IF( imat.LT.6 ) THEN
339 *
340 * Set row and column IZERO to zero.
341 *
342  IF( iuplo.EQ.1 ) THEN
343  ioff = ( izero-1 )*lda
344  DO 20 i = 1, izero - 1
345  a( ioff+i ) = czero
346  20 continue
347  ioff = ioff + izero
348  DO 30 i = izero, n
349  a( ioff ) = czero
350  ioff = ioff + lda
351  30 continue
352  ELSE
353  ioff = izero
354  DO 40 i = 1, izero - 1
355  a( ioff ) = czero
356  ioff = ioff + lda
357  40 continue
358  ioff = ioff - izero
359  DO 50 i = izero, n
360  a( ioff+i ) = czero
361  50 continue
362  END IF
363  ELSE
364  IF( iuplo.EQ.1 ) THEN
365 *
366 * Set the first IZERO rows to zero.
367 *
368  ioff = 0
369  DO 70 j = 1, n
370  i2 = min( j, izero )
371  DO 60 i = 1, i2
372  a( ioff+i ) = czero
373  60 continue
374  ioff = ioff + lda
375  70 continue
376  ELSE
377 *
378 * Set the last IZERO rows to zero.
379 *
380  ioff = 0
381  DO 90 j = 1, n
382  i1 = max( j, izero )
383  DO 80 i = i1, n
384  a( ioff+i ) = czero
385  80 continue
386  ioff = ioff + lda
387  90 continue
388  END IF
389  END IF
390  ELSE
391  izero = 0
392  END IF
393 *
394 * End generate the test matrix A.
395 *
396  ELSE
397 *
398 * Use a special block diagonal matrix to test alternate
399 * code for the 2 x 2 blocks.
400 *
401  CALL zlatsy( uplo, n, a, lda, iseed )
402 *
403  END IF
404 *
405 * Do for each value of NB in NBVAL
406 *
407  DO 150 inb = 1, nnb
408 *
409 * Set the optimal blocksize, which will be later
410 * returned by ILAENV.
411 *
412  nb = nbval( inb )
413  CALL xlaenv( 1, nb )
414 *
415 * Copy the test matrix A into matrix AFAC which
416 * will be factorized in place. This is needed to
417 * preserve the test matrix A for subsequent tests.
418 *
419  CALL zlacpy( uplo, n, n, a, lda, afac, lda )
420 *
421 * Compute the L*D*L**T or U*D*U**T factorization of the
422 * matrix. IWORK stores details of the interchanges and
423 * the block structure of D. AINV is a work array for
424 * block factorization, LWORK is the length of AINV.
425 *
426  lwork = max( 2, nb )*lda
427  srnamt = 'ZSYTRF'
428  CALL zsytrf( uplo, n, afac, lda, iwork, ainv, lwork,
429  $ info )
430 *
431 * Adjust the expected value of INFO to account for
432 * pivoting.
433 *
434  k = izero
435  IF( k.GT.0 ) THEN
436  100 continue
437  IF( iwork( k ).LT.0 ) THEN
438  IF( iwork( k ).NE.-k ) THEN
439  k = -iwork( k )
440  go to 100
441  END IF
442  ELSE IF( iwork( k ).NE.k ) THEN
443  k = iwork( k )
444  go to 100
445  END IF
446  END IF
447 *
448 * Check error code from ZSYTRF and handle error.
449 *
450  IF( info.NE.k )
451  $ CALL alaerh( path, 'ZSYTRF', info, k, uplo, n, n,
452  $ -1, -1, nb, imat, nfail, nerrs, nout )
453 *
454 * Set the condition estimate flag if the INFO is not 0.
455 *
456  IF( info.NE.0 ) THEN
457  trfcon = .true.
458  ELSE
459  trfcon = .false.
460  END IF
461 *
462 *+ TEST 1
463 * Reconstruct matrix from factors and compute residual.
464 *
465  CALL zsyt01( uplo, n, a, lda, afac, lda, iwork, ainv,
466  $ lda, rwork, result( 1 ) )
467  nt = 1
468 *
469 *+ TEST 2
470 * Form the inverse and compute the residual,
471 * if the factorization was competed without INFO > 0
472 * (i.e. there is no zero rows and columns).
473 * Do it only for the first block size.
474 *
475  IF( inb.EQ.1 .AND. .NOT.trfcon ) THEN
476  CALL zlacpy( uplo, n, n, afac, lda, ainv, lda )
477  srnamt = 'ZSYTRI2'
478  lwork = (n+nb+1)*(nb+3)
479  CALL zsytri2( uplo, n, ainv, lda, iwork, work,
480  $ lwork, info )
481 *
482 * Check error code from ZSYTRI2 and handle error.
483 *
484  IF( info.NE.0 )
485  $ CALL alaerh( path, 'ZSYTRI2', info, 0, uplo, n,
486  $ n, -1, -1, -1, imat, nfail, nerrs,
487  $ nout )
488 *
489 * Compute the residual for a symmetric matrix times
490 * its inverse.
491 *
492  CALL zsyt03( uplo, n, a, lda, ainv, lda, work, lda,
493  $ rwork, rcondc, result( 2 ) )
494  nt = 2
495  END IF
496 *
497 * Print information about the tests that did not pass
498 * the threshold.
499 *
500  DO 110 k = 1, nt
501  IF( result( k ).GE.thresh ) THEN
502  IF( nfail.EQ.0 .AND. nerrs.EQ.0 )
503  $ CALL alahd( nout, path )
504  WRITE( nout, fmt = 9999 )uplo, n, nb, imat, k,
505  $ result( k )
506  nfail = nfail + 1
507  END IF
508  110 continue
509  nrun = nrun + nt
510 *
511 * Skip the other tests if this is not the first block
512 * size.
513 *
514  IF( inb.GT.1 )
515  $ go to 150
516 *
517 * Do only the condition estimate if INFO is not 0.
518 *
519  IF( trfcon ) THEN
520  rcondc = zero
521  go to 140
522  END IF
523 *
524  DO 130 irhs = 1, nns
525  nrhs = nsval( irhs )
526 *
527 *+ TEST 3 (Using TRS)
528 * Solve and compute residual for A * X = B.
529 *
530 * Choose a set of NRHS random solution vectors
531 * stored in XACT and set up the right hand side B
532 *
533  srnamt = 'ZLARHS'
534  CALL zlarhs( path, xtype, uplo, ' ', n, n, kl, ku,
535  $ nrhs, a, lda, xact, lda, b, lda,
536  $ iseed, info )
537  CALL zlacpy( 'Full', n, nrhs, b, lda, x, lda )
538 *
539  srnamt = 'ZSYTRS'
540  CALL zsytrs( uplo, n, nrhs, afac, lda, iwork, x,
541  $ lda, info )
542 *
543 * Check error code from ZSYTRS and handle error.
544 *
545  IF( info.NE.0 )
546  $ CALL alaerh( path, 'ZSYTRS', info, 0, uplo, n,
547  $ n, -1, -1, nrhs, imat, nfail,
548  $ nerrs, nout )
549 *
550  CALL zlacpy( 'Full', n, nrhs, b, lda, work, lda )
551 *
552 * Compute the residual for the solution
553 *
554  CALL zsyt02( uplo, n, nrhs, a, lda, x, lda, work,
555  $ lda, rwork, result( 3 ) )
556 *
557 *+ TEST 4 (Using TRS2)
558 * Solve and compute residual for A * X = B.
559 *
560 * Choose a set of NRHS random solution vectors
561 * stored in XACT and set up the right hand side B
562 *
563  srnamt = 'ZLARHS'
564  CALL zlarhs( path, xtype, uplo, ' ', n, n, kl, ku,
565  $ nrhs, a, lda, xact, lda, b, lda,
566  $ iseed, info )
567  CALL zlacpy( 'Full', n, nrhs, b, lda, x, lda )
568 *
569  srnamt = 'ZSYTRS2'
570  CALL zsytrs2( uplo, n, nrhs, afac, lda, iwork, x,
571  $ lda, work, info )
572 *
573 * Check error code from ZSYTRS2 and handle error.
574 *
575  IF( info.NE.0 )
576  $ CALL alaerh( path, 'ZSYTRS', info, 0, uplo, n,
577  $ n, -1, -1, nrhs, imat, nfail,
578  $ nerrs, nout )
579 *
580  CALL zlacpy( 'Full', n, nrhs, b, lda, work, lda )
581 *
582 * Compute the residual for the solution
583 *
584  CALL zsyt02( uplo, n, nrhs, a, lda, x, lda, work,
585  $ lda, rwork, result( 4 ) )
586 *
587 *
588 *+ TEST 5
589 * Check solution from generated exact solution.
590 *
591  CALL zget04( n, nrhs, x, lda, xact, lda, rcondc,
592  $ result( 5 ) )
593 *
594 *+ TESTS 6, 7, and 8
595 * Use iterative refinement to improve the solution.
596 *
597  srnamt = 'ZSYRFS'
598  CALL zsyrfs( uplo, n, nrhs, a, lda, afac, lda,
599  $ iwork, b, lda, x, lda, rwork,
600  $ rwork( nrhs+1 ), work,
601  $ rwork( 2*nrhs+1 ), info )
602 *
603 * Check error code from ZSYRFS and handle error.
604 *
605  IF( info.NE.0 )
606  $ CALL alaerh( path, 'ZSYRFS', info, 0, uplo, n,
607  $ n, -1, -1, nrhs, imat, nfail,
608  $ nerrs, nout )
609 *
610  CALL zget04( n, nrhs, x, lda, xact, lda, rcondc,
611  $ result( 6 ) )
612  CALL zpot05( uplo, n, nrhs, a, lda, b, lda, x, lda,
613  $ xact, lda, rwork, rwork( nrhs+1 ),
614  $ result( 7 ) )
615 *
616 * Print information about the tests that did not pass
617 * the threshold.
618 *
619  DO 120 k = 3, 8
620  IF( result( k ).GE.thresh ) THEN
621  IF( nfail.EQ.0 .AND. nerrs.EQ.0 )
622  $ CALL alahd( nout, path )
623  WRITE( nout, fmt = 9998 )uplo, n, nrhs,
624  $ imat, k, result( k )
625  nfail = nfail + 1
626  END IF
627  120 continue
628  nrun = nrun + 6
629  130 continue
630 *
631 *+ TEST 9
632 * Get an estimate of RCOND = 1/CNDNUM.
633 *
634  140 continue
635  anorm = zlansy( '1', uplo, n, a, lda, rwork )
636  srnamt = 'ZSYCON'
637  CALL zsycon( uplo, n, afac, lda, iwork, anorm, rcond,
638  $ work, info )
639 *
640 * Check error code from ZSYCON and handle error.
641 *
642  IF( info.NE.0 )
643  $ CALL alaerh( path, 'ZSYCON', info, 0, uplo, n, n,
644  $ -1, -1, -1, imat, nfail, nerrs, nout )
645 *
646 * Compute the test ratio to compare to values of RCOND
647 *
648  result( 9 ) = dget06( rcond, rcondc )
649 *
650 * Print information about the tests that did not pass
651 * the threshold.
652 *
653  IF( result( 9 ).GE.thresh ) THEN
654  IF( nfail.EQ.0 .AND. nerrs.EQ.0 )
655  $ CALL alahd( nout, path )
656  WRITE( nout, fmt = 9997 )uplo, n, imat, 9,
657  $ result( 9 )
658  nfail = nfail + 1
659  END IF
660  nrun = nrun + 1
661  150 continue
662  160 continue
663  170 continue
664  180 continue
665 *
666 * Print a summary of the results.
667 *
668  CALL alasum( path, nout, nfail, nrun, nerrs )
669 *
670  9999 format( ' UPLO = ''', a1, ''', N =', i5, ', NB =', i4, ', type ',
671  $ i2, ', test ', i2, ', ratio =', g12.5 )
672  9998 format( ' UPLO = ''', a1, ''', N =', i5, ', NRHS=', i3, ', type ',
673  $ i2, ', test(', i2, ') =', g12.5 )
674  9997 format( ' UPLO = ''', a1, ''', N =', i5, ',', 10x, ' type ', i2,
675  $ ', test(', i2, ') =', g12.5 )
676  return
677 *
678 * End of ZCHKSY
679 *
680  END