LAPACK  3.4.2
LAPACK: Linear Algebra PACKage
 All Files Functions Groups
cchkhe.f
Go to the documentation of this file.
1 *> \brief \b CCHKHE
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 CCHKHE( 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 *> CCHKHE tests CHETRF, -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(3,NSMAX))
140 *> \endverbatim
141 *>
142 *> \param[out] RWORK
143 *> \verbatim
144 *> RWORK is REAL array, dimension
145 *> (max(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 November 2011
168 *
169 *> \ingroup complex_lin
170 *
171 * =====================================================================
172  SUBROUTINE cchkhe( 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.0) --
177 * -- LAPACK is a software package provided by Univ. of Tennessee, --
178 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
179 * November 2011
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  INTEGER ntypes
200  parameter( ntypes = 10 )
201  INTEGER ntests
202  parameter( ntests = 9 )
203 * ..
204 * .. Local Scalars ..
205  LOGICAL trfcon, zerot
206  CHARACTER dist, type, uplo, xtype
207  CHARACTER*3 path
208  INTEGER i, i1, i2, imat, in, inb, info, ioff, irhs,
209  $ iuplo, izero, j, k, kl, ku, lda, lwork, mode,
210  $ n, nb, nerrs, nfail, nimat, nrhs, nrun, nt
211  REAL anorm, cndnum, rcond, rcondc
212 * ..
213 * .. Local Arrays ..
214  CHARACTER uplos( 2 )
215  INTEGER iseed( 4 ), iseedy( 4 )
216  REAL result( ntests )
217 * ..
218 * .. External Functions ..
219  REAL clanhe, sget06
220  EXTERNAL clanhe, sget06
221 * ..
222 * .. External Subroutines ..
223  EXTERNAL alaerh, alahd, alasum, cerrhe, cget04, checon,
226  $ cpot03, cpot05, xlaenv
227 * ..
228 * .. Intrinsic Functions ..
229  INTRINSIC max, min
230 * ..
231 * .. Scalars in Common ..
232  LOGICAL lerr, ok
233  CHARACTER*32 srnamt
234  INTEGER infot, nunit
235 * ..
236 * .. Common blocks ..
237  common / infoc / infot, nunit, ok, lerr
238  common / srnamc / srnamt
239 * ..
240 * .. Data statements ..
241  DATA iseedy / 1988, 1989, 1990, 1991 /
242  DATA uplos / 'U', 'L' /
243 * ..
244 * .. Executable Statements ..
245 *
246 * Initialize constants and the random number seed.
247 *
248  path( 1: 1 ) = 'Complex precision'
249  path( 2: 3 ) = 'HE'
250  nrun = 0
251  nfail = 0
252  nerrs = 0
253  DO 10 i = 1, 4
254  iseed( i ) = iseedy( i )
255  10 continue
256 *
257 * Test the error exits
258 *
259  IF( tsterr )
260  $ CALL cerrhe( path, nout )
261  infot = 0
262 *
263 * Do for each value of N in NVAL
264 *
265  DO 180 in = 1, nn
266  n = nval( in )
267  lda = max( n, 1 )
268  xtype = 'N'
269  nimat = ntypes
270  IF( n.LE.0 )
271  $ nimat = 1
272 *
273  izero = 0
274  DO 170 imat = 1, nimat
275 *
276 * Do the tests only if DOTYPE( IMAT ) is true.
277 *
278  IF( .NOT.dotype( imat ) )
279  $ go to 170
280 *
281 * Skip types 3, 4, 5, or 6 if the matrix size is too small.
282 *
283  zerot = imat.GE.3 .AND. imat.LE.6
284  IF( zerot .AND. n.LT.imat-2 )
285  $ go to 170
286 *
287 * Do first for UPLO = 'U', then for UPLO = 'L'
288 *
289  DO 160 iuplo = 1, 2
290  uplo = uplos( iuplo )
291 *
292 * Set up parameters with CLATB4 and generate a test matrix
293 * with CLATMS.
294 *
295  CALL clatb4( path, imat, n, n, type, kl, ku, anorm, mode,
296  $ cndnum, dist )
297 *
298  srnamt = 'CLATMS'
299  CALL clatms( n, n, dist, iseed, type, rwork, mode,
300  $ cndnum, anorm, kl, ku, uplo, a, lda, work,
301  $ info )
302 *
303 * Check error code from CLATMS.
304 *
305  IF( info.NE.0 ) THEN
306  CALL alaerh( path, 'CLATMS', info, 0, uplo, n, n, -1,
307  $ -1, -1, imat, nfail, nerrs, nout )
308  go to 160
309  END IF
310 *
311 * For types 3-6, zero one or more rows and columns of
312 * the matrix to test that INFO is returned correctly.
313 *
314  IF( zerot ) THEN
315  IF( imat.EQ.3 ) THEN
316  izero = 1
317  ELSE IF( imat.EQ.4 ) THEN
318  izero = n
319  ELSE
320  izero = n / 2 + 1
321  END IF
322 *
323  IF( imat.LT.6 ) THEN
324 *
325 * Set row and column IZERO to zero.
326 *
327  IF( iuplo.EQ.1 ) THEN
328  ioff = ( izero-1 )*lda
329  DO 20 i = 1, izero - 1
330  a( ioff+i ) = zero
331  20 continue
332  ioff = ioff + izero
333  DO 30 i = izero, n
334  a( ioff ) = zero
335  ioff = ioff + lda
336  30 continue
337  ELSE
338  ioff = izero
339  DO 40 i = 1, izero - 1
340  a( ioff ) = zero
341  ioff = ioff + lda
342  40 continue
343  ioff = ioff - izero
344  DO 50 i = izero, n
345  a( ioff+i ) = zero
346  50 continue
347  END IF
348  ELSE
349  ioff = 0
350  IF( iuplo.EQ.1 ) THEN
351 *
352 * Set the first IZERO rows and columns to zero.
353 *
354  DO 70 j = 1, n
355  i2 = min( j, izero )
356  DO 60 i = 1, i2
357  a( ioff+i ) = zero
358  60 continue
359  ioff = ioff + lda
360  70 continue
361  ELSE
362 *
363 * Set the last IZERO rows and columns to zero.
364 *
365  DO 90 j = 1, n
366  i1 = max( j, izero )
367  DO 80 i = i1, n
368  a( ioff+i ) = zero
369  80 continue
370  ioff = ioff + lda
371  90 continue
372  END IF
373  END IF
374  ELSE
375  izero = 0
376  END IF
377 *
378 * Set the imaginary part of the diagonals.
379 *
380  CALL claipd( n, a, lda+1, 0 )
381 *
382 * Do for each value of NB in NBVAL
383 *
384  DO 150 inb = 1, nnb
385  nb = nbval( inb )
386  CALL xlaenv( 1, nb )
387 *
388 * Compute the L*D*L' or U*D*U' factorization of the
389 * matrix.
390 *
391  CALL clacpy( uplo, n, n, a, lda, afac, lda )
392  lwork = max( 2, nb )*lda
393  srnamt = 'CHETRF'
394  CALL chetrf( uplo, n, afac, lda, iwork, ainv, lwork,
395  $ info )
396 *
397 * Adjust the expected value of INFO to account for
398 * pivoting.
399 *
400  k = izero
401  IF( k.GT.0 ) THEN
402  100 continue
403  IF( iwork( k ).LT.0 ) THEN
404  IF( iwork( k ).NE.-k ) THEN
405  k = -iwork( k )
406  go to 100
407  END IF
408  ELSE IF( iwork( k ).NE.k ) THEN
409  k = iwork( k )
410  go to 100
411  END IF
412  END IF
413 *
414 * Check error code from CHETRF.
415 *
416  IF( info.NE.k )
417  $ CALL alaerh( path, 'CHETRF', info, k, uplo, n, n,
418  $ -1, -1, nb, imat, nfail, nerrs, nout )
419  IF( info.NE.0 ) THEN
420  trfcon = .true.
421  ELSE
422  trfcon = .false.
423  END IF
424 *
425 *+ TEST 1
426 * Reconstruct matrix from factors and compute residual.
427 *
428  CALL chet01( uplo, n, a, lda, afac, lda, iwork, ainv,
429  $ lda, rwork, result( 1 ) )
430  nt = 1
431 *
432 *+ TEST 2
433 * Form the inverse and compute the residual.
434 *
435  IF( inb.EQ.1 .AND. .NOT.trfcon ) THEN
436  CALL clacpy( uplo, n, n, afac, lda, ainv, lda )
437  srnamt = 'CHETRI2'
438  lwork = (n+nb+1)*(nb+3)
439  CALL chetri2( uplo, n, ainv, lda, iwork, work,
440  $ lwork, info )
441 *
442 * Check error code from CHETRI.
443 *
444  IF( info.NE.0 )
445  $ CALL alaerh( path, 'CHETRI', info, -1, uplo, n,
446  $ n, -1, -1, -1, imat, nfail, nerrs,
447  $ nout )
448 *
449  CALL cpot03( uplo, n, a, lda, ainv, lda, work, lda,
450  $ rwork, rcondc, result( 2 ) )
451  nt = 2
452  END IF
453 *
454 * Print information about the tests that did not pass
455 * the threshold.
456 *
457  DO 110 k = 1, nt
458  IF( result( k ).GE.thresh ) THEN
459  IF( nfail.EQ.0 .AND. nerrs.EQ.0 )
460  $ CALL alahd( nout, path )
461  WRITE( nout, fmt = 9999 )uplo, n, nb, imat, k,
462  $ result( k )
463  nfail = nfail + 1
464  END IF
465  110 continue
466  nrun = nrun + nt
467 *
468 * Skip the other tests if this is not the first block
469 * size.
470 *
471  IF( inb.GT.1 )
472  $ go to 150
473 *
474 * Do only the condition estimate if INFO is not 0.
475 *
476  IF( trfcon ) THEN
477  rcondc = zero
478  go to 140
479  END IF
480 *
481  DO 130 irhs = 1, nns
482  nrhs = nsval( irhs )
483 *
484 *+ TEST 3
485 * Solve and compute residual for A * X = B.
486 *
487  srnamt = 'CLARHS'
488  CALL clarhs( path, xtype, uplo, ' ', n, n, kl, ku,
489  $ nrhs, a, lda, xact, lda, b, lda,
490  $ iseed, info )
491  CALL clacpy( 'Full', n, nrhs, b, lda, x, lda )
492 *
493  srnamt = 'CHETRS'
494  CALL chetrs( uplo, n, nrhs, afac, lda, iwork, x,
495  $ lda, info )
496 *
497 * Check error code from CHETRS.
498 *
499  IF( info.NE.0 )
500  $ CALL alaerh( path, 'CHETRS', info, 0, uplo, n,
501  $ n, -1, -1, nrhs, imat, nfail,
502  $ nerrs, nout )
503 *
504  CALL clacpy( 'Full', n, nrhs, b, lda, work, lda )
505  CALL cpot02( uplo, n, nrhs, a, lda, x, lda, work,
506  $ lda, rwork, result( 3 ) )
507 *
508 *+ TEST 4
509 * Solve and compute residual for A * X = B.
510 *
511  srnamt = 'CLARHS'
512  CALL clarhs( path, xtype, uplo, ' ', n, n, kl, ku,
513  $ nrhs, a, lda, xact, lda, b, lda,
514  $ iseed, info )
515  CALL clacpy( 'Full', n, nrhs, b, lda, x, lda )
516 *
517  srnamt = 'CHETRS2'
518  CALL chetrs2( uplo, n, nrhs, afac, lda, iwork, x,
519  $ lda, work, info )
520 *
521 * Check error code from CHETRS2.
522 *
523  IF( info.NE.0 )
524  $ CALL alaerh( path, 'CHETRS2', info, 0, uplo, n,
525  $ n, -1, -1, nrhs, imat, nfail,
526  $ nerrs, nout )
527 *
528  CALL clacpy( 'Full', n, nrhs, b, lda, work, lda )
529  CALL cpot02( uplo, n, nrhs, a, lda, x, lda, work,
530  $ lda, rwork, result( 4 ) )
531 *
532 *+ TEST 5
533 * Check solution from generated exact solution.
534 *
535  CALL cget04( n, nrhs, x, lda, xact, lda, rcondc,
536  $ result( 5 ) )
537 *
538 *+ TESTS 6, 7, and 8
539 * Use iterative refinement to improve the solution.
540 *
541  srnamt = 'CHERFS'
542  CALL cherfs( uplo, n, nrhs, a, lda, afac, lda,
543  $ iwork, b, lda, x, lda, rwork,
544  $ rwork( nrhs+1 ), work,
545  $ rwork( 2*nrhs+1 ), info )
546 *
547 * Check error code from CHERFS.
548 *
549  IF( info.NE.0 )
550  $ CALL alaerh( path, 'CHERFS', info, 0, uplo, n,
551  $ n, -1, -1, nrhs, imat, nfail,
552  $ nerrs, nout )
553 *
554  CALL cget04( n, nrhs, x, lda, xact, lda, rcondc,
555  $ result( 6 ) )
556  CALL cpot05( uplo, n, nrhs, a, lda, b, lda, x, lda,
557  $ xact, lda, rwork, rwork( nrhs+1 ),
558  $ result( 7 ) )
559 *
560 * Print information about the tests that did not pass
561 * the threshold.
562 *
563  DO 120 k = 3, 8
564  IF( result( k ).GE.thresh ) THEN
565  IF( nfail.EQ.0 .AND. nerrs.EQ.0 )
566  $ CALL alahd( nout, path )
567  WRITE( nout, fmt = 9998 )uplo, n, nrhs,
568  $ imat, k, result( k )
569  nfail = nfail + 1
570  END IF
571  120 continue
572  nrun = nrun + 5
573  130 continue
574 *
575 *+ TEST 9
576 * Get an estimate of RCOND = 1/CNDNUM.
577 *
578  140 continue
579  anorm = clanhe( '1', uplo, n, a, lda, rwork )
580  srnamt = 'CHECON'
581  CALL checon( uplo, n, afac, lda, iwork, anorm, rcond,
582  $ work, info )
583 *
584 * Check error code from CHECON.
585 *
586  IF( info.NE.0 )
587  $ CALL alaerh( path, 'CHECON', info, 0, uplo, n, n,
588  $ -1, -1, -1, imat, nfail, nerrs, nout )
589 *
590  result( 9 ) = sget06( rcond, rcondc )
591 *
592 * Print information about the tests that did not pass
593 * the threshold.
594 *
595  IF( result( 9 ).GE.thresh ) THEN
596  IF( nfail.EQ.0 .AND. nerrs.EQ.0 )
597  $ CALL alahd( nout, path )
598  WRITE( nout, fmt = 9997 )uplo, n, imat, 8,
599  $ result( 9 )
600  nfail = nfail + 1
601  END IF
602  nrun = nrun + 1
603  150 continue
604  160 continue
605  170 continue
606  180 continue
607 *
608 * Print a summary of the results.
609 *
610  CALL alasum( path, nout, nfail, nrun, nerrs )
611 *
612  9999 format( ' UPLO = ''', a1, ''', N =', i5, ', NB =', i4, ', type ',
613  $ i2, ', test ', i2, ', ratio =', g12.5 )
614  9998 format( ' UPLO = ''', a1, ''', N =', i5, ', NRHS=', i3, ', type ',
615  $ i2, ', test(', i2, ') =', g12.5 )
616  9997 format( ' UPLO = ''', a1, ''', N =', i5, ',', 10x, ' type ', i2,
617  $ ', test(', i2, ') =', g12.5 )
618  return
619 *
620 * End of CCHKHE
621 *
622  END