```001:       SUBROUTINE ZGECON( NORM, 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 ZLACN2 in place of ZLACON, 10 Feb 03, SJH.
010: *
011: *     .. Scalar Arguments ..
012:       CHARACTER          NORM
013:       INTEGER            INFO, LDA, N
014:       DOUBLE PRECISION   ANORM, RCOND
015: *     ..
016: *     .. Array Arguments ..
017:       DOUBLE PRECISION   RWORK( * )
018:       COMPLEX*16         A( LDA, * ), WORK( * )
019: *     ..
020: *
021: *  Purpose
022: *  =======
023: *
024: *  ZGECON estimates the reciprocal of the condition number of a general
025: *  complex matrix A, in either the 1-norm or the infinity-norm, using
026: *  the LU factorization computed by ZGETRF.
027: *
028: *  An estimate is obtained for norm(inv(A)), and the reciprocal of the
029: *  condition number is computed as
030: *     RCOND = 1 / ( norm(A) * norm(inv(A)) ).
031: *
032: *  Arguments
033: *  =========
034: *
035: *  NORM    (input) CHARACTER*1
036: *          Specifies whether the 1-norm condition number or the
037: *          infinity-norm condition number is required:
038: *          = '1' or 'O':  1-norm;
039: *          = 'I':         Infinity-norm.
040: *
041: *  N       (input) INTEGER
042: *          The order of the matrix A.  N >= 0.
043: *
044: *  A       (input) COMPLEX*16 array, dimension (LDA,N)
045: *          The factors L and U from the factorization A = P*L*U
046: *          as computed by ZGETRF.
047: *
048: *  LDA     (input) INTEGER
049: *          The leading dimension of the array A.  LDA >= max(1,N).
050: *
051: *  ANORM   (input) DOUBLE PRECISION
052: *          If NORM = '1' or 'O', the 1-norm of the original matrix A.
053: *          If NORM = 'I', the infinity-norm of the original matrix A.
054: *
055: *  RCOND   (output) DOUBLE PRECISION
056: *          The reciprocal of the condition number of the matrix A,
057: *          computed as RCOND = 1/(norm(A) * norm(inv(A))).
058: *
059: *  WORK    (workspace) COMPLEX*16 array, dimension (2*N)
060: *
061: *  RWORK   (workspace) DOUBLE PRECISION array, dimension (2*N)
062: *
063: *  INFO    (output) INTEGER
064: *          = 0:  successful exit
065: *          < 0:  if INFO = -i, the i-th argument had an illegal value
066: *
067: *  =====================================================================
068: *
069: *     .. Parameters ..
070:       DOUBLE PRECISION   ONE, ZERO
071:       PARAMETER          ( ONE = 1.0D+0, ZERO = 0.0D+0 )
072: *     ..
073: *     .. Local Scalars ..
074:       LOGICAL            ONENRM
075:       CHARACTER          NORMIN
076:       INTEGER            IX, KASE, KASE1
077:       DOUBLE PRECISION   AINVNM, SCALE, SL, SMLNUM, SU
078:       COMPLEX*16         ZDUM
079: *     ..
080: *     .. Local Arrays ..
081:       INTEGER            ISAVE( 3 )
082: *     ..
083: *     .. External Functions ..
084:       LOGICAL            LSAME
085:       INTEGER            IZAMAX
086:       DOUBLE PRECISION   DLAMCH
087:       EXTERNAL           LSAME, IZAMAX, DLAMCH
088: *     ..
089: *     .. External Subroutines ..
090:       EXTERNAL           XERBLA, ZDRSCL, ZLACN2, ZLATRS
091: *     ..
092: *     .. Intrinsic Functions ..
093:       INTRINSIC          ABS, DBLE, DIMAG, MAX
094: *     ..
095: *     .. Statement Functions ..
096:       DOUBLE PRECISION   CABS1
097: *     ..
098: *     .. Statement Function definitions ..
099:       CABS1( ZDUM ) = ABS( DBLE( ZDUM ) ) + ABS( DIMAG( ZDUM ) )
100: *     ..
101: *     .. Executable Statements ..
102: *
103: *     Test the input parameters.
104: *
105:       INFO = 0
106:       ONENRM = NORM.EQ.'1' .OR. LSAME( NORM, 'O' )
107:       IF( .NOT.ONENRM .AND. .NOT.LSAME( NORM, 'I' ) ) THEN
108:          INFO = -1
109:       ELSE IF( N.LT.0 ) THEN
110:          INFO = -2
111:       ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
112:          INFO = -4
113:       ELSE IF( ANORM.LT.ZERO ) THEN
114:          INFO = -5
115:       END IF
116:       IF( INFO.NE.0 ) THEN
117:          CALL XERBLA( 'ZGECON', -INFO )
118:          RETURN
119:       END IF
120: *
121: *     Quick return if possible
122: *
123:       RCOND = ZERO
124:       IF( N.EQ.0 ) THEN
125:          RCOND = ONE
126:          RETURN
127:       ELSE IF( ANORM.EQ.ZERO ) THEN
128:          RETURN
129:       END IF
130: *
131:       SMLNUM = DLAMCH( 'Safe minimum' )
132: *
133: *     Estimate the norm of inv(A).
134: *
135:       AINVNM = ZERO
136:       NORMIN = 'N'
137:       IF( ONENRM ) THEN
138:          KASE1 = 1
139:       ELSE
140:          KASE1 = 2
141:       END IF
142:       KASE = 0
143:    10 CONTINUE
144:       CALL ZLACN2( N, WORK( N+1 ), WORK, AINVNM, KASE, ISAVE )
145:       IF( KASE.NE.0 ) THEN
146:          IF( KASE.EQ.KASE1 ) THEN
147: *
148: *           Multiply by inv(L).
149: *
150:             CALL ZLATRS( 'Lower', 'No transpose', 'Unit', NORMIN, N, A,
151:      \$                   LDA, WORK, SL, RWORK, INFO )
152: *
153: *           Multiply by inv(U).
154: *
155:             CALL ZLATRS( 'Upper', 'No transpose', 'Non-unit', NORMIN, N,
156:      \$                   A, LDA, WORK, SU, RWORK( N+1 ), INFO )
157:          ELSE
158: *
159: *           Multiply by inv(U').
160: *
161:             CALL ZLATRS( 'Upper', 'Conjugate transpose', 'Non-unit',
162:      \$                   NORMIN, N, A, LDA, WORK, SU, RWORK( N+1 ),
163:      \$                   INFO )
164: *
165: *           Multiply by inv(L').
166: *
167:             CALL ZLATRS( 'Lower', 'Conjugate transpose', 'Unit', NORMIN,
168:      \$                   N, A, LDA, WORK, SL, RWORK, INFO )
169:          END IF
170: *
171: *        Divide X by 1/(SL*SU) if doing so will not cause overflow.
172: *
173:          SCALE = SL*SU
174:          NORMIN = 'Y'
175:          IF( SCALE.NE.ONE ) THEN
176:             IX = IZAMAX( N, WORK, 1 )
177:             IF( SCALE.LT.CABS1( WORK( IX ) )*SMLNUM .OR. SCALE.EQ.ZERO )
178:      \$         GO TO 20
179:             CALL ZDRSCL( N, SCALE, WORK, 1 )
180:          END IF
181:          GO TO 10
182:       END IF
183: *
184: *     Compute the estimate of the reciprocal condition number.
185: *
186:       IF( AINVNM.NE.ZERO )
187:      \$   RCOND = ( ONE / AINVNM ) / ANORM
188: *
189:    20 CONTINUE
190:       RETURN
191: *
192: *     End of ZGECON
193: *
194:       END
195: ```