LAPACK  3.6.1
LAPACK: Linear Algebra PACKage
cchkpp.f
Go to the documentation of this file.
1 *> \brief \b CCHKPP
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 CCHKPP( 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 * REAL THRESH
19 * ..
20 * .. Array Arguments ..
21 * LOGICAL DOTYPE( * )
22 * INTEGER 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 *> CCHKPP tests CPPTRF, -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 REAL
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 array, dimension
96 *> (NMAX*(NMAX+1)/2)
97 *> \endverbatim
98 *>
99 *> \param[out] AFAC
100 *> \verbatim
101 *> AFAC is COMPLEX array, dimension
102 *> (NMAX*(NMAX+1)/2)
103 *> \endverbatim
104 *>
105 *> \param[out] AINV
106 *> \verbatim
107 *> AINV is COMPLEX array, dimension
108 *> (NMAX*(NMAX+1)/2)
109 *> \endverbatim
110 *>
111 *> \param[out] B
112 *> \verbatim
113 *> B is COMPLEX 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 array, dimension (NMAX*NSMAX)
120 *> \endverbatim
121 *>
122 *> \param[out] XACT
123 *> \verbatim
124 *> XACT is COMPLEX array, dimension (NMAX*NSMAX)
125 *> \endverbatim
126 *>
127 *> \param[out] WORK
128 *> \verbatim
129 *> WORK is COMPLEX array, dimension
130 *> (NMAX*max(3,NSMAX))
131 *> \endverbatim
132 *>
133 *> \param[out] RWORK
134 *> \verbatim
135 *> RWORK is REAL 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 November 2011
154 *
155 *> \ingroup complex_lin
156 *
157 * =====================================================================
158  SUBROUTINE cchkpp( 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.4.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 * November 2011
166 *
167 * .. Scalar Arguments ..
168  LOGICAL TSTERR
169  INTEGER NMAX, NN, NNS, NOUT
170  REAL THRESH
171 * ..
172 * .. Array Arguments ..
173  LOGICAL DOTYPE( * )
174  INTEGER NSVAL( * ), NVAL( * )
175  REAL RWORK( * )
176  COMPLEX A( * ), AFAC( * ), AINV( * ), B( * ),
177  $ work( * ), x( * ), xact( * )
178 * ..
179 *
180 * =====================================================================
181 *
182 * .. Parameters ..
183  REAL ZERO
184  parameter ( zero = 0.0e+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  REAL ANORM, CNDNUM, RCOND, RCONDC
198 * ..
199 * .. Local Arrays ..
200  CHARACTER PACKS( 2 ), UPLOS( 2 )
201  INTEGER ISEED( 4 ), ISEEDY( 4 )
202  REAL RESULT( ntests )
203 * ..
204 * .. External Functions ..
205  REAL CLANHP, SGET06
206  EXTERNAL clanhp, sget06
207 * ..
208 * .. External Subroutines ..
209  EXTERNAL alaerh, alahd, alasum, ccopy, cerrpo, cget04,
212  $ cpptri, cpptrs
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 ) = 'Complex 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 cerrpo( 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 CLATB4 and generate a test matrix
279 * with CLATMS.
280 *
281  CALL clatb4( path, imat, n, n, TYPE, KL, KU, ANORM, MODE,
282  $ cndnum, dist )
283 *
284  srnamt = 'CLATMS'
285  CALL clatms( n, n, dist, iseed, TYPE, RWORK, MODE,
286  $ cndnum, anorm, kl, ku, packit, a, lda, work,
287  $ info )
288 *
289 * Check error code from CLATMS.
290 *
291  IF( info.NE.0 ) THEN
292  CALL alaerh( path, 'CLATMS', 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 claipd( n, a, 2, 1 )
340  ELSE
341  CALL claipd( 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 ccopy( npp, a, 1, afac, 1 )
348  srnamt = 'CPPTRF'
349  CALL cpptrf( uplo, n, afac, info )
350 *
351 * Check error code from CPPTRF.
352 *
353  IF( info.NE.izero ) THEN
354  CALL alaerh( path, 'CPPTRF', 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 ccopy( npp, afac, 1, ainv, 1 )
368  CALL cppt01( uplo, n, a, ainv, rwork, result( 1 ) )
369 *
370 *+ TEST 2
371 * Form the inverse and compute the residual.
372 *
373  CALL ccopy( npp, afac, 1, ainv, 1 )
374  srnamt = 'CPPTRI'
375  CALL cpptri( uplo, n, ainv, info )
376 *
377 * Check error code from CPPTRI.
378 *
379  IF( info.NE.0 )
380  $ CALL alaerh( path, 'CPPTRI', info, 0, uplo, n, n, -1,
381  $ -1, -1, imat, nfail, nerrs, nout )
382 *
383  CALL cppt03( 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 = 'CLARHS'
407  CALL clarhs( path, xtype, uplo, ' ', n, n, kl, ku,
408  $ nrhs, a, lda, xact, lda, b, lda, iseed,
409  $ info )
410  CALL clacpy( 'Full', n, nrhs, b, lda, x, lda )
411 *
412  srnamt = 'CPPTRS'
413  CALL cpptrs( uplo, n, nrhs, afac, x, lda, info )
414 *
415 * Check error code from CPPTRS.
416 *
417  IF( info.NE.0 )
418  $ CALL alaerh( path, 'CPPTRS', info, 0, uplo, n, n,
419  $ -1, -1, nrhs, imat, nfail, nerrs,
420  $ nout )
421 *
422  CALL clacpy( 'Full', n, nrhs, b, lda, work, lda )
423  CALL cppt02( 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 cget04( 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 = 'CPPRFS'
436  CALL cpprfs( 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 CPPRFS.
441 *
442  IF( info.NE.0 )
443  $ CALL alaerh( path, 'CPPRFS', info, 0, uplo, n, n,
444  $ -1, -1, nrhs, imat, nfail, nerrs,
445  $ nout )
446 *
447  CALL cget04( n, nrhs, x, lda, xact, lda, rcondc,
448  $ result( 5 ) )
449  CALL cppt05( 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 = clanhp( '1', uplo, n, a, rwork )
472  srnamt = 'CPPCON'
473  CALL cppcon( uplo, n, afac, anorm, rcond, work, rwork,
474  $ info )
475 *
476 * Check error code from CPPCON.
477 *
478  IF( info.NE.0 )
479  $ CALL alaerh( path, 'CPPCON', info, 0, uplo, n, n, -1,
480  $ -1, -1, imat, nfail, nerrs, nout )
481 *
482  result( 8 ) = sget06( 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 CCHKPP
510 *
511  END
subroutine alahd(IOUNIT, PATH)
ALAHD
Definition: alahd.f:95
subroutine alaerh(PATH, SUBNAM, INFO, INFOE, OPTS, M, N, KL, KU, N5, IMAT, NFAIL, NERRS, NOUT)
ALAERH
Definition: alaerh.f:149
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 cpptrs(UPLO, N, NRHS, AP, B, LDB, INFO)
CPPTRS
Definition: cpptrs.f:110
subroutine claipd(N, A, INDA, VINDA)
CLAIPD
Definition: claipd.f:85
subroutine cppt01(UPLO, N, A, AFAC, RWORK, RESID)
CPPT01
Definition: cppt01.f:97
subroutine cppt05(UPLO, N, NRHS, AP, B, LDB, X, LDX, XACT, LDXACT, FERR, BERR, RESLTS)
CPPT05
Definition: cppt05.f:159
subroutine cpptrf(UPLO, N, AP, INFO)
CPPTRF
Definition: cpptrf.f:121
subroutine cchkpp(DOTYPE, NN, NVAL, NNS, NSVAL, THRESH, TSTERR, NMAX, A, AFAC, AINV, B, X, XACT, WORK, RWORK, NOUT)
CCHKPP
Definition: cchkpp.f:161
subroutine cppt03(UPLO, N, A, AINV, WORK, LDWORK, RWORK, RCOND, RESID)
CPPT03
Definition: cppt03.f:112
subroutine cppcon(UPLO, N, AP, ANORM, RCOND, WORK, RWORK, INFO)
CPPCON
Definition: cppcon.f:120
subroutine cppt02(UPLO, N, NRHS, A, X, LDX, B, LDB, RWORK, RESID)
CPPT02
Definition: cppt02.f:125
subroutine cpptri(UPLO, N, AP, INFO)
CPPTRI
Definition: cpptri.f:95
subroutine clatms(M, N, DIST, ISEED, SYM, D, MODE, COND, DMAX, KL, KU, PACK, A, LDA, WORK, INFO)
CLATMS
Definition: clatms.f:334
subroutine cpprfs(UPLO, N, NRHS, AP, AFP, B, LDB, X, LDX, FERR, BERR, WORK, RWORK, INFO)
CPPRFS
Definition: cpprfs.f:173
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 ccopy(N, CX, INCX, CY, INCY)
CCOPY
Definition: ccopy.f:52
subroutine clatb4(PATH, IMAT, M, N, TYPE, KL, KU, ANORM, MODE, CNDNUM, DIST)
CLATB4
Definition: clatb4.f:123
subroutine cget04(N, NRHS, X, LDX, XACT, LDXACT, RCOND, RESID)
CGET04
Definition: cget04.f:104
subroutine cerrpo(PATH, NUNIT)
CERRPO
Definition: cerrpo.f:57
subroutine alasum(TYPE, NOUT, NFAIL, NRUN, NERRS)
ALASUM
Definition: alasum.f:75