```001:       SUBROUTINE CPOCON( UPLO, N, A, LDA, ANORM, RCOND, WORK, RWORK,
002:      \$                   INFO )
003: *
004: *  -- LAPACK routine (version 3.2) --
005: *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
006: *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
007: *     November 2006
008: *
009: *     Modified to call CLACN2 in place of CLACON, 10 Feb 03, SJH.
010: *
011: *     .. Scalar Arguments ..
012:       CHARACTER          UPLO
013:       INTEGER            INFO, LDA, N
014:       REAL               ANORM, RCOND
015: *     ..
016: *     .. Array Arguments ..
017:       REAL               RWORK( * )
018:       COMPLEX            A( LDA, * ), WORK( * )
019: *     ..
020: *
021: *  Purpose
022: *  =======
023: *
024: *  CPOCON estimates the reciprocal of the condition number (in the
025: *  1-norm) of a complex Hermitian positive definite matrix using the
026: *  Cholesky factorization A = U**H*U or A = L*L**H computed by CPOTRF.
027: *
028: *  An estimate is obtained for norm(inv(A)), and the reciprocal of the
029: *  condition number is computed as RCOND = 1 / (ANORM * norm(inv(A))).
030: *
031: *  Arguments
032: *  =========
033: *
034: *  UPLO    (input) CHARACTER*1
035: *          = 'U':  Upper triangle of A is stored;
036: *          = 'L':  Lower triangle of A is stored.
037: *
038: *  N       (input) INTEGER
039: *          The order of the matrix A.  N >= 0.
040: *
041: *  A       (input) COMPLEX array, dimension (LDA,N)
042: *          The triangular factor U or L from the Cholesky factorization
043: *          A = U**H*U or A = L*L**H, as computed by CPOTRF.
044: *
045: *  LDA     (input) INTEGER
046: *          The leading dimension of the array A.  LDA >= max(1,N).
047: *
048: *  ANORM   (input) REAL
049: *          The 1-norm (or infinity-norm) of the Hermitian matrix A.
050: *
051: *  RCOND   (output) REAL
052: *          The reciprocal of the condition number of the matrix A,
053: *          computed as RCOND = 1/(ANORM * AINVNM), where AINVNM is an
054: *          estimate of the 1-norm of inv(A) computed in this routine.
055: *
056: *  WORK    (workspace) COMPLEX array, dimension (2*N)
057: *
058: *  RWORK   (workspace) REAL array, dimension (N)
059: *
060: *  INFO    (output) INTEGER
061: *          = 0:  successful exit
062: *          < 0:  if INFO = -i, the i-th argument had an illegal value
063: *
064: *  =====================================================================
065: *
066: *     .. Parameters ..
067:       REAL               ONE, ZERO
068:       PARAMETER          ( ONE = 1.0E+0, ZERO = 0.0E+0 )
069: *     ..
070: *     .. Local Scalars ..
071:       LOGICAL            UPPER
072:       CHARACTER          NORMIN
073:       INTEGER            IX, KASE
074:       REAL               AINVNM, SCALE, SCALEL, SCALEU, SMLNUM
075:       COMPLEX            ZDUM
076: *     ..
077: *     .. Local Arrays ..
078:       INTEGER            ISAVE( 3 )
079: *     ..
080: *     .. External Functions ..
081:       LOGICAL            LSAME
082:       INTEGER            ICAMAX
083:       REAL               SLAMCH
084:       EXTERNAL           LSAME, ICAMAX, SLAMCH
085: *     ..
086: *     .. External Subroutines ..
087:       EXTERNAL           CLACN2, CLATRS, CSRSCL, XERBLA
088: *     ..
089: *     .. Intrinsic Functions ..
090:       INTRINSIC          ABS, AIMAG, MAX, REAL
091: *     ..
092: *     .. Statement Functions ..
093:       REAL               CABS1
094: *     ..
095: *     .. Statement Function definitions ..
096:       CABS1( ZDUM ) = ABS( REAL( ZDUM ) ) + ABS( AIMAG( ZDUM ) )
097: *     ..
098: *     .. Executable Statements ..
099: *
100: *     Test the input parameters.
101: *
102:       INFO = 0
103:       UPPER = LSAME( UPLO, 'U' )
104:       IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
105:          INFO = -1
106:       ELSE IF( N.LT.0 ) THEN
107:          INFO = -2
108:       ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
109:          INFO = -4
110:       ELSE IF( ANORM.LT.ZERO ) THEN
111:          INFO = -5
112:       END IF
113:       IF( INFO.NE.0 ) THEN
114:          CALL XERBLA( 'CPOCON', -INFO )
115:          RETURN
116:       END IF
117: *
118: *     Quick return if possible
119: *
120:       RCOND = ZERO
121:       IF( N.EQ.0 ) THEN
122:          RCOND = ONE
123:          RETURN
124:       ELSE IF( ANORM.EQ.ZERO ) THEN
125:          RETURN
126:       END IF
127: *
128:       SMLNUM = SLAMCH( 'Safe minimum' )
129: *
130: *     Estimate the 1-norm of inv(A).
131: *
132:       KASE = 0
133:       NORMIN = 'N'
134:    10 CONTINUE
135:       CALL CLACN2( N, WORK( N+1 ), WORK, AINVNM, KASE, ISAVE )
136:       IF( KASE.NE.0 ) THEN
137:          IF( UPPER ) THEN
138: *
139: *           Multiply by inv(U').
140: *
141:             CALL CLATRS( 'Upper', 'Conjugate transpose', 'Non-unit',
142:      \$                   NORMIN, N, A, LDA, WORK, SCALEL, RWORK, INFO )
143:             NORMIN = 'Y'
144: *
145: *           Multiply by inv(U).
146: *
147:             CALL CLATRS( 'Upper', 'No transpose', 'Non-unit', NORMIN, N,
148:      \$                   A, LDA, WORK, SCALEU, RWORK, INFO )
149:          ELSE
150: *
151: *           Multiply by inv(L).
152: *
153:             CALL CLATRS( 'Lower', 'No transpose', 'Non-unit', NORMIN, N,
154:      \$                   A, LDA, WORK, SCALEL, RWORK, INFO )
155:             NORMIN = 'Y'
156: *
157: *           Multiply by inv(L').
158: *
159:             CALL CLATRS( 'Lower', 'Conjugate transpose', 'Non-unit',
160:      \$                   NORMIN, N, A, LDA, WORK, SCALEU, RWORK, INFO )
161:          END IF
162: *
163: *        Multiply by 1/SCALE if doing so will not cause overflow.
164: *
165:          SCALE = SCALEL*SCALEU
166:          IF( SCALE.NE.ONE ) THEN
167:             IX = ICAMAX( N, WORK, 1 )
168:             IF( SCALE.LT.CABS1( WORK( IX ) )*SMLNUM .OR. SCALE.EQ.ZERO )
169:      \$         GO TO 20
170:             CALL CSRSCL( N, SCALE, WORK, 1 )
171:          END IF
172:          GO TO 10
173:       END IF
174: *
175: *     Compute the estimate of the reciprocal condition number.
176: *
177:       IF( AINVNM.NE.ZERO )
178:      \$   RCOND = ( ONE / AINVNM ) / ANORM
179: *
180:    20 CONTINUE
181:       RETURN
182: *
183: *     End of CPOCON
184: *
185:       END
186: ```