```001:       REAL FUNCTION CLA_SYRCOND_X( UPLO, N, A, LDA, AF, LDAF, IPIV, X,
002:      \$                             INFO, WORK, RWORK )
003: *
004: *     -- LAPACK routine (version 3.2.1)                                 --
005: *     -- Contributed by James Demmel, Deaglan Halligan, Yozo Hida and --
006: *     -- Jason Riedy of Univ. of California Berkeley.                 --
007: *     -- April 2009                                                   --
008: *
009: *     -- LAPACK is a software package provided by Univ. of Tennessee, --
010: *     -- Univ. of California Berkeley and NAG Ltd.                    --
011: *
012:       IMPLICIT NONE
013: *     ..
014: *     .. Scalar Arguments ..
015:       CHARACTER          UPLO
016:       INTEGER            N, LDA, LDAF, INFO
017: *     ..
018: *     .. Array Arguments ..
019:       INTEGER            IPIV( * )
020:       COMPLEX            A( LDA, * ), AF( LDAF, * ), WORK( * ), X( * )
021:       REAL               RWORK( * )
022: *     ..
023: *
024: *  Purpose
025: *  =======
026: *
027: *     CLA_SYRCOND_X Computes the infinity norm condition number of
028: *     op(A) * diag(X) where X is a COMPLEX vector.
029: *
030: *  Arguments
031: *  =========
032: *
033: *     UPLO    (input) CHARACTER*1
034: *       = 'U':  Upper triangle of A is stored;
035: *       = 'L':  Lower triangle of A is stored.
036: *
037: *     N       (input) INTEGER
038: *     The number of linear equations, i.e., the order of the
039: *     matrix A.  N >= 0.
040: *
041: *     A       (input) COMPLEX array, dimension (LDA,N)
042: *     On entry, the N-by-N matrix A.
043: *
044: *     LDA     (input) INTEGER
045: *     The leading dimension of the array A.  LDA >= max(1,N).
046: *
047: *     AF      (input) COMPLEX array, dimension (LDAF,N)
048: *     The block diagonal matrix D and the multipliers used to
049: *     obtain the factor U or L as computed by CSYTRF.
050: *
051: *     LDAF    (input) INTEGER
052: *     The leading dimension of the array AF.  LDAF >= max(1,N).
053: *
054: *     IPIV    (input) INTEGER array, dimension (N)
055: *     Details of the interchanges and the block structure of D
056: *     as determined by CSYTRF.
057: *
058: *     X       (input) COMPLEX array, dimension (N)
059: *     The vector X in the formula op(A) * diag(X).
060: *
061: *     INFO    (output) INTEGER
062: *       = 0:  Successful exit.
063: *     i > 0:  The ith argument is invalid.
064: *
065: *     WORK    (input) COMPLEX array, dimension (2*N).
066: *     Workspace.
067: *
068: *     RWORK   (input) REAL array, dimension (N).
069: *     Workspace.
070: *
071: *  =====================================================================
072: *
073: *     .. Local Scalars ..
074:       INTEGER            KASE
075:       REAL               AINVNM, ANORM, TMP
076:       INTEGER            I, J
077:       LOGICAL            UP
078:       COMPLEX            ZDUM
079: *     ..
080: *     .. Local Arrays ..
081:       INTEGER            ISAVE( 3 )
082: *     ..
083: *     .. External Functions ..
084:       LOGICAL            LSAME
085:       EXTERNAL           LSAME
086: *     ..
087: *     .. External Subroutines ..
088:       EXTERNAL           CLACN2, CSYTRS, XERBLA
089: *     ..
090: *     .. Intrinsic Functions ..
091:       INTRINSIC          ABS, MAX
092: *     ..
093: *     .. Statement Functions ..
094:       REAL               CABS1
095: *     ..
096: *     .. Statement Function Definitions ..
097:       CABS1( ZDUM ) = ABS( REAL( ZDUM ) ) + ABS( AIMAG( ZDUM ) )
098: *     ..
099: *     .. Executable Statements ..
100: *
101:       CLA_SYRCOND_X = 0.0E+0
102: *
103:       INFO = 0
104:       IF( N.LT.0 ) THEN
105:          INFO = -2
106:       END IF
107:       IF( INFO.NE.0 ) THEN
108:          CALL XERBLA( 'CLA_SYRCOND_X', -INFO )
109:          RETURN
110:       END IF
111:       UP = .FALSE.
112:       IF ( LSAME( UPLO, 'U' ) ) UP = .TRUE.
113: *
114: *     Compute norm of op(A)*op2(C).
115: *
116:       ANORM = 0.0
117:       IF ( UP ) THEN
118:          DO I = 1, N
119:             TMP = 0.0E+0
120:             DO J = 1, I
121:                TMP = TMP + CABS1( A( J, I ) * X( J ) )
122:             END DO
123:             DO J = I+1, N
124:                TMP = TMP + CABS1( A( I, J ) * X( J ) )
125:             END DO
126:             RWORK( I ) = TMP
127:             ANORM = MAX( ANORM, TMP )
128:          END DO
129:       ELSE
130:          DO I = 1, N
131:             TMP = 0.0E+0
132:             DO J = 1, I
133:                TMP = TMP + CABS1( A( I, J ) * X( J ) )
134:             END DO
135:             DO J = I+1, N
136:                TMP = TMP + CABS1( A( J, I ) * X( J ) )
137:             END DO
138:             RWORK( I ) = TMP
139:             ANORM = MAX( ANORM, TMP )
140:          END DO
141:       END IF
142: *
143: *     Quick return if possible.
144: *
145:       IF( N.EQ.0 ) THEN
146:          CLA_SYRCOND_X = 1.0E+0
147:          RETURN
148:       ELSE IF( ANORM .EQ. 0.0E+0 ) THEN
149:          RETURN
150:       END IF
151: *
152: *     Estimate the norm of inv(op(A)).
153: *
154:       AINVNM = 0.0E+0
155: *
156:       KASE = 0
157:    10 CONTINUE
158:       CALL CLACN2( N, WORK( N+1 ), WORK, AINVNM, KASE, ISAVE )
159:       IF( KASE.NE.0 ) THEN
160:          IF( KASE.EQ.2 ) THEN
161: *
162: *           Multiply by R.
163: *
164:             DO I = 1, N
165:                WORK( I ) = WORK( I ) * RWORK( I )
166:             END DO
167: *
168:             IF ( UP ) THEN
169:                CALL CSYTRS( 'U', N, 1, AF, LDAF, IPIV,
170:      \$            WORK, N, INFO )
171:             ELSE
172:                CALL CSYTRS( 'L', N, 1, AF, LDAF, IPIV,
173:      \$            WORK, N, INFO )
174:             ENDIF
175: *
176: *           Multiply by inv(X).
177: *
178:             DO I = 1, N
179:                WORK( I ) = WORK( I ) / X( I )
180:             END DO
181:          ELSE
182: *
183: *           Multiply by inv(X').
184: *
185:             DO I = 1, N
186:                WORK( I ) = WORK( I ) / X( I )
187:             END DO
188: *
189:             IF ( UP ) THEN
190:                CALL CSYTRS( 'U', N, 1, AF, LDAF, IPIV,
191:      \$            WORK, N, INFO )
192:             ELSE
193:                CALL CSYTRS( 'L', N, 1, AF, LDAF, IPIV,
194:      \$            WORK, N, INFO )
195:             END IF
196: *
197: *           Multiply by R.
198: *
199:             DO I = 1, N
200:                WORK( I ) = WORK( I ) * RWORK( I )
201:             END DO
202:          END IF
203:          GO TO 10
204:       END IF
205: *
206: *     Compute the estimate of the reciprocal condition number.
207: *
208:       IF( AINVNM .NE. 0.0E+0 )
209:      \$   CLA_SYRCOND_X = 1.0E+0 / AINVNM
210: *
211:       RETURN
212: *
213:       END
214: ```