LAPACK  3.8.0
LAPACK: Linear Algebra PACKage
cchkhe_aa.f
Go to the documentation of this file.
1 *> \brief \b CCHKHE_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 CCHKHE_AA( 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 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_AA tests CHETRF_AA, -TRS_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] 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 (NMAX*max(3,NSMAX))
139 *> \endverbatim
140 *>
141 *> \param[out] RWORK
142 *> \verbatim
143 *> RWORK is REAL array, dimension (max(NMAX,2*NSMAX))
144 *> \endverbatim
145 *>
146 *> \param[out] IWORK
147 *> \verbatim
148 *> IWORK is INTEGER array, dimension (NMAX)
149 *> \endverbatim
150 *>
151 *> \param[in] NOUT
152 *> \verbatim
153 *> NOUT is INTEGER
154 *> The unit number for output.
155 *> \endverbatim
156 *
157 * Authors:
158 * ========
159 *
160 *> \author Univ. of Tennessee
161 *> \author Univ. of California Berkeley
162 *> \author Univ. of Colorado Denver
163 *> \author NAG Ltd.
164 *
165 *> \date November 2017
166 *
167 *
168 *> \ingroup complex_lin
169 *
170 * =====================================================================
171  SUBROUTINE cchkhe_aa( DOTYPE, NN, NVAL, NNB, NBVAL, NNS, NSVAL,
172  $ THRESH, TSTERR, NMAX, A, AFAC, AINV, B,
173  $ X, XACT, WORK, RWORK, IWORK, NOUT )
174 *
175 * -- LAPACK test routine (version 3.8.0) --
176 * -- LAPACK is a software package provided by Univ. of Tennessee, --
177 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
178 * November 2017
179 *
180  IMPLICIT NONE
181 *
182 * .. Scalar Arguments ..
183  LOGICAL TSTERR
184  INTEGER NMAX, NN, NNB, NNS, NOUT
185  REAL THRESH
186 * ..
187 * .. Array Arguments ..
188  LOGICAL DOTYPE( * )
189  INTEGER IWORK( * ), NBVAL( * ), NSVAL( * ), NVAL( * )
190  REAL RWORK( * )
191  COMPLEX A( * ), AFAC( * ), AINV( * ), B( * ),
192  $ work( * ), x( * ), xact( * )
193 * ..
194 *
195 * =====================================================================
196 *
197 * .. Parameters ..
198  REAL ZERO
199  parameter( zero = 0.0e+0 )
200  COMPLEX CZERO
201  parameter( czero = ( 0.0e+0, 0.0e+0 ) )
202  INTEGER NTYPES
203  parameter( ntypes = 10 )
204  INTEGER NTESTS
205  parameter( ntests = 9 )
206 * ..
207 * .. Local Scalars ..
208  LOGICAL ZEROT
209  CHARACTER DIST, TYPE, UPLO, XTYPE
210  CHARACTER*3 PATH, MATPATH
211  INTEGER I, I1, I2, IMAT, IN, INB, INFO, IOFF, IRHS,
212  $ iuplo, izero, j, k, kl, ku, lda, lwork, mode,
213  $ n, nb, nerrs, nfail, nimat, nrhs, nrun, nt
214  REAL ANORM, CNDNUM
215 * ..
216 * .. Local Arrays ..
217  CHARACTER UPLOS( 2 )
218  INTEGER ISEED( 4 ), ISEEDY( 4 )
219  REAL RESULT( ntests )
220 * ..
221 * .. External Subroutines ..
222  EXTERNAL alaerh, alahd, alasum, xlaenv, cerrhe, chet01_aa,
224  $ clatb4, clatms, cpot02
225 * ..
226 * .. Intrinsic Functions ..
227  INTRINSIC max, min
228 * ..
229 * .. Scalars in Common ..
230  LOGICAL LERR, OK
231  CHARACTER*32 SRNAMT
232  INTEGER INFOT, NUNIT
233 * ..
234 * .. Common blocks ..
235  COMMON / infoc / infot, nunit, ok, lerr
236  COMMON / srnamc / srnamt
237 * ..
238 * .. Data statements ..
239  DATA iseedy / 1988, 1989, 1990, 1991 /
240  DATA uplos / 'U', 'L' /
241 * ..
242 * .. Executable Statements ..
243 *
244 * Initialize constants and the random number seed.
245 *
246 *
247 * Test path
248 *
249  path( 1: 1 ) = 'Complex precision'
250  path( 2: 3 ) = 'HA'
251 *
252 * Path to generate matrices
253 *
254  matpath( 1: 1 ) = 'Complex precision'
255  matpath( 2: 3 ) = 'HE'
256  nrun = 0
257  nfail = 0
258  nerrs = 0
259  DO 10 i = 1, 4
260  iseed( i ) = iseedy( i )
261  10 CONTINUE
262 *
263 * Test the error exits
264 *
265  IF( tsterr )
266  $ CALL cerrhe( path, nout )
267  infot = 0
268 *
269 * Set the minimum block size for which the block routine should
270 * be used, which will be later returned by ILAENV
271 *
272  CALL xlaenv( 2, 2 )
273 *
274 * Do for each value of N in NVAL
275 *
276  DO 180 in = 1, nn
277  n = nval( in )
278  IF( n .GT. nmax ) THEN
279  nfail = nfail + 1
280  WRITE(nout, 9995) 'M ', n, nmax
281  GO TO 180
282  END IF
283  lda = max( n, 1 )
284  xtype = 'N'
285  nimat = ntypes
286  IF( n.LE.0 )
287  $ nimat = 1
288 *
289  izero = 0
290  DO 170 imat = 1, nimat
291 *
292 * Do the tests only if DOTYPE( IMAT ) is true.
293 *
294  IF( .NOT.dotype( imat ) )
295  $ GO TO 170
296 *
297 * Skip types 3, 4, 5, or 6 if the matrix size is too small.
298 *
299  zerot = imat.GE.3 .AND. imat.LE.6
300  IF( zerot .AND. n.LT.imat-2 )
301  $ GO TO 170
302 *
303 * Do first for UPLO = 'U', then for UPLO = 'L'
304 *
305  DO 160 iuplo = 1, 2
306  uplo = uplos( iuplo )
307 *
308 * Set up parameters with CLATB4 for the matrix generator
309 * based on the type of matrix to be generated.
310 *
311  CALL clatb4( matpath, imat, n, n, TYPE, KL, KU,
312  $ anorm, mode, cndnum, dist )
313 *
314 * Generate a matrix with CLATMS.
315 *
316  srnamt = 'CLATMS'
317  CALL clatms( n, n, dist, iseed, TYPE, RWORK, MODE,
318  $ cndnum, anorm, kl, ku, uplo, a, lda, work,
319  $ info )
320 *
321 * Check error code from CLATMS and handle error.
322 *
323  IF( info.NE.0 ) THEN
324  CALL alaerh( path, 'CLATMS', info, 0, uplo, n, n, -1,
325  $ -1, -1, imat, nfail, nerrs, nout )
326 *
327 * Skip all tests for this generated matrix
328 *
329  GO TO 160
330  END IF
331 *
332 * For types 3-6, zero one or more rows and columns of
333 * the matrix to test that INFO is returned correctly.
334 *
335  IF( zerot ) THEN
336  IF( imat.EQ.3 ) THEN
337  izero = 1
338  ELSE IF( imat.EQ.4 ) THEN
339  izero = n
340  ELSE
341  izero = n / 2 + 1
342  END IF
343 *
344  IF( imat.LT.6 ) THEN
345 *
346 * Set row and column IZERO to zero.
347 *
348  IF( iuplo.EQ.1 ) THEN
349  ioff = ( izero-1 )*lda
350  DO 20 i = 1, izero - 1
351  a( ioff+i ) = czero
352  20 CONTINUE
353  ioff = ioff + izero
354  DO 30 i = izero, n
355  a( ioff ) = czero
356  ioff = ioff + lda
357  30 CONTINUE
358  ELSE
359  ioff = izero
360  DO 40 i = 1, izero - 1
361  a( ioff ) = czero
362  ioff = ioff + lda
363  40 CONTINUE
364  ioff = ioff - izero
365  DO 50 i = izero, n
366  a( ioff+i ) = czero
367  50 CONTINUE
368  END IF
369  ELSE
370  IF( iuplo.EQ.1 ) THEN
371 *
372 * Set the first IZERO rows and columns to zero.
373 *
374  ioff = 0
375  DO 70 j = 1, n
376  i2 = min( j, izero )
377  DO 60 i = 1, i2
378  a( ioff+i ) = czero
379  60 CONTINUE
380  ioff = ioff + lda
381  70 CONTINUE
382  izero = 1
383  ELSE
384 *
385 * Set the last IZERO rows and columns to zero.
386 *
387  ioff = 0
388  DO 90 j = 1, n
389  i1 = max( j, izero )
390  DO 80 i = i1, n
391  a( ioff+i ) = czero
392  80 CONTINUE
393  ioff = ioff + lda
394  90 CONTINUE
395  END IF
396  END IF
397  ELSE
398  izero = 0
399  END IF
400 *
401 * End generate test matrix A.
402 *
403 *
404 * Set the imaginary part of the diagonals.
405 *
406  CALL claipd( n, a, lda+1, 0 )
407 *
408 * Do for each value of NB in NBVAL
409 *
410  DO 150 inb = 1, nnb
411 *
412 * Set the optimal blocksize, which will be later
413 * returned by ILAENV.
414 *
415  nb = nbval( inb )
416  CALL xlaenv( 1, nb )
417 *
418 * Copy the test matrix A into matrix AFAC which
419 * will be factorized in place. This is needed to
420 * preserve the test matrix A for subsequent tests.
421 *
422  CALL clacpy( uplo, n, n, a, lda, afac, lda )
423 *
424 * Compute the L*D*L**T or U*D*U**T factorization of the
425 * matrix. IWORK stores details of the interchanges and
426 * the block structure of D. AINV is a work array for
427 * block factorization, LWORK is the length of AINV.
428 *
429  lwork = max( 1, ( nb+1 )*lda )
430  srnamt = 'CHETRF_AA'
431  CALL chetrf_aa( uplo, n, afac, lda, iwork, ainv,
432  $ lwork, info )
433 *
434 * Adjust the expected value of INFO to account for
435 * pivoting.
436 *
437 c IF( IZERO.GT.0 ) THEN
438 c J = 1
439 c K = IZERO
440 c 100 CONTINUE
441 c IF( J.EQ.K ) THEN
442 c K = IWORK( J )
443 c ELSE IF( IWORK( J ).EQ.K ) THEN
444 c K = J
445 c END IF
446 c IF( J.LT.K ) THEN
447 c J = J + 1
448 c GO TO 100
449 c END IF
450 c ELSE
451  k = 0
452 c END IF
453 *
454 * Check error code from CHETRF and handle error.
455 *
456  IF( info.NE.k ) THEN
457  CALL alaerh( path, 'CHETRF_AA', info, k, uplo,
458  $ n, n, -1, -1, nb, imat, nfail, nerrs,
459  $ nout )
460  END IF
461 *
462 *+ TEST 1
463 * Reconstruct matrix from factors and compute residual.
464 *
465  CALL chet01_aa( uplo, n, a, lda, afac, lda, iwork,
466  $ ainv, lda, rwork, result( 1 ) )
467  nt = 1
468 *
469 *
470 * Print information about the tests that did not pass
471 * the threshold.
472 *
473  DO 110 k = 1, nt
474  IF( result( k ).GE.thresh ) THEN
475  IF( nfail.EQ.0 .AND. nerrs.EQ.0 )
476  $ CALL alahd( nout, path )
477  WRITE( nout, fmt = 9999 )uplo, n, nb, imat, k,
478  $ result( k )
479  nfail = nfail + 1
480  END IF
481  110 CONTINUE
482  nrun = nrun + nt
483 *
484 * Skip solver test if INFO is not 0.
485 *
486  IF( info.NE.0 ) THEN
487  GO TO 140
488  END IF
489 *
490 * Do for each value of NRHS in NSVAL.
491 *
492  DO 130 irhs = 1, nns
493  nrhs = nsval( irhs )
494 *
495 *+ TEST 2 (Using TRS)
496 * Solve and compute residual for A * X = B.
497 *
498 * Choose a set of NRHS random solution vectors
499 * stored in XACT and set up the right hand side B
500 *
501  srnamt = 'CLARHS'
502  CALL clarhs( matpath, xtype, uplo, ' ', n, n,
503  $ kl, ku, nrhs, a, lda, xact, lda,
504  $ b, lda, iseed, info )
505  CALL clacpy( 'Full', n, nrhs, b, lda, x, lda )
506 *
507  srnamt = 'CHETRS_AA'
508  lwork = max( 1, 3*n-2 )
509  CALL chetrs_aa( uplo, n, nrhs, afac, lda, iwork,
510  $ x, lda, work, lwork, info )
511 *
512 * Check error code from CHETRS and handle error.
513 *
514  IF( info.NE.0 ) THEN
515  IF( izero.EQ.0 ) THEN
516  CALL alaerh( path, 'CHETRS_AA', info, 0,
517  $ uplo, n, n, -1, -1, nrhs, imat,
518  $ nfail, nerrs, nout )
519  END IF
520  ELSE
521  CALL clacpy( 'Full', n, nrhs, b, lda, work, lda
522  $ )
523 *
524 * Compute the residual for the solution
525 *
526  CALL cpot02( uplo, n, nrhs, a, lda, x, lda,
527  $ work, lda, rwork, result( 2 ) )
528 *
529 * Print information about the tests that did not pass
530 * the threshold.
531 *
532  DO 120 k = 2, 2
533  IF( result( k ).GE.thresh ) THEN
534  IF( nfail.EQ.0 .AND. nerrs.EQ.0 )
535  $ CALL alahd( nout, path )
536  WRITE( nout, fmt = 9998 )uplo, n, nrhs,
537  $ imat, k, result( k )
538  nfail = nfail + 1
539  END IF
540  120 CONTINUE
541  END IF
542  nrun = nrun + 1
543 *
544 * End do for each value of NRHS in NSVAL.
545 *
546  130 CONTINUE
547  140 CONTINUE
548  150 CONTINUE
549  160 CONTINUE
550  170 CONTINUE
551  180 CONTINUE
552 *
553 * Print a summary of the results.
554 *
555  CALL alasum( path, nout, nfail, nrun, nerrs )
556 *
557  9999 FORMAT( ' UPLO = ''', a1, ''', N =', i5, ', NB =', i4, ', type ',
558  $ i2, ', test ', i2, ', ratio =', g12.5 )
559  9998 FORMAT( ' UPLO = ''', a1, ''', N =', i5, ', NRHS=', i3, ', type ',
560  $ i2, ', test(', i2, ') =', g12.5 )
561  9995 FORMAT( ' Invalid input value: ', a4, '=', i6, '; must be <=',
562  $ i6 )
563  RETURN
564 *
565 * End of CCHKHE_AA
566 *
567  END
subroutine xlaenv(ISPEC, NVALUE)
XLAENV
Definition: xlaenv.f:83
subroutine chetrf_aa(UPLO, N, A, LDA, IPIV, WORK, LWORK, INFO)
CHETRF_AA
Definition: chetrf_aa.f:134
subroutine chetrs_aa(UPLO, N, NRHS, A, LDA, IPIV, B, LDB, WORK, LWORK, INFO)
CHETRS_AA
Definition: chetrs_aa.f:131
subroutine cerrhe(PATH, NUNIT)
CERRHE
Definition: cerrhe.f:57
subroutine clacpy(UPLO, M, N, A, LDA, B, LDB)
CLACPY copies all or part of one two-dimensional array to another.
Definition: clacpy.f:105
subroutine clatms(M, N, DIST, ISEED, SYM, D, MODE, COND, DMAX, KL, KU, PACK, A, LDA, WORK, INFO)
CLATMS
Definition: clatms.f:334
subroutine alasum(TYPE, NOUT, NFAIL, NRUN, NERRS)
ALASUM
Definition: alasum.f:75
subroutine cchkhe_aa(DOTYPE, NN, NVAL, NNB, NBVAL, NNS, NSVAL, THRESH, TSTERR, NMAX, A, AFAC, AINV, B, X, XACT, WORK, RWORK, IWORK, NOUT)
CCHKHE_AA
Definition: cchkhe_aa.f:174
subroutine cpot02(UPLO, N, NRHS, A, LDA, X, LDX, B, LDB, RWORK, RESID)
CPOT02
Definition: cpot02.f:129
subroutine alahd(IOUNIT, PATH)
ALAHD
Definition: alahd.f:107
subroutine clatb4(PATH, IMAT, M, N, TYPE, KL, KU, ANORM, MODE, CNDNUM, DIST)
CLATB4
Definition: clatb4.f:123
subroutine alaerh(PATH, SUBNAM, INFO, INFOE, OPTS, M, N, KL, KU, N5, IMAT, NFAIL, NERRS, NOUT)
ALAERH
Definition: alaerh.f:149
subroutine chet01_aa(UPLO, N, A, LDA, AFAC, LDAFAC, IPIV, C, LDC, RWORK, RESID)
CHET01_AA
Definition: chet01_aa.f:127
subroutine clarhs(PATH, XTYPE, UPLO, TRANS, M, N, KL, KU, NRHS, A, LDA, X, LDX, B, LDB, ISEED, INFO)
CLARHS
Definition: clarhs.f:211
subroutine claipd(N, A, INDA, VINDA)
CLAIPD
Definition: claipd.f:85