LAPACK  3.4.2
LAPACK: Linear Algebra PACKage
 All Files Functions Groups
cchksy.f
Go to the documentation of this file.
1 *> \brief \b CCHKSY
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 CCHKSY( 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 * REAL THRESH
19 * ..
20 * .. Array Arguments ..
21 * LOGICAL DOTYPE( * )
22 * INTEGER IWORK( * ), NBVAL( * ), NSVAL( * ), NVAL( * )
23 * REAL RWORK( * )
24 * COMPLEX A( * ), AFAC( * ), AINV( * ), B( * ),
25 * $ WORK( * ), X( * ), XACT( * )
26 * ..
27 *
28 *
29 *> \par Purpose:
30 * =============
31 *>
32 *> \verbatim
33 *>
34 *> CCHKSY tests CSYTRF, -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 REAL
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 array, dimension (NMAX*NMAX)
108 *> \endverbatim
109 *>
110 *> \param[out] AFAC
111 *> \verbatim
112 *> AFAC is COMPLEX array, dimension (NMAX*NMAX)
113 *> \endverbatim
114 *>
115 *> \param[out] AINV
116 *> \verbatim
117 *> AINV is COMPLEX array, dimension (NMAX*NMAX)
118 *> \endverbatim
119 *>
120 *> \param[out] B
121 *> \verbatim
122 *> B is COMPLEX 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 array, dimension (NMAX*NSMAX)
129 *> \endverbatim
130 *>
131 *> \param[out] XACT
132 *> \verbatim
133 *> XACT is COMPLEX array, dimension (NMAX*NSMAX)
134 *> \endverbatim
135 *>
136 *> \param[out] WORK
137 *> \verbatim
138 *> WORK is COMPLEX array, dimension
139 *> (NMAX*max(2,NSMAX))
140 *> \endverbatim
141 *>
142 *> \param[out] RWORK
143 *> \verbatim
144 *> RWORK is REAL 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 complex_lin
170 *
171 * =====================================================================
172  SUBROUTINE cchksy( 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  REAL thresh
185 * ..
186 * .. Array Arguments ..
187  LOGICAL dotype( * )
188  INTEGER iwork( * ), nbval( * ), nsval( * ), nval( * )
189  REAL rwork( * )
190  COMPLEX a( * ), afac( * ), ainv( * ), b( * ),
191  $ work( * ), x( * ), xact( * )
192 * ..
193 *
194 * =====================================================================
195 *
196 * .. Parameters ..
197  REAL zero
198  parameter( zero = 0.0e+0 )
199  COMPLEX czero
200  parameter( czero = ( 0.0e+0, 0.0e+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  REAL anorm, cndnum, rcond, rcondc
214 * ..
215 * .. Local Arrays ..
216  CHARACTER uplos( 2 )
217  INTEGER iseed( 4 ), iseedy( 4 )
218  REAL result( ntests )
219 * ..
220 * .. External Functions ..
221  REAL sget06, clansy
222  EXTERNAL sget06, clansy
223 * ..
224 * .. External Subroutines ..
225  EXTERNAL alaerh, alahd, alasum, cerrsy, cget04, clacpy,
228  $ csytri2, csytrs, xlaenv
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 ) = 'Complex 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 cerrsy( 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 * Begin generate the test matrix A.
305 *
306 * Set up parameters with CLATB4 for the matrix generator
307 * based on the type of matrix to be generated.
308 *
309  CALL clatb4( path, imat, n, n, type, kl, ku, anorm,
310  $ mode, cndnum, dist )
311 *
312 * Generate a matrix with CLATMS.
313 *
314  srnamt = 'CLATMS'
315  CALL clatms( n, n, dist, iseed, type, rwork, mode,
316  $ cndnum, anorm, kl, ku, 'N', a, lda, work,
317  $ info )
318 *
319 * Check error code from CLATMS and handle error.
320 *
321  IF( info.NE.0 ) THEN
322  CALL alaerh( path, 'CLATMS', info, 0, uplo, n, n,
323  $ -1, -1, -1, imat, nfail, nerrs, nout )
324  go to 160
325  END IF
326 *
327 * For matrix types 3-6, zero one or more rows and
328 * columns of the matrix to test that INFO is returned
329 * correctly.
330 *
331  IF( zerot ) THEN
332  IF( imat.EQ.3 ) THEN
333  izero = 1
334  ELSE IF( imat.EQ.4 ) THEN
335  izero = n
336  ELSE
337  izero = n / 2 + 1
338  END IF
339 *
340  IF( imat.LT.6 ) THEN
341 *
342 * Set row and column IZERO to zero.
343 *
344  IF( iuplo.EQ.1 ) THEN
345  ioff = ( izero-1 )*lda
346  DO 20 i = 1, izero - 1
347  a( ioff+i ) = czero
348  20 continue
349  ioff = ioff + izero
350  DO 30 i = izero, n
351  a( ioff ) = czero
352  ioff = ioff + lda
353  30 continue
354  ELSE
355  ioff = izero
356  DO 40 i = 1, izero - 1
357  a( ioff ) = czero
358  ioff = ioff + lda
359  40 continue
360  ioff = ioff - izero
361  DO 50 i = izero, n
362  a( ioff+i ) = czero
363  50 continue
364  END IF
365  ELSE
366  IF( iuplo.EQ.1 ) THEN
367 *
368 * Set the first IZERO rows to zero.
369 *
370  ioff = 0
371  DO 70 j = 1, n
372  i2 = min( j, izero )
373  DO 60 i = 1, i2
374  a( ioff+i ) = czero
375  60 continue
376  ioff = ioff + lda
377  70 continue
378  ELSE
379 *
380 * Set the last IZERO rows to zero.
381 *
382  ioff = 0
383  DO 90 j = 1, n
384  i1 = max( j, izero )
385  DO 80 i = i1, n
386  a( ioff+i ) = czero
387  80 continue
388  ioff = ioff + lda
389  90 continue
390  END IF
391  END IF
392  ELSE
393  izero = 0
394  END IF
395 *
396 * End generate the test matrix A.
397 *
398  ELSE
399 *
400 * Use a special block diagonal matrix to test alternate
401 * code for the 2 x 2 blocks.
402 *
403  CALL clatsy( uplo, n, a, lda, iseed )
404 *
405  END IF
406 *
407 * Do for each value of NB in NBVAL
408 *
409  DO 150 inb = 1, nnb
410 *
411 * Set the optimal blocksize, which will be later
412 * returned by ILAENV.
413 *
414  nb = nbval( inb )
415  CALL xlaenv( 1, nb )
416 *
417 * Copy the test matrix A into matrix AFAC which
418 * will be factorized in place. This is needed to
419 * preserve the test matrix A for subsequent tests.
420 *
421  CALL clacpy( uplo, n, n, a, lda, afac, lda )
422 *
423 * Compute the L*D*L**T or U*D*U**T factorization of the
424 * matrix. IWORK stores details of the interchanges and
425 * the block structure of D. AINV is a work array for
426 * block factorization, LWORK is the length of AINV.
427 *
428  lwork = max( 2, nb )*lda
429  srnamt = 'CSYTRF'
430  CALL csytrf( uplo, n, afac, lda, iwork, ainv, lwork,
431  $ info )
432 *
433 * Adjust the expected value of INFO to account for
434 * pivoting.
435 *
436  k = izero
437  IF( k.GT.0 ) THEN
438  100 continue
439  IF( iwork( k ).LT.0 ) THEN
440  IF( iwork( k ).NE.-k ) THEN
441  k = -iwork( k )
442  go to 100
443  END IF
444  ELSE IF( iwork( k ).NE.k ) THEN
445  k = iwork( k )
446  go to 100
447  END IF
448  END IF
449 *
450 * Check error code from CSYTRF and handle error.
451 *
452  IF( info.NE.k )
453  $ CALL alaerh( path, 'CSYTRF', info, k, uplo, n, n,
454  $ -1, -1, nb, imat, nfail, nerrs, nout )
455 *
456 * Set the condition estimate flag if the INFO is not 0.
457 *
458  IF( info.NE.0 ) THEN
459  trfcon = .true.
460  ELSE
461  trfcon = .false.
462  END IF
463 *
464 *+ TEST 1
465 * Reconstruct matrix from factors and compute residual.
466 *
467  CALL csyt01( uplo, n, a, lda, afac, lda, iwork, ainv,
468  $ lda, rwork, result( 1 ) )
469  nt = 1
470 *
471 *+ TEST 2
472 * Form the inverse and compute the residual,
473 * if the factorization was competed without INFO > 0
474 * (i.e. there is no zero rows and columns).
475 * Do it only for the first block size.
476 *
477  IF( inb.EQ.1 .AND. .NOT.trfcon ) THEN
478  CALL clacpy( uplo, n, n, afac, lda, ainv, lda )
479  srnamt = 'CSYTRI2'
480  lwork = (n+nb+1)*(nb+3)
481  CALL csytri2( uplo, n, ainv, lda, iwork, work,
482  $ lwork, info )
483 *
484 * Check error code from CSYTRI2 and handle error.
485 *
486  IF( info.NE.0 )
487  $ CALL alaerh( path, 'CSYTRI2', info, 0, uplo, n,
488  $ n, -1, -1, -1, imat, nfail, nerrs,
489  $ nout )
490 *
491 * Compute the residual for a symmetric matrix times
492 * its inverse.
493 *
494  CALL csyt03( uplo, n, a, lda, ainv, lda, work, lda,
495  $ rwork, rcondc, result( 2 ) )
496  nt = 2
497  END IF
498 *
499 * Print information about the tests that did not pass
500 * the threshold.
501 *
502  DO 110 k = 1, nt
503  IF( result( k ).GE.thresh ) THEN
504  IF( nfail.EQ.0 .AND. nerrs.EQ.0 )
505  $ CALL alahd( nout, path )
506  WRITE( nout, fmt = 9999 )uplo, n, nb, imat, k,
507  $ result( k )
508  nfail = nfail + 1
509  END IF
510  110 continue
511  nrun = nrun + nt
512 *
513 * Skip the other tests if this is not the first block
514 * size.
515 *
516  IF( inb.GT.1 )
517  $ go to 150
518 *
519 * Do only the condition estimate if INFO is not 0.
520 *
521  IF( trfcon ) THEN
522  rcondc = zero
523  go to 140
524  END IF
525 *
526  DO 130 irhs = 1, nns
527  nrhs = nsval( irhs )
528 *
529 *+ TEST 3 (Using TRS)
530 * Solve and compute residual for A * X = B.
531 *
532 * Choose a set of NRHS random solution vectors
533 * stored in XACT and set up the right hand side B
534 *
535  srnamt = 'CLARHS'
536  CALL clarhs( path, xtype, uplo, ' ', n, n, kl, ku,
537  $ nrhs, a, lda, xact, lda, b, lda,
538  $ iseed, info )
539  CALL clacpy( 'Full', n, nrhs, b, lda, x, lda )
540 *
541  srnamt = 'CSYTRS'
542  CALL csytrs( uplo, n, nrhs, afac, lda, iwork, x,
543  $ lda, info )
544 *
545 * Check error code from CSYTRS and handle error.
546 *
547  IF( info.NE.0 )
548  $ CALL alaerh( path, 'CSYTRS', info, 0, uplo, n,
549  $ n, -1, -1, nrhs, imat, nfail,
550  $ nerrs, nout )
551 *
552  CALL clacpy( 'Full', n, nrhs, b, lda, work, lda )
553 *
554 * Compute the residual for the solution
555 *
556  CALL csyt02( uplo, n, nrhs, a, lda, x, lda, work,
557  $ lda, rwork, result( 3 ) )
558 *
559 *+ TEST 4 (Using TRS2)
560 * Solve and compute residual for A * X = B.
561 *
562 * Choose a set of NRHS random solution vectors
563 * stored in XACT and set up the right hand side B
564 *
565  srnamt = 'CLARHS'
566  CALL clarhs( path, xtype, uplo, ' ', n, n, kl, ku,
567  $ nrhs, a, lda, xact, lda, b, lda,
568  $ iseed, info )
569  CALL clacpy( 'Full', n, nrhs, b, lda, x, lda )
570 *
571  srnamt = 'CSYTRS2'
572  CALL csytrs2( uplo, n, nrhs, afac, lda, iwork, x,
573  $ lda, work, info )
574 *
575 * Check error code from CSYTRS2 and handle error.
576 *
577  IF( info.NE.0 )
578  $ CALL alaerh( path, 'CSYTRS2', info, 0, uplo, n,
579  $ n, -1, -1, nrhs, imat, nfail,
580  $ nerrs, nout )
581 *
582  CALL clacpy( 'Full', n, nrhs, b, lda, work, lda )
583 *
584 * Compute the residual for the solution
585 *
586  CALL csyt02( uplo, n, nrhs, a, lda, x, lda, work,
587  $ lda, rwork, result( 4 ) )
588 *
589 *+ TEST 5
590 * Check solution from generated exact solution.
591 *
592  CALL cget04( n, nrhs, x, lda, xact, lda, rcondc,
593  $ result( 5 ) )
594 *
595 *+ TESTS 6, 7, and 8
596 * Use iterative refinement to improve the solution.
597 *
598  srnamt = 'CSYRFS'
599  CALL csyrfs( uplo, n, nrhs, a, lda, afac, lda,
600  $ iwork, b, lda, x, lda, rwork,
601  $ rwork( nrhs+1 ), work,
602  $ rwork( 2*nrhs+1 ), info )
603 *
604 * Check error code from CSYRFS.
605 *
606  IF( info.NE.0 )
607  $ CALL alaerh( path, 'CSYRFS', info, 0, uplo, n,
608  $ n, -1, -1, nrhs, imat, nfail,
609  $ nerrs, nout )
610 *
611  CALL cget04( n, nrhs, x, lda, xact, lda, rcondc,
612  $ result( 6 ) )
613  CALL cpot05( uplo, n, nrhs, a, lda, b, lda, x, lda,
614  $ xact, lda, rwork, rwork( nrhs+1 ),
615  $ result( 7 ) )
616 *
617 * Print information about the tests that did not pass
618 * the threshold.
619 *
620  DO 120 k = 3, 8
621  IF( result( k ).GE.thresh ) THEN
622  IF( nfail.EQ.0 .AND. nerrs.EQ.0 )
623  $ CALL alahd( nout, path )
624  WRITE( nout, fmt = 9998 )uplo, n, nrhs,
625  $ imat, k, result( k )
626  nfail = nfail + 1
627  END IF
628  120 continue
629  nrun = nrun + 6
630  130 continue
631 *
632 *+ TEST 9
633 * Get an estimate of RCOND = 1/CNDNUM.
634 *
635  140 continue
636  anorm = clansy( '1', uplo, n, a, lda, rwork )
637  srnamt = 'CSYCON'
638  CALL csycon( uplo, n, afac, lda, iwork, anorm, rcond,
639  $ work, info )
640 *
641 * Check error code from CSYCON and handle error.
642 *
643  IF( info.NE.0 )
644  $ CALL alaerh( path, 'CSYCON', info, 0, uplo, n, n,
645  $ -1, -1, -1, imat, nfail, nerrs, nout )
646 *
647 * Compute the test ratio to compare to values of RCOND
648 *
649  result( 9 ) = sget06( rcond, rcondc )
650 *
651 * Print information about the tests that did not pass
652 * the threshold.
653 *
654  IF( result( 9 ).GE.thresh ) THEN
655  IF( nfail.EQ.0 .AND. nerrs.EQ.0 )
656  $ CALL alahd( nout, path )
657  WRITE( nout, fmt = 9997 )uplo, n, imat, 9,
658  $ result( 9 )
659  nfail = nfail + 1
660  END IF
661  nrun = nrun + 1
662  150 continue
663  160 continue
664  170 continue
665  180 continue
666 *
667 * Print a summary of the results.
668 *
669  CALL alasum( path, nout, nfail, nrun, nerrs )
670 *
671  9999 format( ' UPLO = ''', a1, ''', N =', i5, ', NB =', i4, ', type ',
672  $ i2, ', test ', i2, ', ratio =', g12.5 )
673  9998 format( ' UPLO = ''', a1, ''', N =', i5, ', NRHS=', i3, ', type ',
674  $ i2, ', test(', i2, ') =', g12.5 )
675  9997 format( ' UPLO = ''', a1, ''', N =', i5, ',', 10x, ' type ', i2,
676  $ ', test(', i2, ') =', g12.5 )
677  return
678 *
679 * End of CCHKSY
680 *
681  END