3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
11 * SUBROUTINE ZCHKGB( DOTYPE, NM, MVAL, NN, NVAL, NNB, NBVAL, NNS,
12 * NSVAL, THRESH, TSTERR, A, LA, AFAC, LAFAC, B,
13 * X, XACT, WORK, RWORK, IWORK, NOUT )
15 * .. Scalar Arguments ..
17 * INTEGER LA, LAFAC, NM, NN, NNB, NNS, NOUT
18 * DOUBLE PRECISION THRESH
20 * .. Array Arguments ..
22 * INTEGER IWORK( * ), MVAL( * ), NBVAL( * ), NSVAL( * ),
24 * DOUBLE PRECISION RWORK( * )
25 * COMPLEX*16 A( * ), AFAC( * ), B( * ), WORK( * ), X( * ),
35 *> ZCHKGB tests ZGBTRF, -TRS, -RFS, and -CON
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.
52 *> The number of values of M contained in the vector MVAL.
57 *> MVAL is INTEGER array, dimension (NM)
58 *> The values of the matrix row dimension M.
64 *> The number of values of N contained in the vector NVAL.
69 *> NVAL is INTEGER array, dimension (NN)
70 *> The values of the matrix column dimension N.
76 *> The number of values of NB contained in the vector NBVAL.
81 *> NBVAL is INTEGER array, dimension (NBVAL)
82 *> The values of the blocksize NB.
88 *> The number of values of NRHS contained in the vector NSVAL.
93 *> NSVAL is INTEGER array, dimension (NNS)
94 *> The values of the number of right hand sides NRHS.
99 *> THRESH is DOUBLE PRECISION
100 *> The threshold value for the test ratios. A result is
101 *> included in the output file if RESULT >= THRESH. To have
102 *> every test ratio printed, use THRESH = 0.
108 *> Flag that indicates whether error exits are to be tested.
113 *> A is COMPLEX*16 array, dimension (LA)
119 *> The length of the array A. LA >= (KLMAX+KUMAX+1)*NMAX
120 *> where KLMAX is the largest entry in the local array KLVAL,
121 *> KUMAX is the largest entry in the local array KUVAL and
122 *> NMAX is the largest entry in the input array NVAL.
127 *> AFAC is COMPLEX*16 array, dimension (LAFAC)
133 *> The length of the array AFAC. LAFAC >= (2*KLMAX+KUMAX+1)*NMAX
134 *> where KLMAX is the largest entry in the local array KLVAL,
135 *> KUMAX is the largest entry in the local array KUVAL and
136 *> NMAX is the largest entry in the input array NVAL.
141 *> B is COMPLEX*16 array, dimension (NMAX*NSMAX)
146 *> X is COMPLEX*16 array, dimension (NMAX*NSMAX)
151 *> XACT is COMPLEX*16 array, dimension (NMAX*NSMAX)
156 *> WORK is COMPLEX*16 array, dimension
157 *> (NMAX*max(3,NSMAX,NMAX))
162 *> RWORK is DOUBLE PRECISION array, dimension
163 *> (max(NMAX,2*NSMAX))
168 *> IWORK is INTEGER array, dimension (NMAX)
174 *> The unit number for output.
180 *> \author Univ. of Tennessee
181 *> \author Univ. of California Berkeley
182 *> \author Univ. of Colorado Denver
185 *> \date November 2011
187 *> \ingroup complex16_lin
189 * =====================================================================
190 SUBROUTINE ZCHKGB( DOTYPE, NM, MVAL, NN, NVAL, NNB, NBVAL, NNS,
191 $ NSVAL, THRESH, TSTERR, A, LA, AFAC, LAFAC, B,
192 $ X, XACT, WORK, RWORK, IWORK, NOUT )
194 * -- LAPACK test routine (version 3.4.0) --
195 * -- LAPACK is a software package provided by Univ. of Tennessee, --
196 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
199 * .. Scalar Arguments ..
201 INTEGER LA, LAFAC, NM, NN, NNB, NNS, NOUT
202 DOUBLE PRECISION THRESH
204 * .. Array Arguments ..
206 INTEGER IWORK( * ), MVAL( * ), NBVAL( * ), NSVAL( * ),
208 DOUBLE PRECISION RWORK( * )
209 COMPLEX*16 A( * ), AFAC( * ), B( * ), WORK( * ), X( * ),
213 * =====================================================================
216 DOUBLE PRECISION ONE, ZERO
217 PARAMETER ( ONE = 1.0D+0, ZERO = 0.0D+0 )
218 INTEGER NTYPES, NTESTS
219 PARAMETER ( NTYPES = 8, NTESTS = 7 )
221 PARAMETER ( NBW = 4, NTRAN = 3 )
223 * .. Local Scalars ..
224 LOGICAL TRFCON, ZEROT
225 CHARACTER DIST, NORM, TRANS, TYPE, XTYPE
227 INTEGER I, I1, I2, IKL, IKU, IM, IMAT, IN, INB, INFO,
228 $ IOFF, IRHS, ITRAN, IZERO, J, K, KL, KOFF, KU,
229 $ LDA, LDAFAC, LDB, M, MODE, N, NB, NERRS, NFAIL,
230 $ NIMAT, NKL, NKU, NRHS, NRUN
231 DOUBLE PRECISION AINVNM, ANORM, ANORMI, ANORMO, CNDNUM, RCOND,
232 $ RCONDC, RCONDI, RCONDO
235 CHARACTER TRANSS( NTRAN )
236 INTEGER ISEED( 4 ), ISEEDY( 4 ), KLVAL( NBW ),
238 DOUBLE PRECISION RESULT( NTESTS )
240 * .. External Functions ..
241 DOUBLE PRECISION DGET06, ZLANGB, ZLANGE
242 EXTERNAL DGET06, ZLANGB, ZLANGE
244 * .. External Subroutines ..
245 EXTERNAL ALAERH, ALAHD, ALASUM, XLAENV, ZCOPY, ZERRGE,
246 $ ZGBCON, ZGBRFS, ZGBT01, ZGBT02, ZGBT05, ZGBTRF,
247 $ ZGBTRS, ZGET04, ZLACPY, ZLARHS, ZLASET, ZLATB4,
250 * .. Intrinsic Functions ..
251 INTRINSIC DCMPLX, MAX, MIN
253 * .. Scalars in Common ..
258 * .. Common blocks ..
259 COMMON / INFOC / INFOT, NUNIT, OK, LERR
260 COMMON / SRNAMC / SRNAMT
262 * .. Data statements ..
263 DATA ISEEDY / 1988, 1989, 1990, 1991 / ,
264 $ TRANSS / 'N', 'T', 'C' /
266 * .. Executable Statements ..
268 * Initialize constants and the random number seed.
270 PATH( 1: 1 ) = 'Zomplex precision'
276 ISEED( I ) = ISEEDY( I )
279 * Test the error exits
282 $ CALL ZERRGE( PATH, NOUT )
285 * Initialize the first value for the lower and upper bandwidths.
290 * Do for each value of M in MVAL
295 * Set values to use for the lower bandwidth.
297 KLVAL( 2 ) = M + ( M+1 ) / 4
299 * KLVAL( 2 ) = MAX( M-1, 0 )
301 KLVAL( 3 ) = ( 3*M-1 ) / 4
302 KLVAL( 4 ) = ( M+1 ) / 4
304 * Do for each value of N in NVAL
310 * Set values to use for the upper bandwidth.
312 KUVAL( 2 ) = N + ( N+1 ) / 4
314 * KUVAL( 2 ) = MAX( N-1, 0 )
316 KUVAL( 3 ) = ( 3*N-1 ) / 4
317 KUVAL( 4 ) = ( N+1 ) / 4
319 * Set limits on the number of loop iterations.
328 IF( M.LE.0 .OR. N.LE.0 )
333 * Do for KL = 0, (5*M+1)/4, (3M-1)/4, and (M+1)/4. This
334 * order makes it easier to skip redundant values for small
340 * Do for KU = 0, (5*N+1)/4, (3N-1)/4, and (N+1)/4. This
341 * order makes it easier to skip redundant values for
346 * Check that A and AFAC are big enough to generate this
350 LDAFAC = 2*KL + KU + 1
351 IF( ( LDA*N ).GT.LA .OR. ( LDAFAC*N ).GT.LAFAC ) THEN
352 IF( NFAIL.EQ.0 .AND. NERRS.EQ.0 )
353 $ CALL ALAHD( NOUT, PATH )
354 IF( N*( KL+KU+1 ).GT.LA ) THEN
355 WRITE( NOUT, FMT = 9999 )LA, M, N, KL, KU,
359 IF( N*( 2*KL+KU+1 ).GT.LAFAC ) THEN
360 WRITE( NOUT, FMT = 9998 )LAFAC, M, N, KL, KU,
367 DO 120 IMAT = 1, NIMAT
369 * Do the tests only if DOTYPE( IMAT ) is true.
371 IF( .NOT.DOTYPE( IMAT ) )
374 * Skip types 2, 3, or 4 if the matrix size is too
377 ZEROT = IMAT.GE.2 .AND. IMAT.LE.4
378 IF( ZEROT .AND. N.LT.IMAT-1 )
381 IF( .NOT.ZEROT .OR. .NOT.DOTYPE( 1 ) ) THEN
383 * Set up parameters with ZLATB4 and generate a
384 * test matrix with ZLATMS.
386 CALL ZLATB4( PATH, IMAT, M, N, TYPE, KL, KU,
387 $ ANORM, MODE, CNDNUM, DIST )
389 KOFF = MAX( 1, KU+2-N )
390 DO 20 I = 1, KOFF - 1
394 CALL ZLATMS( M, N, DIST, ISEED, TYPE, RWORK,
395 $ MODE, CNDNUM, ANORM, KL, KU, 'Z',
396 $ A( KOFF ), LDA, WORK, INFO )
398 * Check the error code from ZLATMS.
401 CALL ALAERH( PATH, 'ZLATMS', INFO, 0, ' ', M,
402 $ N, KL, KU, -1, IMAT, NFAIL,
406 ELSE IF( IZERO.GT.0 ) THEN
408 * Use the same matrix for types 3 and 4 as for
409 * type 2 by copying back the zeroed out column.
411 CALL ZCOPY( I2-I1+1, B, 1, A( IOFF+I1 ), 1 )
414 * For types 2, 3, and 4, zero one or more columns of
415 * the matrix to test that INFO is returned correctly.
421 ELSE IF( IMAT.EQ.3 ) THEN
424 IZERO = MIN( M, N ) / 2 + 1
426 IOFF = ( IZERO-1 )*LDA
429 * Store the column to be zeroed out in B.
431 I1 = MAX( 1, KU+2-IZERO )
432 I2 = MIN( KL+KU+1, KU+1+( M-IZERO ) )
433 CALL ZCOPY( I2-I1+1, A( IOFF+I1 ), 1, B, 1 )
440 DO 40 I = MAX( 1, KU+2-J ),
441 $ MIN( KL+KU+1, KU+1+( M-J ) )
449 * These lines, if used in place of the calls in the
450 * loop over INB, cause the code to bomb on a Sun
453 * ANORMO = ZLANGB( 'O', N, KL, KU, A, LDA, RWORK )
454 * ANORMI = ZLANGB( 'I', N, KL, KU, A, LDA, RWORK )
456 * Do for each blocksize in NBVAL
462 * Compute the LU factorization of the band matrix.
464 IF( M.GT.0 .AND. N.GT.0 )
465 $ CALL ZLACPY( 'Full', KL+KU+1, N, A, LDA,
466 $ AFAC( KL+1 ), LDAFAC )
468 CALL ZGBTRF( M, N, KL, KU, AFAC, LDAFAC, IWORK,
471 * Check error code from ZGBTRF.
474 $ CALL ALAERH( PATH, 'ZGBTRF', INFO, IZERO,
475 $ ' ', M, N, KL, KU, NB, IMAT,
476 $ NFAIL, NERRS, NOUT )
480 * Reconstruct matrix from factors and compute
483 CALL ZGBT01( M, N, KL, KU, A, LDA, AFAC, LDAFAC,
484 $ IWORK, WORK, RESULT( 1 ) )
486 * Print information about the tests so far that
487 * did not pass the threshold.
489 IF( RESULT( 1 ).GE.THRESH ) THEN
490 IF( NFAIL.EQ.0 .AND. NERRS.EQ.0 )
491 $ CALL ALAHD( NOUT, PATH )
492 WRITE( NOUT, FMT = 9997 )M, N, KL, KU, NB,
493 $ IMAT, 1, RESULT( 1 )
498 * Skip the remaining tests if this is not the
499 * first block size or if M .ne. N.
501 IF( INB.GT.1 .OR. M.NE.N )
504 ANORMO = ZLANGB( 'O', N, KL, KU, A, LDA, RWORK )
505 ANORMI = ZLANGB( 'I', N, KL, KU, A, LDA, RWORK )
509 * Form the inverse of A so we can get a good
510 * estimate of CNDNUM = norm(A) * norm(inv(A)).
513 CALL ZLASET( 'Full', N, N, DCMPLX( ZERO ),
514 $ DCMPLX( ONE ), WORK, LDB )
516 CALL ZGBTRS( 'No transpose', N, KL, KU, N,
517 $ AFAC, LDAFAC, IWORK, WORK, LDB,
520 * Compute the 1-norm condition number of A.
522 AINVNM = ZLANGE( 'O', N, N, WORK, LDB,
524 IF( ANORMO.LE.ZERO .OR. AINVNM.LE.ZERO ) THEN
527 RCONDO = ( ONE / ANORMO ) / AINVNM
530 * Compute the infinity-norm condition number of
533 AINVNM = ZLANGE( 'I', N, N, WORK, LDB,
535 IF( ANORMI.LE.ZERO .OR. AINVNM.LE.ZERO ) THEN
538 RCONDI = ( ONE / ANORMI ) / AINVNM
542 * Do only the condition estimate if INFO.NE.0.
549 * Skip the solve tests if the matrix is singular.
558 DO 70 ITRAN = 1, NTRAN
559 TRANS = TRANSS( ITRAN )
560 IF( ITRAN.EQ.1 ) THEN
569 * Solve and compute residual for A * X = B.
572 CALL ZLARHS( PATH, XTYPE, ' ', TRANS, N,
573 $ N, KL, KU, NRHS, A, LDA,
574 $ XACT, LDB, B, LDB, ISEED,
577 CALL ZLACPY( 'Full', N, NRHS, B, LDB, X,
581 CALL ZGBTRS( TRANS, N, KL, KU, NRHS, AFAC,
582 $ LDAFAC, IWORK, X, LDB, INFO )
584 * Check error code from ZGBTRS.
587 $ CALL ALAERH( PATH, 'ZGBTRS', INFO, 0,
588 $ TRANS, N, N, KL, KU, -1,
589 $ IMAT, NFAIL, NERRS, NOUT )
591 CALL ZLACPY( 'Full', N, NRHS, B, LDB,
593 CALL ZGBT02( TRANS, M, N, KL, KU, NRHS, A,
594 $ LDA, X, LDB, WORK, LDB,
598 * Check solution from generated exact
601 CALL ZGET04( N, NRHS, X, LDB, XACT, LDB,
602 $ RCONDC, RESULT( 3 ) )
605 * Use iterative refinement to improve the
609 CALL ZGBRFS( TRANS, N, KL, KU, NRHS, A,
610 $ LDA, AFAC, LDAFAC, IWORK, B,
611 $ LDB, X, LDB, RWORK,
612 $ RWORK( NRHS+1 ), WORK,
613 $ RWORK( 2*NRHS+1 ), INFO )
615 * Check error code from ZGBRFS.
618 $ CALL ALAERH( PATH, 'ZGBRFS', INFO, 0,
619 $ TRANS, N, N, KL, KU, NRHS,
620 $ IMAT, NFAIL, NERRS, NOUT )
622 CALL ZGET04( N, NRHS, X, LDB, XACT, LDB,
623 $ RCONDC, RESULT( 4 ) )
624 CALL ZGBT05( TRANS, N, KL, KU, NRHS, A,
625 $ LDA, B, LDB, X, LDB, XACT,
626 $ LDB, RWORK, RWORK( NRHS+1 ),
629 * Print information about the tests that did
630 * not pass the threshold.
633 IF( RESULT( K ).GE.THRESH ) THEN
634 IF( NFAIL.EQ.0 .AND. NERRS.EQ.0 )
635 $ CALL ALAHD( NOUT, PATH )
636 WRITE( NOUT, FMT = 9996 )TRANS, N,
637 $ KL, KU, NRHS, IMAT, K,
647 * Get an estimate of RCOND = 1/CNDNUM.
651 IF( ITRAN.EQ.1 ) THEN
661 CALL ZGBCON( NORM, N, KL, KU, AFAC, LDAFAC,
662 $ IWORK, ANORM, RCOND, WORK,
665 * Check error code from ZGBCON.
668 $ CALL ALAERH( PATH, 'ZGBCON', INFO, 0,
669 $ NORM, N, N, KL, KU, -1, IMAT,
670 $ NFAIL, NERRS, NOUT )
672 RESULT( 7 ) = DGET06( RCOND, RCONDC )
674 * Print information about the tests that did
675 * not pass the threshold.
677 IF( RESULT( 7 ).GE.THRESH ) THEN
678 IF( NFAIL.EQ.0 .AND. NERRS.EQ.0 )
679 $ CALL ALAHD( NOUT, PATH )
680 WRITE( NOUT, FMT = 9995 )NORM, N, KL, KU,
681 $ IMAT, 7, RESULT( 7 )
693 * Print a summary of the results.
695 CALL ALASUM( PATH, NOUT, NFAIL, NRUN, NERRS )
697 9999 FORMAT( ' *** In ZCHKGB, LA=', I5, ' is too small for M=', I5,
698 $ ', N=', I5, ', KL=', I4, ', KU=', I4,
699 $ / ' ==> Increase LA to at least ', I5 )
700 9998 FORMAT( ' *** In ZCHKGB, LAFAC=', I5, ' is too small for M=', I5,
701 $ ', N=', I5, ', KL=', I4, ', KU=', I4,
702 $ / ' ==> Increase LAFAC to at least ', I5 )
703 9997 FORMAT( ' M =', I5, ', N =', I5, ', KL=', I5, ', KU=', I5,
704 $ ', NB =', I4, ', type ', I1, ', test(', I1, ')=', G12.5 )
705 9996 FORMAT( ' TRANS=''', A1, ''', N=', I5, ', KL=', I5, ', KU=', I5,
706 $ ', NRHS=', I3, ', type ', I1, ', test(', I1, ')=', G12.5 )
707 9995 FORMAT( ' NORM =''', A1, ''', N=', I5, ', KL=', I5, ', KU=', I5,
708 $ ',', 10X, ' type ', I1, ', test(', I1, ')=', G12.5 )