3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
11 * SUBROUTINE SCHKGB( 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
20 * .. Array Arguments ..
22 * INTEGER IWORK( * ), MVAL( * ), NBVAL( * ), NSVAL( * ),
24 * REAL A( * ), AFAC( * ), B( * ), RWORK( * ),
25 * $ WORK( * ), X( * ), XACT( * )
34 *> SCHKGB tests SGBTRF, -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 M contained in the vector MVAL.
56 *> MVAL is INTEGER array, dimension (NM)
57 *> The values of the matrix row dimension M.
63 *> The number of values of N contained in the vector NVAL.
68 *> NVAL is INTEGER array, dimension (NN)
69 *> The values of the matrix column dimension N.
75 *> The number of values of NB contained in the vector NBVAL.
80 *> NBVAL is INTEGER array, dimension (NNB)
81 *> The values of the blocksize NB.
87 *> The number of values of NRHS contained in the vector NSVAL.
92 *> NSVAL is INTEGER array, dimension (NNS)
93 *> The values of the number of right hand sides NRHS.
99 *> The threshold value for the test ratios. A result is
100 *> included in the output file if RESULT >= THRESH. To have
101 *> every test ratio printed, use THRESH = 0.
107 *> Flag that indicates whether error exits are to be tested.
112 *> A is REAL array, dimension (LA)
118 *> The length of the array A. LA >= (KLMAX+KUMAX+1)*NMAX
119 *> where KLMAX is the largest entry in the local array KLVAL,
120 *> KUMAX is the largest entry in the local array KUVAL and
121 *> NMAX is the largest entry in the input array NVAL.
126 *> AFAC is REAL array, dimension (LAFAC)
132 *> The length of the array AFAC. LAFAC >= (2*KLMAX+KUMAX+1)*NMAX
133 *> where KLMAX is the largest entry in the local array KLVAL,
134 *> KUMAX is the largest entry in the local array KUVAL and
135 *> NMAX is the largest entry in the input array NVAL.
140 *> B is REAL array, dimension (NMAX*NSMAX)
141 *> where NSMAX is the largest entry in NSVAL.
146 *> X is REAL array, dimension (NMAX*NSMAX)
151 *> XACT is REAL array, dimension (NMAX*NSMAX)
156 *> WORK is REAL array, dimension
157 *> (NMAX*max(3,NSMAX,NMAX))
162 *> RWORK is REAL array, dimension
163 *> (max(NMAX,2*NSMAX))
168 *> IWORK is INTEGER array, dimension (2*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 single_lin
189 * =====================================================================
190 SUBROUTINE SCHKGB( 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
204 * .. Array Arguments ..
206 INTEGER IWORK( * ), MVAL( * ), NBVAL( * ), NSVAL( * ),
208 REAL A( * ), AFAC( * ), B( * ), RWORK( * ),
209 $ WORK( * ), X( * ), XACT( * )
212 * =====================================================================
216 PARAMETER ( ONE = 1.0E+0, ZERO = 0.0E+0 )
217 INTEGER NTYPES, NTESTS
218 PARAMETER ( NTYPES = 8, NTESTS = 7 )
220 PARAMETER ( NBW = 4, NTRAN = 3 )
222 * .. Local Scalars ..
223 LOGICAL TRFCON, ZEROT
224 CHARACTER DIST, NORM, TRANS, TYPE, XTYPE
226 INTEGER I, I1, I2, IKL, IKU, IM, IMAT, IN, INB, INFO,
227 $ IOFF, IRHS, ITRAN, IZERO, J, K, KL, KOFF, KU,
228 $ LDA, LDAFAC, LDB, M, MODE, N, NB, NERRS, NFAIL,
229 $ NIMAT, NKL, NKU, NRHS, NRUN
230 REAL AINVNM, ANORM, ANORMI, ANORMO, CNDNUM, RCOND,
231 $ RCONDC, RCONDI, RCONDO
234 CHARACTER TRANSS( NTRAN )
235 INTEGER ISEED( 4 ), ISEEDY( 4 ), KLVAL( NBW ),
237 REAL RESULT( NTESTS )
239 * .. External Functions ..
240 REAL SGET06, SLANGB, SLANGE
241 EXTERNAL SGET06, SLANGB, SLANGE
243 * .. External Subroutines ..
244 EXTERNAL ALAERH, ALAHD, ALASUM, SCOPY, SERRGE, SGBCON,
245 $ SGBRFS, SGBT01, SGBT02, SGBT05, SGBTRF, SGBTRS,
246 $ SGET04, SLACPY, SLARHS, SLASET, SLATB4, SLATMS,
249 * .. Intrinsic Functions ..
252 * .. Scalars in Common ..
257 * .. Common blocks ..
258 COMMON / INFOC / INFOT, NUNIT, OK, LERR
259 COMMON / SRNAMC / SRNAMT
261 * .. Data statements ..
262 DATA ISEEDY / 1988, 1989, 1990, 1991 / ,
263 $ TRANSS / 'N', 'T', 'C' /
265 * .. Executable Statements ..
267 * Initialize constants and the random number seed.
269 PATH( 1: 1 ) = 'Single precision'
275 ISEED( I ) = ISEEDY( I )
278 * Test the error exits
281 $ CALL SERRGE( 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 SLATB4 and generate a
384 * test matrix with SLATMS.
386 CALL SLATB4( 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 SLATMS( 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 SLATMS.
401 CALL ALAERH( PATH, 'SLATMS', 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 SCOPY( 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 SCOPY( 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 = SLANGB( 'O', N, KL, KU, A, LDA, RWORK )
454 * ANORMI = SLANGB( '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 SLACPY( 'Full', KL+KU+1, N, A, LDA,
466 $ AFAC( KL+1 ), LDAFAC )
468 CALL SGBTRF( M, N, KL, KU, AFAC, LDAFAC, IWORK,
471 * Check error code from SGBTRF.
474 $ CALL ALAERH( PATH, 'SGBTRF', INFO, IZERO,
475 $ ' ', M, N, KL, KU, NB, IMAT,
476 $ NFAIL, NERRS, NOUT )
480 * Reconstruct matrix from factors and compute
483 CALL SGBT01( 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 = SLANGB( 'O', N, KL, KU, A, LDA, RWORK )
505 ANORMI = SLANGB( '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 SLASET( 'Full', N, N, ZERO, ONE, WORK,
516 CALL SGBTRS( 'No transpose', N, KL, KU, N,
517 $ AFAC, LDAFAC, IWORK, WORK, LDB,
520 * Compute the 1-norm condition number of A.
522 AINVNM = SLANGE( '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 = SLANGE( '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 SLARHS( PATH, XTYPE, ' ', TRANS, N,
573 $ N, KL, KU, NRHS, A, LDA,
574 $ XACT, LDB, B, LDB, ISEED,
577 CALL SLACPY( 'Full', N, NRHS, B, LDB, X,
581 CALL SGBTRS( TRANS, N, KL, KU, NRHS, AFAC,
582 $ LDAFAC, IWORK, X, LDB, INFO )
584 * Check error code from SGBTRS.
587 $ CALL ALAERH( PATH, 'SGBTRS', INFO, 0,
588 $ TRANS, N, N, KL, KU, -1,
589 $ IMAT, NFAIL, NERRS, NOUT )
591 CALL SLACPY( 'Full', N, NRHS, B, LDB,
593 CALL SGBT02( TRANS, M, N, KL, KU, NRHS, A,
594 $ LDA, X, LDB, WORK, LDB,
598 * Check solution from generated exact
601 CALL SGET04( N, NRHS, X, LDB, XACT, LDB,
602 $ RCONDC, RESULT( 3 ) )
605 * Use iterative refinement to improve the
609 CALL SGBRFS( TRANS, N, KL, KU, NRHS, A,
610 $ LDA, AFAC, LDAFAC, IWORK, B,
611 $ LDB, X, LDB, RWORK,
612 $ RWORK( NRHS+1 ), WORK,
613 $ IWORK( N+1 ), INFO )
615 * Check error code from SGBRFS.
618 $ CALL ALAERH( PATH, 'SGBRFS', INFO, 0,
619 $ TRANS, N, N, KL, KU, NRHS,
620 $ IMAT, NFAIL, NERRS, NOUT )
622 CALL SGET04( N, NRHS, X, LDB, XACT, LDB,
623 $ RCONDC, RESULT( 4 ) )
624 CALL SGBT05( TRANS, N, KL, KU, NRHS, A,
625 $ LDA, B, LDB, X, LDB, XACT,
626 $ LDB, RWORK, RWORK( NRHS+1 ),
629 IF( RESULT( K ).GE.THRESH ) THEN
630 IF( NFAIL.EQ.0 .AND. NERRS.EQ.0 )
631 $ CALL ALAHD( NOUT, PATH )
632 WRITE( NOUT, FMT = 9996 )TRANS, N,
633 $ KL, KU, NRHS, IMAT, K,
643 * Get an estimate of RCOND = 1/CNDNUM.
647 IF( ITRAN.EQ.1 ) THEN
657 CALL SGBCON( NORM, N, KL, KU, AFAC, LDAFAC,
658 $ IWORK, ANORM, RCOND, WORK,
659 $ IWORK( N+1 ), INFO )
661 * Check error code from SGBCON.
664 $ CALL ALAERH( PATH, 'SGBCON', INFO, 0,
665 $ NORM, N, N, KL, KU, -1, IMAT,
666 $ NFAIL, NERRS, NOUT )
668 RESULT( 7 ) = SGET06( RCOND, RCONDC )
670 * Print information about the tests that did
671 * not pass the threshold.
673 IF( RESULT( 7 ).GE.THRESH ) THEN
674 IF( NFAIL.EQ.0 .AND. NERRS.EQ.0 )
675 $ CALL ALAHD( NOUT, PATH )
676 WRITE( NOUT, FMT = 9995 )NORM, N, KL, KU,
677 $ IMAT, 7, RESULT( 7 )
690 * Print a summary of the results.
692 CALL ALASUM( PATH, NOUT, NFAIL, NRUN, NERRS )
694 9999 FORMAT( ' *** In SCHKGB, LA=', I5, ' is too small for M=', I5,
695 $ ', N=', I5, ', KL=', I4, ', KU=', I4,
696 $ / ' ==> Increase LA to at least ', I5 )
697 9998 FORMAT( ' *** In SCHKGB, LAFAC=', I5, ' is too small for M=', I5,
698 $ ', N=', I5, ', KL=', I4, ', KU=', I4,
699 $ / ' ==> Increase LAFAC to at least ', I5 )
700 9997 FORMAT( ' M =', I5, ', N =', I5, ', KL=', I5, ', KU=', I5,
701 $ ', NB =', I4, ', type ', I1, ', test(', I1, ')=', G12.5 )
702 9996 FORMAT( ' TRANS=''', A1, ''', N=', I5, ', KL=', I5, ', KU=', I5,
703 $ ', NRHS=', I3, ', type ', I1, ', test(', I1, ')=', G12.5 )
704 9995 FORMAT( ' NORM =''', A1, ''', N=', I5, ', KL=', I5, ', KU=', I5,
705 $ ',', 10X, ' type ', I1, ', test(', I1, ')=', G12.5 )