1*> \brief \b CTBT06
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 CTBT06( RCOND, RCONDC, UPLO, DIAG, N, KD, AB, LDAB,
12*                          RWORK, RAT )
13*
14*       .. Scalar Arguments ..
15*       CHARACTER          DIAG, UPLO
16*       INTEGER            KD, LDAB, N
17*       REAL               RAT, RCOND, RCONDC
18*       ..
19*       .. Array Arguments ..
20*       REAL               RWORK( * )
21*       COMPLEX            AB( LDAB, * )
22*       ..
23*
24*
25*> \par Purpose:
26*  =============
27*>
28*> \verbatim
29*>
30*> CTBT06 computes a test ratio comparing RCOND (the reciprocal
31*> condition number of a triangular matrix A) and RCONDC, the estimate
32*> computed by CTBCON.  Information about the triangular matrix A is
33*> used if one estimate is zero and the other is non-zero to decide if
34*> underflow in the estimate is justified.
35*> \endverbatim
36*
37*  Arguments:
38*  ==========
39*
40*> \param[in] RCOND
41*> \verbatim
42*>          RCOND is REAL
43*>          The estimate of the reciprocal condition number obtained by
44*>          forming the explicit inverse of the matrix A and computing
45*>          RCOND = 1/( norm(A) * norm(inv(A)) ).
46*> \endverbatim
47*>
48*> \param[in] RCONDC
49*> \verbatim
50*>          RCONDC is REAL
51*>          The estimate of the reciprocal condition number computed by
52*>          CTBCON.
53*> \endverbatim
54*>
55*> \param[in] UPLO
56*> \verbatim
57*>          UPLO is CHARACTER
58*>          Specifies whether the matrix A is upper or lower triangular.
59*>          = 'U':  Upper triangular
60*>          = 'L':  Lower triangular
61*> \endverbatim
62*>
63*> \param[in] DIAG
64*> \verbatim
65*>          DIAG is CHARACTER
66*>          Specifies whether or not the matrix A is unit triangular.
67*>          = 'N':  Non-unit triangular
68*>          = 'U':  Unit triangular
69*> \endverbatim
70*>
71*> \param[in] N
72*> \verbatim
73*>          N is INTEGER
74*>          The order of the matrix A.  N >= 0.
75*> \endverbatim
76*>
77*> \param[in] KD
78*> \verbatim
79*>          KD is INTEGER
80*>          The number of superdiagonals or subdiagonals of the
81*>          triangular band matrix A.  KD >= 0.
82*> \endverbatim
83*>
84*> \param[in] AB
85*> \verbatim
86*>          AB is COMPLEX array, dimension (LDAB,N)
87*>          The upper or lower triangular band matrix A, stored in the
88*>          first kd+1 rows of the array. The j-th column of A is stored
89*>          in the j-th column of the array AB as follows:
90*>          if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j;
91*>          if UPLO = 'L', AB(1+i-j,j)    = A(i,j) for j<=i<=min(n,j+kd).
92*> \endverbatim
93*>
94*> \param[in] LDAB
95*> \verbatim
96*>          LDAB is INTEGER
97*>          The leading dimension of the array AB.  LDAB >= KD+1.
98*> \endverbatim
99*>
100*> \param[out] RWORK
101*> \verbatim
102*>          RWORK is REAL array, dimension (N)
103*> \endverbatim
104*>
105*> \param[out] RAT
106*> \verbatim
107*>          RAT is REAL
108*>          The test ratio.  If both RCOND and RCONDC are nonzero,
109*>             RAT = MAX( RCOND, RCONDC )/MIN( RCOND, RCONDC ) - 1.
110*>          If RAT = 0, the two estimates are exactly the same.
111*> \endverbatim
112*
113*  Authors:
114*  ========
115*
116*> \author Univ. of Tennessee
117*> \author Univ. of California Berkeley
118*> \author Univ. of Colorado Denver
119*> \author NAG Ltd.
120*
121*> \ingroup complex_lin
122*
123*  =====================================================================
124      SUBROUTINE CTBT06( RCOND, RCONDC, UPLO, DIAG, N, KD, AB, LDAB,
125     $                   RWORK, RAT )
126*
127*  -- LAPACK test routine --
128*  -- LAPACK is a software package provided by Univ. of Tennessee,    --
129*  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
130*
131*     .. Scalar Arguments ..
132      CHARACTER          DIAG, UPLO
133      INTEGER            KD, LDAB, N
134      REAL               RAT, RCOND, RCONDC
135*     ..
136*     .. Array Arguments ..
137      REAL               RWORK( * )
138      COMPLEX            AB( LDAB, * )
139*     ..
140*
141*  =====================================================================
142*
143*     .. Parameters ..
144      REAL               ZERO, ONE
145      PARAMETER          ( ZERO = 0.0E+0, ONE = 1.0E+0 )
146*     ..
147*     .. Local Scalars ..
148      REAL               ANORM, BIGNUM, EPS, RMAX, RMIN
149*     ..
150*     .. External Functions ..
151      REAL               CLANTB, SLAMCH
152      EXTERNAL           CLANTB, SLAMCH
153*     ..
154*     .. Intrinsic Functions ..
155      INTRINSIC          MAX, MIN
156*     ..
157*     .. Executable Statements ..
158*
159      EPS = SLAMCH( 'Epsilon' )
160      RMAX = MAX( RCOND, RCONDC )
161      RMIN = MIN( RCOND, RCONDC )
162*
163*     Do the easy cases first.
164*
165      IF( RMIN.LT.ZERO ) THEN
166*
167*        Invalid value for RCOND or RCONDC, return 1/EPS.
168*
169         RAT = ONE / EPS
170*
171      ELSE IF( RMIN.GT.ZERO ) THEN
172*
173*        Both estimates are positive, return RMAX/RMIN - 1.
174*
175         RAT = RMAX / RMIN - ONE
176*
177      ELSE IF( RMAX.EQ.ZERO ) THEN
178*
179*        Both estimates zero.
180*
181         RAT = ZERO
182*
183      ELSE
184*
185*        One estimate is zero, the other is non-zero.  If the matrix is
186*        ill-conditioned, return the nonzero estimate multiplied by
187*        1/EPS; if the matrix is badly scaled, return the nonzero
188*        estimate multiplied by BIGNUM/TMAX, where TMAX is the maximum
189*        element in absolute value in A.
190*
191         BIGNUM = ONE / SLAMCH( 'Safe minimum' )
192         ANORM = CLANTB( 'M', UPLO, DIAG, N, KD, AB, LDAB, RWORK )
193*
194         RAT = RMAX*( MIN( BIGNUM / MAX( ONE, ANORM ), ONE / EPS ) )
195      END IF
196*
197      RETURN
198*
199*     End of CTBT06
200*
201      END
202