LAPACK  3.8.0
LAPACK: Linear Algebra PACKage
zchkhe_aa_2stage.f
Go to the documentation of this file.
1 *> \brief \b ZCHKHE_AA_2STAGE
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 ZCHKHE_AA_2STAGE( DOTYPE, NN, NVAL, NNB, NBVAL,
12 * NNS, NSVAL, THRESH, TSTERR, NMAX, A,
13 * AFAC, AINV, B, X, XACT, WORK, RWORK,
14 * IWORK, NOUT )
15 *
16 * .. Scalar Arguments ..
17 * LOGICAL TSTERR
18 * INTEGER NMAX, NN, NNB, NNS, NOUT
19 * DOUBLE PRECISION THRESH
20 * ..
21 * .. Array Arguments ..
22 * LOGICAL DOTYPE( * )
23 * INTEGER IWORK( * ), NBVAL( * ), NSVAL( * ), NVAL( * )
24 * DOUBLE PRECISION RWORK( * )
25 * COMPLEX*16 A( * ), AFAC( * ), AINV( * ), B( * ),
26 * $ WORK( * ), X( * ), XACT( * )
27 * ..
28 *
29 *
30 *> \par Purpose:
31 * =============
32 *>
33 *> \verbatim
34 *>
35 *> ZCHKSY_AA_2STAGE tests ZHETRF_AA_2STAGE, -TRS_AA_2STAGE.
36 *> \endverbatim
37 *
38 * Arguments:
39 * ==========
40 *
41 *> \param[in] DOTYPE
42 *> \verbatim
43 *> DOTYPE is LOGICAL array, dimension (NTYPES)
44 *> The matrix types to be used for testing. Matrices of type j
45 *> (for 1 <= j <= NTYPES) are used for testing if DOTYPE(j) =
46 *> .TRUE.; if DOTYPE(j) = .FALSE., then type j is not used.
47 *> \endverbatim
48 *>
49 *> \param[in] NN
50 *> \verbatim
51 *> NN is INTEGER
52 *> The number of values of N contained in the vector NVAL.
53 *> \endverbatim
54 *>
55 *> \param[in] NVAL
56 *> \verbatim
57 *> NVAL is INTEGER array, dimension (NN)
58 *> The values of the matrix dimension N.
59 *> \endverbatim
60 *>
61 *> \param[in] NNB
62 *> \verbatim
63 *> NNB is INTEGER
64 *> The number of values of NB contained in the vector NBVAL.
65 *> \endverbatim
66 *>
67 *> \param[in] NBVAL
68 *> \verbatim
69 *> NBVAL is INTEGER array, dimension (NBVAL)
70 *> The values of the blocksize NB.
71 *> \endverbatim
72 *>
73 *> \param[in] NNS
74 *> \verbatim
75 *> NNS is INTEGER
76 *> The number of values of NRHS contained in the vector NSVAL.
77 *> \endverbatim
78 *>
79 *> \param[in] NSVAL
80 *> \verbatim
81 *> NSVAL is INTEGER array, dimension (NNS)
82 *> The values of the number of right hand sides NRHS.
83 *> \endverbatim
84 *>
85 *> \param[in] THRESH
86 *> \verbatim
87 *> THRESH is DOUBLE PRECISION
88 *> The threshold value for the test ratios. A result is
89 *> included in the output file if RESULT >= THRESH. To have
90 *> every test ratio printed, use THRESH = 0.
91 *> \endverbatim
92 *>
93 *> \param[in] TSTERR
94 *> \verbatim
95 *> TSTERR is LOGICAL
96 *> Flag that indicates whether error exits are to be tested.
97 *> \endverbatim
98 *>
99 *> \param[in] NMAX
100 *> \verbatim
101 *> NMAX is INTEGER
102 *> The maximum value permitted for N, used in dimensioning the
103 *> work arrays.
104 *> \endverbatim
105 *>
106 *> \param[out] A
107 *> \verbatim
108 *> A is COMPLEX*16 array, dimension (NMAX*NMAX)
109 *> \endverbatim
110 *>
111 *> \param[out] AFAC
112 *> \verbatim
113 *> AFAC is COMPLEX*16 array, dimension (NMAX*NMAX)
114 *> \endverbatim
115 *>
116 *> \param[out] AINV
117 *> \verbatim
118 *> AINV is COMPLEX*16 array, dimension (NMAX*NMAX)
119 *> \endverbatim
120 *>
121 *> \param[out] B
122 *> \verbatim
123 *> B is COMPLEX*16 array, dimension (NMAX*NSMAX)
124 *> where NSMAX is the largest entry in NSVAL.
125 *> \endverbatim
126 *>
127 *> \param[out] X
128 *> \verbatim
129 *> X is COMPLEX*16 array, dimension (NMAX*NSMAX)
130 *> \endverbatim
131 *>
132 *> \param[out] XACT
133 *> \verbatim
134 *> XACT is COMPLEX*16 array, dimension (NMAX*NSMAX)
135 *> \endverbatim
136 *>
137 *> \param[out] WORK
138 *> \verbatim
139 *> WORK is COMPLEX*16 array, dimension (NMAX*max(3,NSMAX))
140 *> \endverbatim
141 *>
142 *> \param[out] RWORK
143 *> \verbatim
144 *> RWORK is DOUBLE PRECISION array, dimension (max(NMAX,2*NSMAX))
145 *> \endverbatim
146 *>
147 *> \param[out] IWORK
148 *> \verbatim
149 *> IWORK is INTEGER array, dimension (2*NMAX)
150 *> \endverbatim
151 *>
152 *> \param[in] NOUT
153 *> \verbatim
154 *> NOUT is INTEGER
155 *> The unit number for output.
156 *> \endverbatim
157 *
158 * Authors:
159 * ========
160 *
161 *> \author Univ. of Tennessee
162 *> \author Univ. of California Berkeley
163 *> \author Univ. of Colorado Denver
164 *> \author NAG Ltd.
165 *
166 *> \date November 2017
167 *
168 *> \ingroup complex16_lin
169 *
170 * =====================================================================
171  SUBROUTINE zchkhe_aa_2stage( DOTYPE, NN, NVAL, NNB, NBVAL, NNS,
172  $ NSVAL, THRESH, TSTERR, NMAX, A, AFAC, AINV,
173  $ B, 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 NN, NNB, NNS, NMAX, NOUT
185  DOUBLE PRECISION THRESH
186 * ..
187 * .. Array Arguments ..
188  LOGICAL DOTYPE( * )
189  INTEGER IWORK( * ), NBVAL( * ), NSVAL( * ), NVAL( * )
190  COMPLEX*16 A( * ), AFAC( * ), AINV( * ), B( * ),
191  $ rwork( * ), 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 = 10 )
203  INTEGER NTESTS
204  parameter( ntests = 9 )
205 * ..
206 * .. Local Scalars ..
207  LOGICAL ZEROT
208  CHARACTER DIST, TYPE, UPLO, XTYPE
209  CHARACTER*3 PATH, MATPATH
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
214 * ..
215 * .. Local Arrays ..
216  CHARACTER UPLOS( 2 )
217  INTEGER ISEED( 4 ), ISEEDY( 4 )
218  DOUBLE PRECISION RESULT( ntests )
219 * ..
220 * .. External Subroutines ..
221  EXTERNAL alaerh, alahd, alasum, zerrhe, zlacpy,
222  $ zlarhs, zlatb4, zlatms, zpot02,
224  $ xlaenv
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 * Test path
247 *
248  path( 1: 1 ) = 'Zomplex precision'
249  path( 2: 3 ) = 'H2'
250 *
251 * Path to generate matrices
252 *
253  matpath( 1: 1 ) = 'Zomplex precision'
254  matpath( 2: 3 ) = 'HE'
255  nrun = 0
256  nfail = 0
257  nerrs = 0
258  DO 10 i = 1, 4
259  iseed( i ) = iseedy( i )
260  10 CONTINUE
261 *
262 * Test the error exits
263 *
264  IF( tsterr )
265  $ CALL zerrhe( path, nout )
266  infot = 0
267 *
268 * Set the minimum block size for which the block routine should
269 * be used, which will be later returned by ILAENV
270 *
271  CALL xlaenv( 2, 2 )
272 *
273 * Do for each value of N in NVAL
274 *
275  DO 180 in = 1, nn
276  n = nval( in )
277  IF( n .GT. nmax ) THEN
278  nfail = nfail + 1
279  WRITE(nout, 9995) 'M ', n, nmax
280  GO TO 180
281  END IF
282  lda = max( n, 1 )
283  xtype = 'N'
284  nimat = ntypes
285  IF( n.LE.0 )
286  $ nimat = 1
287 *
288  izero = 0
289 *
290 * Do for each value of matrix type IMAT
291 *
292  DO 170 imat = 1, nimat
293 *
294 * Do the tests only if DOTYPE( IMAT ) is true.
295 *
296  IF( .NOT.dotype( imat ) )
297  $ GO TO 170
298 *
299 * Skip types 3, 4, 5, or 6 if the matrix size is too small.
300 *
301  zerot = imat.GE.3 .AND. imat.LE.6
302  IF( zerot .AND. n.LT.imat-2 )
303  $ GO TO 170
304 *
305 * Do first for UPLO = 'U', then for UPLO = 'L'
306 *
307  DO 160 iuplo = 1, 2
308  uplo = uplos( iuplo )
309 *
310 * Begin generate the test matrix A.
311 *
312 *
313 * Set up parameters with ZLATB4 for the matrix generator
314 * based on the type of matrix to be generated.
315 *
316  CALL zlatb4( matpath, imat, n, n, TYPE, KL, KU,
317  $ anorm, mode, cndnum, dist )
318 *
319 * Generate a matrix with ZLATMS.
320 *
321  srnamt = 'ZLATMS'
322  CALL zlatms( n, n, dist, iseed, TYPE, RWORK, MODE,
323  $ cndnum, anorm, kl, ku, uplo, a, lda, work,
324  $ info )
325 *
326 * Check error code from ZLATMS and handle error.
327 *
328  IF( info.NE.0 ) THEN
329  CALL alaerh( path, 'ZLATMS', info, 0, uplo, n, n, -1,
330  $ -1, -1, imat, nfail, nerrs, nout )
331 *
332 * Skip all tests for this generated matrix
333 *
334  GO TO 160
335  END IF
336 *
337 * For matrix types 3-6, zero one or more rows and
338 * columns of the matrix to test that INFO is returned
339 * correctly.
340 *
341  IF( zerot ) THEN
342  IF( imat.EQ.3 ) THEN
343  izero = 1
344  ELSE IF( imat.EQ.4 ) THEN
345  izero = n
346  ELSE
347  izero = n / 2 + 1
348  END IF
349 *
350  IF( imat.LT.6 ) THEN
351 *
352 * Set row and column IZERO to zero.
353 *
354  IF( iuplo.EQ.1 ) THEN
355  ioff = ( izero-1 )*lda
356  DO 20 i = 1, izero - 1
357  a( ioff+i ) = czero
358  20 CONTINUE
359  ioff = ioff + izero
360  DO 30 i = izero, n
361  a( ioff ) = czero
362  ioff = ioff + lda
363  30 CONTINUE
364  ELSE
365  ioff = izero
366  DO 40 i = 1, izero - 1
367  a( ioff ) = czero
368  ioff = ioff + lda
369  40 CONTINUE
370  ioff = ioff - izero
371  DO 50 i = izero, n
372  a( ioff+i ) = czero
373  50 CONTINUE
374  END IF
375  ELSE
376  IF( iuplo.EQ.1 ) THEN
377 *
378 * Set the first IZERO rows and columns to zero.
379 *
380  ioff = 0
381  DO 70 j = 1, n
382  i2 = min( j, izero )
383  DO 60 i = 1, i2
384  a( ioff+i ) = czero
385  60 CONTINUE
386  ioff = ioff + lda
387  70 CONTINUE
388  izero = 1
389  ELSE
390 *
391 * Set the last IZERO rows and columns to zero.
392 *
393  ioff = 0
394  DO 90 j = 1, n
395  i1 = max( j, izero )
396  DO 80 i = i1, n
397  a( ioff+i ) = czero
398  80 CONTINUE
399  ioff = ioff + lda
400  90 CONTINUE
401  END IF
402  END IF
403  ELSE
404  izero = 0
405  END IF
406 *
407 * End generate test matrix A.
408 *
409 *
410 * Set the imaginary part of the diagonals.
411 *
412  CALL zlaipd( n, a, lda+1, 0 )
413 *
414 * Do for each value of NB in NBVAL
415 *
416  DO 150 inb = 1, nnb
417 *
418 * Set the optimal blocksize, which will be later
419 * returned by ILAENV.
420 *
421  nb = nbval( inb )
422  CALL xlaenv( 1, nb )
423 *
424 * Copy the test matrix A into matrix AFAC which
425 * will be factorized in place. This is needed to
426 * preserve the test matrix A for subsequent tests.
427 *
428  CALL zlacpy( uplo, n, n, a, lda, afac, lda )
429 *
430 * Compute the L*D*L**T or U*D*U**T factorization of the
431 * matrix. IWORK stores details of the interchanges and
432 * the block structure of D. AINV is a work array for
433 * block factorization, LWORK is the length of AINV.
434 *
435  srnamt = 'ZHETRF_AA_2STAGE'
436  lwork = min(n*nb, 3*nmax*nmax)
437  CALL zhetrf_aa_2stage( uplo, n, afac, lda,
438  $ ainv, (3*nb+1)*n,
439  $ iwork, iwork( 1+n ),
440  $ work, lwork,
441  $ info )
442 *
443 * Adjust the expected value of INFO to account for
444 * pivoting.
445 *
446  IF( izero.GT.0 ) THEN
447  j = 1
448  k = izero
449  100 CONTINUE
450  IF( j.EQ.k ) THEN
451  k = iwork( j )
452  ELSE IF( iwork( j ).EQ.k ) THEN
453  k = j
454  END IF
455  IF( j.LT.k ) THEN
456  j = j + 1
457  GO TO 100
458  END IF
459  ELSE
460  k = 0
461  END IF
462 *
463 * Check error code from CHETRF and handle error.
464 *
465  IF( info.NE.k ) THEN
466  CALL alaerh( path, 'ZHETRF_AA_2STAGE', info, k,
467  $ uplo, n, n, -1, -1, nb, imat, nfail,
468  $ nerrs, nout )
469  END IF
470 *
471 *+ TEST 1
472 * Reconstruct matrix from factors and compute residual.
473 *
474 * NEED TO CREATE ZHET01_AA_2STAGE
475 * CALL ZHET01_AA( UPLO, N, A, LDA, AFAC, LDA, IWORK,
476 * $ AINV, LDA, RWORK, RESULT( 1 ) )
477 * NT = 1
478  nt = 0
479 *
480 *
481 * Print information about the tests that did not pass
482 * the threshold.
483 *
484  DO 110 k = 1, nt
485  IF( result( k ).GE.thresh ) THEN
486  IF( nfail.EQ.0 .AND. nerrs.EQ.0 )
487  $ CALL alahd( nout, path )
488  WRITE( nout, fmt = 9999 )uplo, n, nb, imat, k,
489  $ result( k )
490  nfail = nfail + 1
491  END IF
492  110 CONTINUE
493  nrun = nrun + nt
494 *
495 * Skip solver test if INFO is not 0.
496 *
497  IF( info.NE.0 ) THEN
498  GO TO 140
499  END IF
500 *
501 * Do for each value of NRHS in NSVAL.
502 *
503  DO 130 irhs = 1, nns
504  nrhs = nsval( irhs )
505 *
506 *+ TEST 2 (Using TRS)
507 * Solve and compute residual for A * X = B.
508 *
509 * Choose a set of NRHS random solution vectors
510 * stored in XACT and set up the right hand side B
511 *
512  srnamt = 'ZLARHS'
513  CALL zlarhs( matpath, xtype, uplo, ' ', n, n,
514  $ kl, ku, nrhs, a, lda, xact, lda,
515  $ b, lda, iseed, info )
516  CALL zlacpy( 'Full', n, nrhs, b, lda, x, lda )
517 *
518  srnamt = 'ZHETRS_AA_2STAGE'
519  lwork = max( 1, 3*n-2 )
520  CALL zhetrs_aa_2stage( uplo, n, nrhs, afac, lda,
521  $ ainv, (3*nb+1)*n, iwork, iwork( 1+n ),
522  $ x, lda, info )
523 *
524 * Check error code from ZHETRS and handle error.
525 *
526  IF( info.NE.0 ) THEN
527  IF( izero.EQ.0 ) THEN
528  CALL alaerh( path, 'ZHETRS_AA_2STAGE',
529  $ info, 0, uplo, n, n, -1, -1,
530  $ nrhs, imat, nfail, nerrs, nout )
531  END IF
532  ELSE
533 *
534  CALL zlacpy( 'Full', n, nrhs, b, lda, work, lda
535  $ )
536 *
537 * Compute the residual for the solution
538 *
539  CALL zpot02( uplo, n, nrhs, a, lda, x, lda,
540  $ work, lda, rwork, result( 2 ) )
541 *
542 * Print information about the tests that did not pass
543 * the threshold.
544 *
545  DO 120 k = 2, 2
546  IF( result( k ).GE.thresh ) THEN
547  IF( nfail.EQ.0 .AND. nerrs.EQ.0 )
548  $ CALL alahd( nout, path )
549  WRITE( nout, fmt = 9998 )uplo, n, nrhs,
550  $ imat, k, result( k )
551  nfail = nfail + 1
552  END IF
553  120 CONTINUE
554  END IF
555  nrun = nrun + 1
556 *
557 * End do for each value of NRHS in NSVAL.
558 *
559  130 CONTINUE
560  140 CONTINUE
561  150 CONTINUE
562  160 CONTINUE
563  170 CONTINUE
564  180 CONTINUE
565 *
566 * Print a summary of the results.
567 *
568  CALL alasum( path, nout, nfail, nrun, nerrs )
569 *
570  9999 FORMAT( ' UPLO = ''', a1, ''', N =', i5, ', NB =', i4, ', type ',
571  $ i2, ', test ', i2, ', ratio =', g12.5 )
572  9998 FORMAT( ' UPLO = ''', a1, ''', N =', i5, ', NRHS=', i3, ', type ',
573  $ i2, ', test(', i2, ') =', g12.5 )
574  9995 FORMAT( ' Invalid input value: ', a4, '=', i6, '; must be <=',
575  $ i6 )
576  RETURN
577 *
578 * End of ZCHKSY_AA_2STAGE
579 *
580  END
subroutine alahd(IOUNIT, PATH)
ALAHD
Definition: alahd.f:107
subroutine zhetrs_aa_2stage(UPLO, N, NRHS, A, LDA, TB, LTB, IPIV, IPIV2, B, LDB, INFO)
ZHETRS_AA_2STAGE
subroutine zerrhe(PATH, NUNIT)
ZERRHE
Definition: zerrhe.f:57
subroutine alaerh(PATH, SUBNAM, INFO, INFOE, OPTS, M, N, KL, KU, N5, IMAT, NFAIL, NERRS, NOUT)
ALAERH
Definition: alaerh.f:149
subroutine zchkhe_aa_2stage(DOTYPE, NN, NVAL, NNB, NBVAL, NNS, NSVAL, THRESH, TSTERR, NMAX, A, AFAC, AINV, B, X, XACT, WORK, RWORK, IWORK, NOUT)
ZCHKHE_AA_2STAGE
subroutine zlacpy(UPLO, M, N, A, LDA, B, LDB)
ZLACPY copies all or part of one two-dimensional array to another.
Definition: zlacpy.f:105
subroutine zlatb4(PATH, IMAT, M, N, TYPE, KL, KU, ANORM, MODE, CNDNUM, DIST)
ZLATB4
Definition: zlatb4.f:123
subroutine xlaenv(ISPEC, NVALUE)
XLAENV
Definition: xlaenv.f:83
subroutine zlaipd(N, A, INDA, VINDA)
ZLAIPD
Definition: zlaipd.f:85
subroutine zlatms(M, N, DIST, ISEED, SYM, D, MODE, COND, DMAX, KL, KU, PACK, A, LDA, WORK, INFO)
ZLATMS
Definition: zlatms.f:334
subroutine zhetrf_aa_2stage(UPLO, N, A, LDA, TB, LTB, IPIV, IPIV2, WORK, LWORK, INFO)
ZHETRF_AA_2STAGE
subroutine zlarhs(PATH, XTYPE, UPLO, TRANS, M, N, KL, KU, NRHS, A, LDA, X, LDX, B, LDB, ISEED, INFO)
ZLARHS
Definition: zlarhs.f:211
subroutine zpot02(UPLO, N, NRHS, A, LDA, X, LDX, B, LDB, RWORK, RESID)
ZPOT02
Definition: zpot02.f:129
subroutine alasum(TYPE, NOUT, NFAIL, NRUN, NERRS)
ALASUM
Definition: alasum.f:75