3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
11 * SUBROUTINE ZCHKSP( DOTYPE, NN, NVAL, NNS, NSVAL, THRESH, TSTERR,
12 * NMAX, A, AFAC, AINV, B, X, XACT, WORK, RWORK,
15 * .. Scalar Arguments ..
17 * INTEGER NMAX, NN, NNS, NOUT
18 * DOUBLE PRECISION THRESH
20 * .. Array Arguments ..
22 * INTEGER IWORK( * ), NSVAL( * ), NVAL( * )
23 * DOUBLE PRECISION RWORK( * )
24 * COMPLEX*16 A( * ), AFAC( * ), AINV( * ), B( * ),
25 * $ WORK( * ), X( * ), XACT( * )
34 *> ZCHKSP tests ZSPTRF, -TRI, -TRS, -RFS, and -CON
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.
51 *> The number of values of N contained in the vector NVAL.
56 *> NVAL is INTEGER array, dimension (NN)
57 *> The values of the matrix dimension N.
63 *> The number of values of NRHS contained in the vector NSVAL.
68 *> NSVAL is INTEGER array, dimension (NNS)
69 *> The values of the number of right hand sides NRHS.
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.
83 *> Flag that indicates whether error exits are to be tested.
89 *> The maximum value permitted for N, used in dimensioning the
95 *> A is COMPLEX*16 array, dimension
101 *> AFAC is COMPLEX*16 array, dimension
107 *> AINV is COMPLEX*16 array, dimension
113 *> B is COMPLEX*16 array, dimension (NMAX*NSMAX)
114 *> where NSMAX is the largest entry in NSVAL.
119 *> X is COMPLEX*16 array, dimension (NMAX*NSMAX)
124 *> XACT is COMPLEX*16 array, dimension (NMAX*NSMAX)
129 *> WORK is COMPLEX*16 array, dimension
130 *> (NMAX*max(2,NSMAX))
135 *> RWORK is DOUBLE PRECISION array,
136 *> dimension (NMAX+2*NSMAX)
141 *> IWORK is INTEGER array, dimension (NMAX)
147 *> The unit number for output.
153 *> \author Univ. of Tennessee
154 *> \author Univ. of California Berkeley
155 *> \author Univ. of Colorado Denver
158 *> \date November 2011
160 *> \ingroup complex16_lin
162 * =====================================================================
163 SUBROUTINE ZCHKSP( DOTYPE, NN, NVAL, NNS, NSVAL, THRESH, TSTERR,
164 $ NMAX, A, AFAC, AINV, B, X, XACT, WORK, RWORK,
167 * -- LAPACK test routine (version 3.4.0) --
168 * -- LAPACK is a software package provided by Univ. of Tennessee, --
169 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
172 * .. Scalar Arguments ..
174 INTEGER NMAX, NN, NNS, NOUT
175 DOUBLE PRECISION THRESH
177 * .. Array Arguments ..
179 INTEGER IWORK( * ), NSVAL( * ), NVAL( * )
180 DOUBLE PRECISION RWORK( * )
181 COMPLEX*16 A( * ), AFAC( * ), AINV( * ), B( * ),
182 $ WORK( * ), X( * ), XACT( * )
185 * =====================================================================
188 DOUBLE PRECISION ZERO
189 PARAMETER ( ZERO = 0.0D+0 )
191 PARAMETER ( NTYPES = 11 )
193 PARAMETER ( NTESTS = 8 )
195 * .. Local Scalars ..
196 LOGICAL TRFCON, ZEROT
197 CHARACTER DIST, PACKIT, TYPE, UPLO, XTYPE
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
206 INTEGER ISEED( 4 ), ISEEDY( 4 )
207 DOUBLE PRECISION RESULT( NTESTS )
209 * .. External Functions ..
211 DOUBLE PRECISION DGET06, ZLANSP
212 EXTERNAL LSAME, DGET06, ZLANSP
214 * .. External Subroutines ..
215 EXTERNAL ALAERH, ALAHD, ALASUM, ZCOPY, ZERRSY, ZGET04,
216 $ ZLACPY, ZLARHS, ZLATB4, ZLATMS, ZLATSP, ZPPT05,
217 $ ZSPCON, ZSPRFS, ZSPT01, ZSPT02, ZSPT03, ZSPTRF,
220 * .. Intrinsic Functions ..
223 * .. Scalars in Common ..
228 * .. Common blocks ..
229 COMMON / INFOC / INFOT, NUNIT, OK, LERR
230 COMMON / SRNAMC / SRNAMT
232 * .. Data statements ..
233 DATA ISEEDY / 1988, 1989, 1990, 1991 /
234 DATA UPLOS / 'U', 'L' /
236 * .. Executable Statements ..
238 * Initialize constants and the random number seed.
240 PATH( 1: 1 ) = 'Zomplex precision'
246 ISEED( I ) = ISEEDY( I )
249 * Test the error exits
252 $ CALL ZERRSY( PATH, NOUT )
255 * Do for each value of N in NVAL
265 DO 160 IMAT = 1, NIMAT
267 * Do the tests only if DOTYPE( IMAT ) is true.
269 IF( .NOT.DOTYPE( IMAT ) )
272 * Skip types 3, 4, 5, or 6 if the matrix size is too small.
274 ZEROT = IMAT.GE.3 .AND. IMAT.LE.6
275 IF( ZEROT .AND. N.LT.IMAT-2 )
278 * Do first for UPLO = 'U', then for UPLO = 'L'
281 UPLO = UPLOS( IUPLO )
282 IF( LSAME( UPLO, 'U' ) ) THEN
288 IF( IMAT.NE.NTYPES ) THEN
290 * Set up parameters with ZLATB4 and generate a test
291 * matrix with ZLATMS.
293 CALL ZLATB4( PATH, IMAT, N, N, TYPE, KL, KU, ANORM,
294 $ MODE, CNDNUM, DIST )
297 CALL ZLATMS( N, N, DIST, ISEED, TYPE, RWORK, MODE,
298 $ CNDNUM, ANORM, KL, KU, PACKIT, A, LDA,
301 * Check error code from ZLATMS.
304 CALL ALAERH( PATH, 'ZLATMS', INFO, 0, UPLO, N, N,
305 $ -1, -1, -1, IMAT, NFAIL, NERRS, NOUT )
309 * For types 3-6, zero one or more rows and columns of
310 * the matrix to test that INFO is returned correctly.
315 ELSE IF( IMAT.EQ.4 ) THEN
323 * Set row and column IZERO to zero.
325 IF( IUPLO.EQ.1 ) THEN
326 IOFF = ( IZERO-1 )*IZERO / 2
327 DO 20 I = 1, IZERO - 1
337 DO 40 I = 1, IZERO - 1
347 IF( IUPLO.EQ.1 ) THEN
349 * Set the first IZERO rows and columns to zero.
361 * Set the last IZERO rows and columns to zero.
378 * Use a special block diagonal matrix to test alternate
379 * code for the 2 x 2 blocks.
381 CALL ZLATSP( UPLO, N, A, ISEED )
384 * Compute the L*D*L' or U*D*U' factorization of the matrix.
387 CALL ZCOPY( NPP, A, 1, AFAC, 1 )
389 CALL ZSPTRF( UPLO, N, AFAC, IWORK, INFO )
391 * Adjust the expected value of INFO to account for
397 IF( IWORK( K ).LT.0 ) THEN
398 IF( IWORK( K ).NE.-K ) THEN
402 ELSE IF( IWORK( K ).NE.K ) THEN
408 * Check error code from ZSPTRF.
411 $ CALL ALAERH( PATH, 'ZSPTRF', INFO, K, UPLO, N, N, -1,
412 $ -1, -1, IMAT, NFAIL, NERRS, NOUT )
420 * Reconstruct matrix from factors and compute residual.
422 CALL ZSPT01( UPLO, N, A, AFAC, IWORK, AINV, LDA, RWORK,
427 * Form the inverse and compute the residual.
429 IF( .NOT.TRFCON ) THEN
430 CALL ZCOPY( NPP, AFAC, 1, AINV, 1 )
432 CALL ZSPTRI( UPLO, N, AINV, IWORK, WORK, INFO )
434 * Check error code from ZSPTRI.
437 $ CALL ALAERH( PATH, 'ZSPTRI', INFO, 0, UPLO, N, N,
438 $ -1, -1, -1, IMAT, NFAIL, NERRS, NOUT )
440 CALL ZSPT03( UPLO, N, A, AINV, WORK, LDA, RWORK,
441 $ RCONDC, RESULT( 2 ) )
445 * Print information about the tests that did not pass
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,
459 * Do only the condition estimate if INFO is not 0.
470 * Solve and compute residual for A * X = B.
473 CALL ZLARHS( PATH, XTYPE, UPLO, ' ', N, N, KL, KU,
474 $ NRHS, A, LDA, XACT, LDA, B, LDA, ISEED,
476 CALL ZLACPY( 'Full', N, NRHS, B, LDA, X, LDA )
479 CALL ZSPTRS( UPLO, N, NRHS, AFAC, IWORK, X, LDA,
482 * Check error code from ZSPTRS.
485 $ CALL ALAERH( PATH, 'ZSPTRS', INFO, 0, UPLO, N, N,
486 $ -1, -1, NRHS, IMAT, NFAIL, NERRS,
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 ) )
494 * Check solution from generated exact solution.
496 CALL ZGET04( N, NRHS, X, LDA, XACT, LDA, RCONDC,
500 * Use iterative refinement to improve the solution.
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 )
507 * Check error code from ZSPRFS.
510 $ CALL ALAERH( PATH, 'ZSPRFS', INFO, 0, UPLO, N, N,
511 $ -1, -1, NRHS, IMAT, NFAIL, NERRS,
514 CALL ZGET04( N, NRHS, X, LDA, XACT, LDA, RCONDC,
516 CALL ZPPT05( UPLO, N, NRHS, A, B, LDA, X, LDA, XACT,
517 $ LDA, RWORK, RWORK( NRHS+1 ),
520 * Print information about the tests that did not pass
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,
536 * Get an estimate of RCOND = 1/CNDNUM.
539 ANORM = ZLANSP( '1', UPLO, N, A, RWORK )
541 CALL ZSPCON( UPLO, N, AFAC, IWORK, ANORM, RCOND, WORK,
544 * Check error code from ZSPCON.
547 $ CALL ALAERH( PATH, 'ZSPCON', INFO, 0, UPLO, N, N, -1,
548 $ -1, -1, IMAT, NFAIL, NERRS, NOUT )
550 RESULT( 8 ) = DGET06( RCOND, RCONDC )
552 * Print the test ratio if it is .GE. THRESH.
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,
566 * Print a summary of the results.
568 CALL ALASUM( PATH, NOUT, NFAIL, NRUN, NERRS )
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 )