1       SUBROUTINE ZTPT06( RCOND, RCONDC, UPLO, DIAG, N, AP, RWORK, RAT )
  2 *
  3 *  -- LAPACK test routine (version 3.1) --
  4 *     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
  5 *     November 2006
  6 *
  7 *     .. Scalar Arguments ..
  8       CHARACTER          DIAG, UPLO
  9       INTEGER            N
 10       DOUBLE PRECISION   RAT, RCOND, RCONDC
 11 *     ..
 12 *     .. Array Arguments ..
 13       DOUBLE PRECISION   RWORK( * )
 14       COMPLEX*16         AP( * )
 15 *     ..
 16 *
 17 *  Purpose
 18 *  =======
 19 *
 20 *  ZTPT06 computes a test ratio comparing RCOND (the reciprocal
 21 *  condition number of the triangular matrix A) and RCONDC, the estimate
 22 *  computed by ZTPCON.  Information about the triangular matrix is used
 23 *  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 *          ZTPCON.
 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 *  AP      (input) COMPLEX*16 array, dimension (N*(N+1)/2)
 52 *          The upper or lower triangular matrix A, packed columnwise in
 53 *          a linear array.  The j-th column of A is stored in the array
 54 *          AP as follows:
 55 *          if UPLO = 'U', AP((j-1)*j/2 + i) = A(i,j) for 1<=i<=j;
 56 *          if UPLO = 'L',
 57 *             AP((j-1)*(n-j) + j*(j+1)/2 + i-j) = A(i,j) for j<=i<=n.
 58 *
 59 *  RWORK   (workspace) DOUBLE PRECISION array, dimension (N)
 60 *
 61 *  RAT     (output) DOUBLE PRECISION
 62 *          The test ratio.  If both RCOND and RCONDC are nonzero,
 63 *             RAT = MAX( RCOND, RCONDC )/MIN( RCOND, RCONDC ) - 1.
 64 *          If RAT = 0, the two estimates are exactly the same.
 65 *
 66 *  =====================================================================
 67 *
 68 *     .. Parameters ..
 69       DOUBLE PRECISION   ZERO, ONE
 70       PARAMETER          ( ZERO = 0.0D+0, ONE = 1.0D+0 )
 71 *     ..
 72 *     .. Local Scalars ..
 73       DOUBLE PRECISION   ANORM, BIGNUM, EPS, RMAX, RMIN
 74 *     ..
 75 *     .. External Functions ..
 76       DOUBLE PRECISION   DLAMCH, ZLANTP
 77       EXTERNAL           DLAMCH, ZLANTP
 78 *     ..
 79 *     .. Intrinsic Functions ..
 80       INTRINSIC          MAXMIN
 81 *     ..
 82 *     .. Executable Statements ..
 83 *
 84       EPS = DLAMCH( 'Epsilon' )
 85       RMAX = MAX( RCOND, RCONDC )
 86       RMIN = MIN( RCOND, RCONDC )
 87 *
 88 *     Do the easy cases first.
 89 *
 90       IF( RMIN.LT.ZERO ) THEN
 91 *
 92 *        Invalid value for RCOND or RCONDC, return 1/EPS.
 93 *
 94          RAT = ONE / EPS
 95 *
 96       ELSE IF( RMIN.GT.ZERO ) THEN
 97 *
 98 *        Both estimates are positive, return RMAX/RMIN - 1.
 99 *
100          RAT = RMAX / RMIN - ONE
101 *
102       ELSE IF( RMAX.EQ.ZERO ) THEN
103 *
104 *        Both estimates zero.
105 *
106          RAT = ZERO
107 *
108       ELSE
109 *
110 *        One estimate is zero, the other is non-zero.  If the matrix is
111 *        ill-conditioned, return the nonzero estimate multiplied by
112 *        1/EPS; if the matrix is badly scaled, return the nonzero
113 *        estimate multiplied by BIGNUM/TMAX, where TMAX is the maximum
114 *        element in absolute value in A.
115 *
116          BIGNUM = ONE / DLAMCH( 'Safe minimum' )
117          ANORM = ZLANTP( 'M', UPLO, DIAG, N, AP, RWORK )
118 *
119          RAT = RMAX*MIN( BIGNUM / MAX( ONE, ANORM ), ONE / EPS ) )
120       END IF
121 *
122       RETURN
123 *
124 *     End of ZTPT06
125 *
126       END