1       SUBROUTINE DTBT06( RCOND, RCONDC, UPLO, DIAG, N, KD, AB, LDAB,
  2      $                   WORK, RAT )
  3 *
  4 *  -- LAPACK test routine (version 3.1) --
  5 *     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
  6 *     November 2006
  7 *
  8 *     .. Scalar Arguments ..
  9       CHARACTER          DIAG, UPLO
 10       INTEGER            KD, LDAB, N
 11       DOUBLE PRECISION   RAT, RCOND, RCONDC
 12 *     ..
 13 *     .. Array Arguments ..
 14       DOUBLE PRECISION   AB( LDAB, * ), WORK( * )
 15 *     ..
 16 *
 17 *  Purpose
 18 *  =======
 19 *
 20 *  DTBT06 computes a test ratio comparing RCOND (the reciprocal
 21 *  condition number of a triangular matrix A) and RCONDC, the estimate
 22 *  computed by DTBCON.  Information about the triangular matrix A is
 23 *  used if one estimate is zero and the other is non-zero to decide if
 24 *  underflow in the estimate is justified.
 25 *
 26 *  Arguments
 27 *  =========
 28 *
 29 *  RCOND   (input) DOUBLE PRECISION
 30 *          The estimate of the reciprocal condition number obtained by
 31 *          forming the explicit inverse of the matrix A and computing
 32 *          RCOND = 1/( norm(A) * norm(inv(A)) ).
 33 *
 34 *  RCONDC  (input) DOUBLE PRECISION
 35 *          The estimate of the reciprocal condition number computed by
 36 *          DTBCON.
 37 *
 38 *  UPLO    (input) CHARACTER
 39 *          Specifies whether the matrix A is upper or lower triangular.
 40 *          = 'U':  Upper triangular
 41 *          = 'L':  Lower triangular
 42 *
 43 *  DIAG    (input) CHARACTER
 44 *          Specifies whether or not the matrix A is unit triangular.
 45 *          = 'N':  Non-unit triangular
 46 *          = 'U':  Unit triangular
 47 *
 48 *  N       (input) INTEGER
 49 *          The order of the matrix A.  N >= 0.
 50 *
 51 *  KD      (input) INTEGER
 52 *          The number of superdiagonals or subdiagonals of the
 53 *          triangular band matrix A.  KD >= 0.
 54 *
 55 *  AB      (input) DOUBLE PRECISION array, dimension (LDAB,N)
 56 *          The upper or lower triangular band matrix A, stored in the
 57 *          first kd+1 rows of the array. The j-th column of A is stored
 58 *          in the j-th column of the array AB as follows:
 59 *          if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j;
 60 *          if UPLO = 'L', AB(1+i-j,j)    = A(i,j) for j<=i<=min(n,j+kd).
 61 *
 62 *  LDAB    (input) INTEGER
 63 *          The leading dimension of the array AB.  LDAB >= KD+1.
 64 *
 65 *  WORK    (workspace) DOUBLE PRECISION array, dimension (N)
 66 *
 67 *  RAT     (output) DOUBLE PRECISION
 68 *          The test ratio.  If both RCOND and RCONDC are nonzero,
 69 *             RAT = MAX( RCOND, RCONDC )/MIN( RCOND, RCONDC ) - 1.
 70 *          If RAT = 0, the two estimates are exactly the same.
 71 *
 72 *  =====================================================================
 73 *
 74 *     .. Parameters ..
 75       DOUBLE PRECISION   ZERO, ONE
 76       PARAMETER          ( ZERO = 0.0D+0, ONE = 1.0D+0 )
 77 *     ..
 78 *     .. Local Scalars ..
 79       DOUBLE PRECISION   ANORM, BIGNUM, EPS, RMAX, RMIN, SMLNUM
 80 *     ..
 81 *     .. External Functions ..
 82       DOUBLE PRECISION   DLAMCH, DLANTB
 83       EXTERNAL           DLAMCH, DLANTB
 84 *     ..
 85 *     .. Intrinsic Functions ..
 86       INTRINSIC          MAXMIN
 87 *     ..
 88 *     .. External Subroutines ..
 89       EXTERNAL           DLABAD
 90 *     ..
 91 *     .. Executable Statements ..
 92 *
 93       EPS = DLAMCH( 'Epsilon' )
 94       RMAX = MAX( RCOND, RCONDC )
 95       RMIN = MIN( RCOND, RCONDC )
 96 *
 97 *     Do the easy cases first.
 98 *
 99       IF( RMIN.LT.ZERO ) THEN
100 *
101 *        Invalid value for RCOND or RCONDC, return 1/EPS.
102 *
103          RAT = ONE / EPS
104 *
105       ELSE IF( RMIN.GT.ZERO ) THEN
106 *
107 *        Both estimates are positive, return RMAX/RMIN - 1.
108 *
109          RAT = RMAX / RMIN - ONE
110 *
111       ELSE IF( RMAX.EQ.ZERO ) THEN
112 *
113 *        Both estimates zero.
114 *
115          RAT = ZERO
116 *
117       ELSE
118 *
119 *        One estimate is zero, the other is non-zero.  If the matrix is
120 *        ill-conditioned, return the nonzero estimate multiplied by
121 *        1/EPS; if the matrix is badly scaled, return the nonzero
122 *        estimate multiplied by BIGNUM/TMAX, where TMAX is the maximum
123 *        element in absolute value in A.
124 *
125          SMLNUM = DLAMCH( 'Safe minimum' )
126          BIGNUM = ONE / SMLNUM
127          CALL DLABAD( SMLNUM, BIGNUM )
128          ANORM = DLANTB( 'M', UPLO, DIAG, N, KD, AB, LDAB, WORK )
129 *
130          RAT = RMAX*MIN( BIGNUM / MAX( ONE, ANORM ), ONE / EPS ) )
131       END IF
132 *
133       RETURN
134 *
135 *     End of DTBT06
136 *
137       END