LAPACK  3.8.0 LAPACK: Linear Algebra PACKage
zchkpp.f
Go to the documentation of this file.
1 *> \brief \b ZCHKPP
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 ZCHKPP( DOTYPE, NN, NVAL, NNS, NSVAL, THRESH, TSTERR,
12 * NMAX, A, AFAC, AINV, B, X, XACT, WORK, RWORK,
13 * NOUT )
14 *
15 * .. Scalar Arguments ..
16 * LOGICAL TSTERR
17 * INTEGER NMAX, NN, NNS, NOUT
18 * DOUBLE PRECISION THRESH
19 * ..
20 * .. Array Arguments ..
21 * LOGICAL DOTYPE( * )
22 * INTEGER 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 *> ZCHKPP tests ZPPTRF, -TRI, -TRS, -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] NNS
61 *> \verbatim
62 *> NNS is INTEGER
63 *> The number of values of NRHS contained in the vector NSVAL.
64 *> \endverbatim
65 *>
66 *> \param[in] NSVAL
67 *> \verbatim
68 *> NSVAL is INTEGER array, dimension (NNS)
69 *> The values of the number of right hand sides NRHS.
70 *> \endverbatim
71 *>
72 *> \param[in] THRESH
73 *> \verbatim
74 *> THRESH is DOUBLE PRECISION
75 *> The threshold value for the test ratios. A result is
76 *> included in the output file if RESULT >= THRESH. To have
77 *> every test ratio printed, use THRESH = 0.
78 *> \endverbatim
79 *>
80 *> \param[in] TSTERR
81 *> \verbatim
82 *> TSTERR is LOGICAL
83 *> Flag that indicates whether error exits are to be tested.
84 *> \endverbatim
85 *>
86 *> \param[in] NMAX
87 *> \verbatim
88 *> NMAX is INTEGER
89 *> The maximum value permitted for N, used in dimensioning the
90 *> work arrays.
91 *> \endverbatim
92 *>
93 *> \param[out] A
94 *> \verbatim
95 *> A is COMPLEX*16 array, dimension
96 *> (NMAX*(NMAX+1)/2)
97 *> \endverbatim
98 *>
99 *> \param[out] AFAC
100 *> \verbatim
101 *> AFAC is COMPLEX*16 array, dimension
102 *> (NMAX*(NMAX+1)/2)
103 *> \endverbatim
104 *>
105 *> \param[out] AINV
106 *> \verbatim
107 *> AINV is COMPLEX*16 array, dimension
108 *> (NMAX*(NMAX+1)/2)
109 *> \endverbatim
110 *>
111 *> \param[out] B
112 *> \verbatim
113 *> B is COMPLEX*16 array, dimension (NMAX*NSMAX)
114 *> where NSMAX is the largest entry in NSVAL.
115 *> \endverbatim
116 *>
117 *> \param[out] X
118 *> \verbatim
119 *> X is COMPLEX*16 array, dimension (NMAX*NSMAX)
120 *> \endverbatim
121 *>
122 *> \param[out] XACT
123 *> \verbatim
124 *> XACT is COMPLEX*16 array, dimension (NMAX*NSMAX)
125 *> \endverbatim
126 *>
127 *> \param[out] WORK
128 *> \verbatim
129 *> WORK is COMPLEX*16 array, dimension
130 *> (NMAX*max(3,NSMAX))
131 *> \endverbatim
132 *>
133 *> \param[out] RWORK
134 *> \verbatim
135 *> RWORK is DOUBLE PRECISION array, dimension
136 *> (max(NMAX,2*NSMAX))
137 *> \endverbatim
138 *>
139 *> \param[in] NOUT
140 *> \verbatim
141 *> NOUT is INTEGER
142 *> The unit number for output.
143 *> \endverbatim
144 *
145 * Authors:
146 * ========
147 *
148 *> \author Univ. of Tennessee
149 *> \author Univ. of California Berkeley
150 *> \author Univ. of Colorado Denver
151 *> \author NAG Ltd.
152 *
153 *> \date December 2016
154 *
155 *> \ingroup complex16_lin
156 *
157 * =====================================================================
158  SUBROUTINE zchkpp( DOTYPE, NN, NVAL, NNS, NSVAL, THRESH, TSTERR,
159  \$ NMAX, A, AFAC, AINV, B, X, XACT, WORK, RWORK,
160  \$ NOUT )
161 *
162 * -- LAPACK test routine (version 3.7.0) --
163 * -- LAPACK is a software package provided by Univ. of Tennessee, --
164 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
165 * December 2016
166 *
167 * .. Scalar Arguments ..
168  LOGICAL TSTERR
169  INTEGER NMAX, NN, NNS, NOUT
170  DOUBLE PRECISION THRESH
171 * ..
172 * .. Array Arguments ..
173  LOGICAL DOTYPE( * )
174  INTEGER NSVAL( * ), NVAL( * )
175  DOUBLE PRECISION RWORK( * )
176  COMPLEX*16 A( * ), AFAC( * ), AINV( * ), B( * ),
177  \$ work( * ), x( * ), xact( * )
178 * ..
179 *
180 * =====================================================================
181 *
182 * .. Parameters ..
183  DOUBLE PRECISION ZERO
184  parameter( zero = 0.0d+0 )
185  INTEGER NTYPES
186  parameter( ntypes = 9 )
187  INTEGER NTESTS
188  parameter( ntests = 8 )
189 * ..
190 * .. Local Scalars ..
191  LOGICAL ZEROT
192  CHARACTER DIST, PACKIT, TYPE, UPLO, XTYPE
193  CHARACTER*3 PATH
194  INTEGER I, IMAT, IN, INFO, IOFF, IRHS, IUPLO, IZERO, K,
195  \$ kl, ku, lda, mode, n, nerrs, nfail, nimat, npp,
196  \$ nrhs, nrun
197  DOUBLE PRECISION ANORM, CNDNUM, RCOND, RCONDC
198 * ..
199 * .. Local Arrays ..
200  CHARACTER PACKS( 2 ), UPLOS( 2 )
201  INTEGER ISEED( 4 ), ISEEDY( 4 )
202  DOUBLE PRECISION RESULT( ntests )
203 * ..
204 * .. External Functions ..
205  DOUBLE PRECISION DGET06, ZLANHP
206  EXTERNAL dget06, zlanhp
207 * ..
208 * .. External Subroutines ..
209  EXTERNAL alaerh, alahd, alasum, zcopy, zerrpo, zget04,
212  \$ zpptri, zpptrs
213 * ..
214 * .. Scalars in Common ..
215  LOGICAL LERR, OK
216  CHARACTER*32 SRNAMT
217  INTEGER INFOT, NUNIT
218 * ..
219 * .. Common blocks ..
220  COMMON / infoc / infot, nunit, ok, lerr
221  COMMON / srnamc / srnamt
222 * ..
223 * .. Intrinsic Functions ..
224  INTRINSIC max
225 * ..
226 * .. Data statements ..
227  DATA iseedy / 1988, 1989, 1990, 1991 /
228  DATA uplos / 'U', 'L' / , packs / 'C', 'R' /
229 * ..
230 * .. Executable Statements ..
231 *
232 * Initialize constants and the random number seed.
233 *
234  path( 1: 1 ) = 'Zomplex precision'
235  path( 2: 3 ) = 'PP'
236  nrun = 0
237  nfail = 0
238  nerrs = 0
239  DO 10 i = 1, 4
240  iseed( i ) = iseedy( i )
241  10 CONTINUE
242 *
243 * Test the error exits
244 *
245  IF( tsterr )
246  \$ CALL zerrpo( path, nout )
247  infot = 0
248 *
249 * Do for each value of N in NVAL
250 *
251  DO 110 in = 1, nn
252  n = nval( in )
253  lda = max( n, 1 )
254  xtype = 'N'
255  nimat = ntypes
256  IF( n.LE.0 )
257  \$ nimat = 1
258 *
259  DO 100 imat = 1, nimat
260 *
261 * Do the tests only if DOTYPE( IMAT ) is true.
262 *
263  IF( .NOT.dotype( imat ) )
264  \$ GO TO 100
265 *
266 * Skip types 3, 4, or 5 if the matrix size is too small.
267 *
268  zerot = imat.GE.3 .AND. imat.LE.5
269  IF( zerot .AND. n.LT.imat-2 )
270  \$ GO TO 100
271 *
272 * Do first for UPLO = 'U', then for UPLO = 'L'
273 *
274  DO 90 iuplo = 1, 2
275  uplo = uplos( iuplo )
276  packit = packs( iuplo )
277 *
278 * Set up parameters with ZLATB4 and generate a test matrix
279 * with ZLATMS.
280 *
281  CALL zlatb4( path, imat, n, n, TYPE, KL, KU, ANORM, MODE,
282  \$ cndnum, dist )
283 *
284  srnamt = 'ZLATMS'
285  CALL zlatms( n, n, dist, iseed, TYPE, RWORK, MODE,
286  \$ cndnum, anorm, kl, ku, packit, a, lda, work,
287  \$ info )
288 *
289 * Check error code from ZLATMS.
290 *
291  IF( info.NE.0 ) THEN
292  CALL alaerh( path, 'ZLATMS', info, 0, uplo, n, n, -1,
293  \$ -1, -1, imat, nfail, nerrs, nout )
294  GO TO 90
295  END IF
296 *
297 * For types 3-5, zero one row and column of the matrix to
298 * test that INFO is returned correctly.
299 *
300  IF( zerot ) THEN
301  IF( imat.EQ.3 ) THEN
302  izero = 1
303  ELSE IF( imat.EQ.4 ) THEN
304  izero = n
305  ELSE
306  izero = n / 2 + 1
307  END IF
308 *
309 * Set row and column IZERO of A to 0.
310 *
311  IF( iuplo.EQ.1 ) THEN
312  ioff = ( izero-1 )*izero / 2
313  DO 20 i = 1, izero - 1
314  a( ioff+i ) = zero
315  20 CONTINUE
316  ioff = ioff + izero
317  DO 30 i = izero, n
318  a( ioff ) = zero
319  ioff = ioff + i
320  30 CONTINUE
321  ELSE
322  ioff = izero
323  DO 40 i = 1, izero - 1
324  a( ioff ) = zero
325  ioff = ioff + n - i
326  40 CONTINUE
327  ioff = ioff - izero
328  DO 50 i = izero, n
329  a( ioff+i ) = zero
330  50 CONTINUE
331  END IF
332  ELSE
333  izero = 0
334  END IF
335 *
336 * Set the imaginary part of the diagonals.
337 *
338  IF( iuplo.EQ.1 ) THEN
339  CALL zlaipd( n, a, 2, 1 )
340  ELSE
341  CALL zlaipd( n, a, n, -1 )
342  END IF
343 *
344 * Compute the L*L' or U'*U factorization of the matrix.
345 *
346  npp = n*( n+1 ) / 2
347  CALL zcopy( npp, a, 1, afac, 1 )
348  srnamt = 'ZPPTRF'
349  CALL zpptrf( uplo, n, afac, info )
350 *
351 * Check error code from ZPPTRF.
352 *
353  IF( info.NE.izero ) THEN
354  CALL alaerh( path, 'ZPPTRF', info, izero, uplo, n, n,
355  \$ -1, -1, -1, imat, nfail, nerrs, nout )
356  GO TO 90
357  END IF
358 *
359 * Skip the tests if INFO is not 0.
360 *
361  IF( info.NE.0 )
362  \$ GO TO 90
363 *
364 *+ TEST 1
365 * Reconstruct matrix from factors and compute residual.
366 *
367  CALL zcopy( npp, afac, 1, ainv, 1 )
368  CALL zppt01( uplo, n, a, ainv, rwork, result( 1 ) )
369 *
370 *+ TEST 2
371 * Form the inverse and compute the residual.
372 *
373  CALL zcopy( npp, afac, 1, ainv, 1 )
374  srnamt = 'ZPPTRI'
375  CALL zpptri( uplo, n, ainv, info )
376 *
377 * Check error code from ZPPTRI.
378 *
379  IF( info.NE.0 )
380  \$ CALL alaerh( path, 'ZPPTRI', info, 0, uplo, n, n, -1,
381  \$ -1, -1, imat, nfail, nerrs, nout )
382 *
383  CALL zppt03( uplo, n, a, ainv, work, lda, rwork, rcondc,
384  \$ result( 2 ) )
385 *
386 * Print information about the tests that did not pass
387 * the threshold.
388 *
389  DO 60 k = 1, 2
390  IF( result( k ).GE.thresh ) THEN
391  IF( nfail.EQ.0 .AND. nerrs.EQ.0 )
392  \$ CALL alahd( nout, path )
393  WRITE( nout, fmt = 9999 )uplo, n, imat, k,
394  \$ result( k )
395  nfail = nfail + 1
396  END IF
397  60 CONTINUE
398  nrun = nrun + 2
399 *
400  DO 80 irhs = 1, nns
401  nrhs = nsval( irhs )
402 *
403 *+ TEST 3
404 * Solve and compute residual for A * X = B.
405 *
406  srnamt = 'ZLARHS'
407  CALL zlarhs( path, xtype, uplo, ' ', n, n, kl, ku,
408  \$ nrhs, a, lda, xact, lda, b, lda, iseed,
409  \$ info )
410  CALL zlacpy( 'Full', n, nrhs, b, lda, x, lda )
411 *
412  srnamt = 'ZPPTRS'
413  CALL zpptrs( uplo, n, nrhs, afac, x, lda, info )
414 *
415 * Check error code from ZPPTRS.
416 *
417  IF( info.NE.0 )
418  \$ CALL alaerh( path, 'ZPPTRS', info, 0, uplo, n, n,
419  \$ -1, -1, nrhs, imat, nfail, nerrs,
420  \$ nout )
421 *
422  CALL zlacpy( 'Full', n, nrhs, b, lda, work, lda )
423  CALL zppt02( uplo, n, nrhs, a, x, lda, work, lda,
424  \$ rwork, result( 3 ) )
425 *
426 *+ TEST 4
427 * Check solution from generated exact solution.
428 *
429  CALL zget04( n, nrhs, x, lda, xact, lda, rcondc,
430  \$ result( 4 ) )
431 *
432 *+ TESTS 5, 6, and 7
433 * Use iterative refinement to improve the solution.
434 *
435  srnamt = 'ZPPRFS'
436  CALL zpprfs( uplo, n, nrhs, a, afac, b, lda, x, lda,
437  \$ rwork, rwork( nrhs+1 ), work,
438  \$ rwork( 2*nrhs+1 ), info )
439 *
440 * Check error code from ZPPRFS.
441 *
442  IF( info.NE.0 )
443  \$ CALL alaerh( path, 'ZPPRFS', info, 0, uplo, n, n,
444  \$ -1, -1, nrhs, imat, nfail, nerrs,
445  \$ nout )
446 *
447  CALL zget04( n, nrhs, x, lda, xact, lda, rcondc,
448  \$ result( 5 ) )
449  CALL zppt05( uplo, n, nrhs, a, b, lda, x, lda, xact,
450  \$ lda, rwork, rwork( nrhs+1 ),
451  \$ result( 6 ) )
452 *
453 * Print information about the tests that did not pass
454 * the threshold.
455 *
456  DO 70 k = 3, 7
457  IF( result( k ).GE.thresh ) THEN
458  IF( nfail.EQ.0 .AND. nerrs.EQ.0 )
459  \$ CALL alahd( nout, path )
460  WRITE( nout, fmt = 9998 )uplo, n, nrhs, imat,
461  \$ k, result( k )
462  nfail = nfail + 1
463  END IF
464  70 CONTINUE
465  nrun = nrun + 5
466  80 CONTINUE
467 *
468 *+ TEST 8
469 * Get an estimate of RCOND = 1/CNDNUM.
470 *
471  anorm = zlanhp( '1', uplo, n, a, rwork )
472  srnamt = 'ZPPCON'
473  CALL zppcon( uplo, n, afac, anorm, rcond, work, rwork,
474  \$ info )
475 *
476 * Check error code from ZPPCON.
477 *
478  IF( info.NE.0 )
479  \$ CALL alaerh( path, 'ZPPCON', info, 0, uplo, n, n, -1,
480  \$ -1, -1, imat, nfail, nerrs, nout )
481 *
482  result( 8 ) = dget06( rcond, rcondc )
483 *
484 * Print the test ratio if greater than or equal to THRESH.
485 *
486  IF( result( 8 ).GE.thresh ) THEN
487  IF( nfail.EQ.0 .AND. nerrs.EQ.0 )
488  \$ CALL alahd( nout, path )
489  WRITE( nout, fmt = 9999 )uplo, n, imat, 8,
490  \$ result( 8 )
491  nfail = nfail + 1
492  END IF
493  nrun = nrun + 1
494 *
495  90 CONTINUE
496  100 CONTINUE
497  110 CONTINUE
498 *
499 * Print a summary of the results.
500 *
501  CALL alasum( path, nout, nfail, nrun, nerrs )
502 *
503  9999 FORMAT( ' UPLO = ''', a1, ''', N =', i5, ', type ', i2, ', test ',
504  \$ i2, ', ratio =', g12.5 )
505  9998 FORMAT( ' UPLO = ''', a1, ''', N =', i5, ', NRHS=', i3, ', type ',
506  \$ i2, ', test(', i2, ') =', g12.5 )
507  RETURN
508 *
509 * End of ZCHKPP
510 *
511  END
subroutine zlatms(M, N, DIST, ISEED, SYM, D, MODE, COND, DMAX, KL, KU, PACK, A, LDA, WORK, INFO)
ZLATMS
Definition: zlatms.f:334
subroutine alasum(TYPE, NOUT, NFAIL, NRUN, NERRS)
ALASUM
Definition: alasum.f:75
subroutine zcopy(N, ZX, INCX, ZY, INCY)
ZCOPY
Definition: zcopy.f:83
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 zlaipd(N, A, INDA, VINDA)
ZLAIPD
Definition: zlaipd.f:85
subroutine zpptri(UPLO, N, AP, INFO)
ZPPTRI
Definition: zpptri.f:95
subroutine zpptrs(UPLO, N, NRHS, AP, B, LDB, INFO)
ZPPTRS
Definition: zpptrs.f:110
subroutine zerrpo(PATH, NUNIT)
ZERRPO
Definition: zerrpo.f:57
subroutine zpptrf(UPLO, N, AP, INFO)
ZPPTRF
Definition: zpptrf.f:121
subroutine zppcon(UPLO, N, AP, ANORM, RCOND, WORK, RWORK, INFO)
ZPPCON
Definition: zppcon.f:120
subroutine alahd(IOUNIT, PATH)
ALAHD
Definition: alahd.f:107
subroutine zppt03(UPLO, N, A, AINV, WORK, LDWORK, RWORK, RCOND, RESID)
ZPPT03
Definition: zppt03.f:112
subroutine alaerh(PATH, SUBNAM, INFO, INFOE, OPTS, M, N, KL, KU, N5, IMAT, NFAIL, NERRS, NOUT)
ALAERH
Definition: alaerh.f:149
subroutine zppt02(UPLO, N, NRHS, A, X, LDX, B, LDB, RWORK, RESID)
ZPPT02
Definition: zppt02.f:125
subroutine zppt01(UPLO, N, A, AFAC, RWORK, RESID)
ZPPT01
Definition: zppt01.f:97
subroutine zlatb4(PATH, IMAT, M, N, TYPE, KL, KU, ANORM, MODE, CNDNUM, DIST)
ZLATB4
Definition: zlatb4.f:123
subroutine zget04(N, NRHS, X, LDX, XACT, LDXACT, RCOND, RESID)
ZGET04
Definition: zget04.f:104
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 zchkpp(DOTYPE, NN, NVAL, NNS, NSVAL, THRESH, TSTERR, NMAX, A, AFAC, AINV, B, X, XACT, WORK, RWORK, NOUT)
ZCHKPP
Definition: zchkpp.f:161
subroutine zppt05(UPLO, N, NRHS, AP, B, LDB, X, LDX, XACT, LDXACT, FERR, BERR, RESLTS)
ZPPT05
Definition: zppt05.f:159
subroutine zpprfs(UPLO, N, NRHS, AP, AFP, B, LDB, X, LDX, FERR, BERR, WORK, RWORK, INFO)
ZPPRFS
Definition: zpprfs.f:173