LAPACK  3.8.0
LAPACK: Linear Algebra PACKage
zchksp.f
Go to the documentation of this file.
1 *> \brief \b ZCHKSP
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 ZCHKSP( DOTYPE, NN, NVAL, NNS, NSVAL, THRESH, TSTERR,
12 * NMAX, A, AFAC, AINV, B, X, XACT, WORK, RWORK,
13 * IWORK, 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 IWORK( * ), 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 *> ZCHKSP tests ZSPTRF, -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(2,NSMAX))
131 *> \endverbatim
132 *>
133 *> \param[out] RWORK
134 *> \verbatim
135 *> RWORK is DOUBLE PRECISION array,
136 *> dimension (NMAX+2*NSMAX)
137 *> \endverbatim
138 *>
139 *> \param[out] IWORK
140 *> \verbatim
141 *> IWORK is INTEGER array, dimension (NMAX)
142 *> \endverbatim
143 *>
144 *> \param[in] NOUT
145 *> \verbatim
146 *> NOUT is INTEGER
147 *> The unit number for output.
148 *> \endverbatim
149 *
150 * Authors:
151 * ========
152 *
153 *> \author Univ. of Tennessee
154 *> \author Univ. of California Berkeley
155 *> \author Univ. of Colorado Denver
156 *> \author NAG Ltd.
157 *
158 *> \date December 2016
159 *
160 *> \ingroup complex16_lin
161 *
162 * =====================================================================
163  SUBROUTINE zchksp( DOTYPE, NN, NVAL, NNS, NSVAL, THRESH, TSTERR,
164  $ NMAX, A, AFAC, AINV, B, X, XACT, WORK, RWORK,
165  $ IWORK, NOUT )
166 *
167 * -- LAPACK test routine (version 3.7.0) --
168 * -- LAPACK is a software package provided by Univ. of Tennessee, --
169 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
170 * December 2016
171 *
172 * .. Scalar Arguments ..
173  LOGICAL TSTERR
174  INTEGER NMAX, NN, NNS, NOUT
175  DOUBLE PRECISION THRESH
176 * ..
177 * .. Array Arguments ..
178  LOGICAL DOTYPE( * )
179  INTEGER IWORK( * ), NSVAL( * ), NVAL( * )
180  DOUBLE PRECISION RWORK( * )
181  COMPLEX*16 A( * ), AFAC( * ), AINV( * ), B( * ),
182  $ work( * ), x( * ), xact( * )
183 * ..
184 *
185 * =====================================================================
186 *
187 * .. Parameters ..
188  DOUBLE PRECISION ZERO
189  parameter( zero = 0.0d+0 )
190  INTEGER NTYPES
191  parameter( ntypes = 11 )
192  INTEGER NTESTS
193  parameter( ntests = 8 )
194 * ..
195 * .. Local Scalars ..
196  LOGICAL TRFCON, ZEROT
197  CHARACTER DIST, PACKIT, TYPE, UPLO, XTYPE
198  CHARACTER*3 PATH
199  INTEGER I, I1, I2, IMAT, IN, INFO, IOFF, IRHS, IUPLO,
200  $ izero, j, k, kl, ku, lda, mode, n, nerrs,
201  $ nfail, nimat, npp, nrhs, nrun, nt
202  DOUBLE PRECISION ANORM, CNDNUM, RCOND, RCONDC
203 * ..
204 * .. Local Arrays ..
205  CHARACTER UPLOS( 2 )
206  INTEGER ISEED( 4 ), ISEEDY( 4 )
207  DOUBLE PRECISION RESULT( ntests )
208 * ..
209 * .. External Functions ..
210  LOGICAL LSAME
211  DOUBLE PRECISION DGET06, ZLANSP
212  EXTERNAL lsame, dget06, zlansp
213 * ..
214 * .. External Subroutines ..
215  EXTERNAL alaerh, alahd, alasum, zcopy, zerrsy, zget04,
218  $ zsptri, zsptrs
219 * ..
220 * .. Intrinsic Functions ..
221  INTRINSIC max, min
222 * ..
223 * .. Scalars in Common ..
224  LOGICAL LERR, OK
225  CHARACTER*32 SRNAMT
226  INTEGER INFOT, NUNIT
227 * ..
228 * .. Common blocks ..
229  COMMON / infoc / infot, nunit, ok, lerr
230  COMMON / srnamc / srnamt
231 * ..
232 * .. Data statements ..
233  DATA iseedy / 1988, 1989, 1990, 1991 /
234  DATA uplos / 'U', 'L' /
235 * ..
236 * .. Executable Statements ..
237 *
238 * Initialize constants and the random number seed.
239 *
240  path( 1: 1 ) = 'Zomplex precision'
241  path( 2: 3 ) = 'SP'
242  nrun = 0
243  nfail = 0
244  nerrs = 0
245  DO 10 i = 1, 4
246  iseed( i ) = iseedy( i )
247  10 CONTINUE
248 *
249 * Test the error exits
250 *
251  IF( tsterr )
252  $ CALL zerrsy( path, nout )
253  infot = 0
254 *
255 * Do for each value of N in NVAL
256 *
257  DO 170 in = 1, nn
258  n = nval( in )
259  lda = max( n, 1 )
260  xtype = 'N'
261  nimat = ntypes
262  IF( n.LE.0 )
263  $ nimat = 1
264 *
265  DO 160 imat = 1, nimat
266 *
267 * Do the tests only if DOTYPE( IMAT ) is true.
268 *
269  IF( .NOT.dotype( imat ) )
270  $ GO TO 160
271 *
272 * Skip types 3, 4, 5, or 6 if the matrix size is too small.
273 *
274  zerot = imat.GE.3 .AND. imat.LE.6
275  IF( zerot .AND. n.LT.imat-2 )
276  $ GO TO 160
277 *
278 * Do first for UPLO = 'U', then for UPLO = 'L'
279 *
280  DO 150 iuplo = 1, 2
281  uplo = uplos( iuplo )
282  IF( lsame( uplo, 'U' ) ) THEN
283  packit = 'C'
284  ELSE
285  packit = 'R'
286  END IF
287 *
288  IF( imat.NE.ntypes ) THEN
289 *
290 * Set up parameters with ZLATB4 and generate a test
291 * matrix with ZLATMS.
292 *
293  CALL zlatb4( path, imat, n, n, TYPE, KL, KU, ANORM,
294  $ mode, cndnum, dist )
295 *
296  srnamt = 'ZLATMS'
297  CALL zlatms( n, n, dist, iseed, TYPE, RWORK, MODE,
298  $ cndnum, anorm, kl, ku, packit, a, lda,
299  $ work, info )
300 *
301 * Check error code from ZLATMS.
302 *
303  IF( info.NE.0 ) THEN
304  CALL alaerh( path, 'ZLATMS', info, 0, uplo, n, n,
305  $ -1, -1, -1, imat, nfail, nerrs, nout )
306  GO TO 150
307  END IF
308 *
309 * For types 3-6, zero one or more rows and columns of
310 * the matrix to test that INFO is returned correctly.
311 *
312  IF( zerot ) THEN
313  IF( imat.EQ.3 ) THEN
314  izero = 1
315  ELSE IF( imat.EQ.4 ) THEN
316  izero = n
317  ELSE
318  izero = n / 2 + 1
319  END IF
320 *
321  IF( imat.LT.6 ) THEN
322 *
323 * Set row and column IZERO to zero.
324 *
325  IF( iuplo.EQ.1 ) THEN
326  ioff = ( izero-1 )*izero / 2
327  DO 20 i = 1, izero - 1
328  a( ioff+i ) = zero
329  20 CONTINUE
330  ioff = ioff + izero
331  DO 30 i = izero, n
332  a( ioff ) = zero
333  ioff = ioff + i
334  30 CONTINUE
335  ELSE
336  ioff = izero
337  DO 40 i = 1, izero - 1
338  a( ioff ) = zero
339  ioff = ioff + n - i
340  40 CONTINUE
341  ioff = ioff - izero
342  DO 50 i = izero, n
343  a( ioff+i ) = zero
344  50 CONTINUE
345  END IF
346  ELSE
347  IF( iuplo.EQ.1 ) THEN
348 *
349 * Set the first IZERO rows and columns to zero.
350 *
351  ioff = 0
352  DO 70 j = 1, n
353  i2 = min( j, izero )
354  DO 60 i = 1, i2
355  a( ioff+i ) = zero
356  60 CONTINUE
357  ioff = ioff + j
358  70 CONTINUE
359  ELSE
360 *
361 * Set the last IZERO rows and columns to zero.
362 *
363  ioff = 0
364  DO 90 j = 1, n
365  i1 = max( j, izero )
366  DO 80 i = i1, n
367  a( ioff+i ) = zero
368  80 CONTINUE
369  ioff = ioff + n - j
370  90 CONTINUE
371  END IF
372  END IF
373  ELSE
374  izero = 0
375  END IF
376  ELSE
377 *
378 * Use a special block diagonal matrix to test alternate
379 * code for the 2 x 2 blocks.
380 *
381  CALL zlatsp( uplo, n, a, iseed )
382  END IF
383 *
384 * Compute the L*D*L' or U*D*U' factorization of the matrix.
385 *
386  npp = n*( n+1 ) / 2
387  CALL zcopy( npp, a, 1, afac, 1 )
388  srnamt = 'ZSPTRF'
389  CALL zsptrf( uplo, n, afac, iwork, info )
390 *
391 * Adjust the expected value of INFO to account for
392 * pivoting.
393 *
394  k = izero
395  IF( k.GT.0 ) THEN
396  100 CONTINUE
397  IF( iwork( k ).LT.0 ) THEN
398  IF( iwork( k ).NE.-k ) THEN
399  k = -iwork( k )
400  GO TO 100
401  END IF
402  ELSE IF( iwork( k ).NE.k ) THEN
403  k = iwork( k )
404  GO TO 100
405  END IF
406  END IF
407 *
408 * Check error code from ZSPTRF.
409 *
410  IF( info.NE.k )
411  $ CALL alaerh( path, 'ZSPTRF', info, k, uplo, n, n, -1,
412  $ -1, -1, imat, nfail, nerrs, nout )
413  IF( info.NE.0 ) THEN
414  trfcon = .true.
415  ELSE
416  trfcon = .false.
417  END IF
418 *
419 *+ TEST 1
420 * Reconstruct matrix from factors and compute residual.
421 *
422  CALL zspt01( uplo, n, a, afac, iwork, ainv, lda, rwork,
423  $ result( 1 ) )
424  nt = 1
425 *
426 *+ TEST 2
427 * Form the inverse and compute the residual.
428 *
429  IF( .NOT.trfcon ) THEN
430  CALL zcopy( npp, afac, 1, ainv, 1 )
431  srnamt = 'ZSPTRI'
432  CALL zsptri( uplo, n, ainv, iwork, work, info )
433 *
434 * Check error code from ZSPTRI.
435 *
436  IF( info.NE.0 )
437  $ CALL alaerh( path, 'ZSPTRI', info, 0, uplo, n, n,
438  $ -1, -1, -1, imat, nfail, nerrs, nout )
439 *
440  CALL zspt03( uplo, n, a, ainv, work, lda, rwork,
441  $ rcondc, result( 2 ) )
442  nt = 2
443  END IF
444 *
445 * Print information about the tests that did not pass
446 * the threshold.
447 *
448  DO 110 k = 1, nt
449  IF( result( k ).GE.thresh ) THEN
450  IF( nfail.EQ.0 .AND. nerrs.EQ.0 )
451  $ CALL alahd( nout, path )
452  WRITE( nout, fmt = 9999 )uplo, n, imat, k,
453  $ result( k )
454  nfail = nfail + 1
455  END IF
456  110 CONTINUE
457  nrun = nrun + nt
458 *
459 * Do only the condition estimate if INFO is not 0.
460 *
461  IF( trfcon ) THEN
462  rcondc = zero
463  GO TO 140
464  END IF
465 *
466  DO 130 irhs = 1, nns
467  nrhs = nsval( irhs )
468 *
469 *+ TEST 3
470 * Solve and compute residual for A * X = B.
471 *
472  srnamt = 'ZLARHS'
473  CALL zlarhs( path, xtype, uplo, ' ', n, n, kl, ku,
474  $ nrhs, a, lda, xact, lda, b, lda, iseed,
475  $ info )
476  CALL zlacpy( 'Full', n, nrhs, b, lda, x, lda )
477 *
478  srnamt = 'ZSPTRS'
479  CALL zsptrs( uplo, n, nrhs, afac, iwork, x, lda,
480  $ info )
481 *
482 * Check error code from ZSPTRS.
483 *
484  IF( info.NE.0 )
485  $ CALL alaerh( path, 'ZSPTRS', info, 0, uplo, n, n,
486  $ -1, -1, nrhs, imat, nfail, nerrs,
487  $ nout )
488 *
489  CALL zlacpy( 'Full', n, nrhs, b, lda, work, lda )
490  CALL zspt02( uplo, n, nrhs, a, x, lda, work, lda,
491  $ rwork, result( 3 ) )
492 *
493 *+ TEST 4
494 * Check solution from generated exact solution.
495 *
496  CALL zget04( n, nrhs, x, lda, xact, lda, rcondc,
497  $ result( 4 ) )
498 *
499 *+ TESTS 5, 6, and 7
500 * Use iterative refinement to improve the solution.
501 *
502  srnamt = 'ZSPRFS'
503  CALL zsprfs( uplo, n, nrhs, a, afac, iwork, b, lda, x,
504  $ lda, rwork, rwork( nrhs+1 ), work,
505  $ rwork( 2*nrhs+1 ), info )
506 *
507 * Check error code from ZSPRFS.
508 *
509  IF( info.NE.0 )
510  $ CALL alaerh( path, 'ZSPRFS', info, 0, uplo, n, n,
511  $ -1, -1, nrhs, imat, nfail, nerrs,
512  $ nout )
513 *
514  CALL zget04( n, nrhs, x, lda, xact, lda, rcondc,
515  $ result( 5 ) )
516  CALL zppt05( uplo, n, nrhs, a, b, lda, x, lda, xact,
517  $ lda, rwork, rwork( nrhs+1 ),
518  $ result( 6 ) )
519 *
520 * Print information about the tests that did not pass
521 * the threshold.
522 *
523  DO 120 k = 3, 7
524  IF( result( k ).GE.thresh ) THEN
525  IF( nfail.EQ.0 .AND. nerrs.EQ.0 )
526  $ CALL alahd( nout, path )
527  WRITE( nout, fmt = 9998 )uplo, n, nrhs, imat,
528  $ k, result( k )
529  nfail = nfail + 1
530  END IF
531  120 CONTINUE
532  nrun = nrun + 5
533  130 CONTINUE
534 *
535 *+ TEST 8
536 * Get an estimate of RCOND = 1/CNDNUM.
537 *
538  140 CONTINUE
539  anorm = zlansp( '1', uplo, n, a, rwork )
540  srnamt = 'ZSPCON'
541  CALL zspcon( uplo, n, afac, iwork, anorm, rcond, work,
542  $ info )
543 *
544 * Check error code from ZSPCON.
545 *
546  IF( info.NE.0 )
547  $ CALL alaerh( path, 'ZSPCON', info, 0, uplo, n, n, -1,
548  $ -1, -1, imat, nfail, nerrs, nout )
549 *
550  result( 8 ) = dget06( rcond, rcondc )
551 *
552 * Print the test ratio if it is .GE. THRESH.
553 *
554  IF( result( 8 ).GE.thresh ) THEN
555  IF( nfail.EQ.0 .AND. nerrs.EQ.0 )
556  $ CALL alahd( nout, path )
557  WRITE( nout, fmt = 9999 )uplo, n, imat, 8,
558  $ result( 8 )
559  nfail = nfail + 1
560  END IF
561  nrun = nrun + 1
562  150 CONTINUE
563  160 CONTINUE
564  170 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, ', type ', i2, ', test ',
571  $ i2, ', ratio =', g12.5 )
572  9998 FORMAT( ' UPLO = ''', a1, ''', N =', i5, ', NRHS=', i3, ', type ',
573  $ i2, ', test(', i2, ') =', g12.5 )
574  RETURN
575 *
576 * End of ZCHKSP
577 *
578  END
subroutine alahd(IOUNIT, PATH)
ALAHD
Definition: alahd.f:107
subroutine zsptrs(UPLO, N, NRHS, AP, IPIV, B, LDB, INFO)
ZSPTRS
Definition: zsptrs.f:117
subroutine zerrsy(PATH, NUNIT)
ZERRSY
Definition: zerrsy.f:57
subroutine zsptrf(UPLO, N, AP, IPIV, INFO)
ZSPTRF
Definition: zsptrf.f:160
subroutine zget04(N, NRHS, X, LDX, XACT, LDXACT, RCOND, RESID)
ZGET04
Definition: zget04.f:104
subroutine zcopy(N, ZX, INCX, ZY, INCY)
ZCOPY
Definition: zcopy.f:83
subroutine alaerh(PATH, SUBNAM, INFO, INFOE, OPTS, M, N, KL, KU, N5, IMAT, NFAIL, NERRS, NOUT)
ALAERH
Definition: alaerh.f:149
subroutine zspcon(UPLO, N, AP, IPIV, ANORM, RCOND, WORK, INFO)
ZSPCON
Definition: zspcon.f:120
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 zspt02(UPLO, N, NRHS, A, X, LDX, B, LDB, RWORK, RESID)
ZSPT02
Definition: zspt02.f:125
subroutine zlatb4(PATH, IMAT, M, N, TYPE, KL, KU, ANORM, MODE, CNDNUM, DIST)
ZLATB4
Definition: zlatb4.f:123
subroutine zlatsp(UPLO, N, X, ISEED)
ZLATSP
Definition: zlatsp.f:86
subroutine zppt05(UPLO, N, NRHS, AP, B, LDB, X, LDX, XACT, LDXACT, FERR, BERR, RESLTS)
ZPPT05
Definition: zppt05.f:159
subroutine zsptri(UPLO, N, AP, IPIV, WORK, INFO)
ZSPTRI
Definition: zsptri.f:111
subroutine zchksp(DOTYPE, NN, NVAL, NNS, NSVAL, THRESH, TSTERR, NMAX, A, AFAC, AINV, B, X, XACT, WORK, RWORK, IWORK, NOUT)
ZCHKSP
Definition: zchksp.f:166
subroutine zlatms(M, N, DIST, ISEED, SYM, D, MODE, COND, DMAX, KL, KU, PACK, A, LDA, WORK, INFO)
ZLATMS
Definition: zlatms.f:334
subroutine zsprfs(UPLO, N, NRHS, AP, AFP, IPIV, B, LDB, X, LDX, FERR, BERR, WORK, RWORK, INFO)
ZSPRFS
Definition: zsprfs.f:182
subroutine zspt03(UPLO, N, A, AINV, WORK, LDW, RWORK, RCOND, RESID)
ZSPT03
Definition: zspt03.f:112
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 zspt01(UPLO, N, A, AFAC, IPIV, C, LDC, RWORK, RESID)
ZSPT01
Definition: zspt01.f:114
subroutine alasum(TYPE, NOUT, NFAIL, NRUN, NERRS)
ALASUM
Definition: alasum.f:75