```001:       REAL FUNCTION CLA_SYRCOND_C( UPLO, N, A, LDA, AF, LDAF, IPIV, C,
002:      \$                             CAPPLY, 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:       LOGICAL            CAPPLY
017:       INTEGER            N, LDA, LDAF, INFO
018: *     ..
019: *     .. Array Arguments ..
020:       INTEGER            IPIV( * )
021:       COMPLEX            A( LDA, * ), AF( LDAF, * ), WORK( * )
022:       REAL               C( * ), RWORK( * )
023: *     ..
024: *
025: *  Purpose
026: *  =======
027: *
028: *     CLA_SYRCOND_C Computes the infinity norm condition number of
029: *     op(A) * inv(diag(C)) where C is a REAL vector.
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 number of linear equations, i.e., the order of the
040: *     matrix A.  N >= 0.
041: *
042: *     A       (input) COMPLEX array, dimension (LDA,N)
043: *     On entry, the N-by-N matrix A
044: *
045: *     LDA     (input) INTEGER
046: *     The leading dimension of the array A.  LDA >= max(1,N).
047: *
048: *     AF      (input) COMPLEX array, dimension (LDAF,N)
049: *     The block diagonal matrix D and the multipliers used to
050: *     obtain the factor U or L as computed by CSYTRF.
051: *
052: *     LDAF    (input) INTEGER
053: *     The leading dimension of the array AF.  LDAF >= max(1,N).
054: *
055: *     IPIV    (input) INTEGER array, dimension (N)
056: *     Details of the interchanges and the block structure of D
057: *     as determined by CSYTRF.
058: *
059: *     C       (input) REAL array, dimension (N)
060: *     The vector C in the formula op(A) * inv(diag(C)).
061: *
062: *     CAPPLY  (input) LOGICAL
063: *     If .TRUE. then access the vector C in the formula above.
064: *
065: *     INFO    (output) INTEGER
066: *       = 0:  Successful exit.
067: *     i > 0:  The ith argument is invalid.
068: *
069: *     WORK    (input) COMPLEX array, dimension (2*N).
070: *     Workspace.
071: *
072: *     RWORK   (input) REAL array, dimension (N).
073: *     Workspace.
074: *
075: *  =====================================================================
076: *
077: *     .. Local Scalars ..
078:       INTEGER            KASE
079:       REAL               AINVNM, ANORM, TMP
080:       INTEGER            I, J
081:       LOGICAL            UP
082:       COMPLEX            ZDUM
083: *     ..
084: *     .. Local Arrays ..
085:       INTEGER            ISAVE( 3 )
086: *     ..
087: *     .. External Functions ..
088:       LOGICAL            LSAME
089:       EXTERNAL           LSAME
090: *     ..
091: *     .. External Subroutines ..
092:       EXTERNAL           CLACN2, CSYTRS, XERBLA
093: *     ..
094: *     .. Intrinsic Functions ..
095:       INTRINSIC          ABS, MAX
096: *     ..
097: *     .. Statement Functions ..
098:       REAL CABS1
099: *     ..
100: *     .. Statement Function Definitions ..
101:       CABS1( ZDUM ) = ABS( REAL( ZDUM ) ) + ABS( AIMAG( ZDUM ) )
102: *     ..
103: *     .. Executable Statements ..
104: *
105:       CLA_SYRCOND_C = 0.0E+0
106: *
107:       INFO = 0
108:       IF( N.LT.0 ) THEN
109:          INFO = -2
110:       END IF
111:       IF( INFO.NE.0 ) THEN
112:          CALL XERBLA( 'CLA_SYRCOND_C', -INFO )
113:          RETURN
114:       END IF
115:       UP = .FALSE.
116:       IF ( LSAME( UPLO, 'U' ) ) UP = .TRUE.
117: *
118: *     Compute norm of op(A)*op2(C).
119: *
120:       ANORM = 0.0E+0
121:       IF ( UP ) THEN
122:          DO I = 1, N
123:             TMP = 0.0E+0
124:             IF ( CAPPLY ) THEN
125:                DO J = 1, I
126:                   TMP = TMP + CABS1( A( J, I ) ) / C( J )
127:                END DO
128:                DO J = I+1, N
129:                   TMP = TMP + CABS1( A( I, J ) ) / C( J )
130:                END DO
131:             ELSE
132:                DO J = 1, I
133:                   TMP = TMP + CABS1( A( J, I ) )
134:                END DO
135:                DO J = I+1, N
136:                   TMP = TMP + CABS1( A( I, J ) )
137:                END DO
138:             END IF
139:             RWORK( I ) = TMP
140:             ANORM = MAX( ANORM, TMP )
141:          END DO
142:       ELSE
143:          DO I = 1, N
144:             TMP = 0.0E+0
145:             IF ( CAPPLY ) THEN
146:                DO J = 1, I
147:                   TMP = TMP + CABS1( A( I, J ) ) / C( J )
148:                END DO
149:                DO J = I+1, N
150:                   TMP = TMP + CABS1( A( J, I ) ) / C( J )
151:                END DO
152:             ELSE
153:                DO J = 1, I
154:                   TMP = TMP + CABS1( A( I, J ) )
155:                END DO
156:                DO J = I+1, N
157:                   TMP = TMP + CABS1( A( J, I ) )
158:                END DO
159:             END IF
160:             RWORK( I ) = TMP
161:             ANORM = MAX( ANORM, TMP )
162:          END DO
163:       END IF
164: *
165: *     Quick return if possible.
166: *
167:       IF( N.EQ.0 ) THEN
168:          CLA_SYRCOND_C = 1.0E+0
169:          RETURN
170:       ELSE IF( ANORM .EQ. 0.0E+0 ) THEN
171:          RETURN
172:       END IF
173: *
174: *     Estimate the norm of inv(op(A)).
175: *
176:       AINVNM = 0.0E+0
177: *
178:       KASE = 0
179:    10 CONTINUE
180:       CALL CLACN2( N, WORK( N+1 ), WORK, AINVNM, KASE, ISAVE )
181:       IF( KASE.NE.0 ) THEN
182:          IF( KASE.EQ.2 ) THEN
183: *
184: *           Multiply by R.
185: *
186:             DO I = 1, N
187:                WORK( I ) = WORK( I ) * RWORK( I )
188:             END DO
189: *
190:             IF ( UP ) THEN
191:                CALL CSYTRS( 'U', N, 1, AF, LDAF, IPIV,
192:      \$            WORK, N, INFO )
193:             ELSE
194:                CALL CSYTRS( 'L', N, 1, AF, LDAF, IPIV,
195:      \$            WORK, N, INFO )
196:             ENDIF
197: *
198: *           Multiply by inv(C).
199: *
200:             IF ( CAPPLY ) THEN
201:                DO I = 1, N
202:                   WORK( I ) = WORK( I ) * C( I )
203:                END DO
204:             END IF
205:          ELSE
206: *
207: *           Multiply by inv(C').
208: *
209:             IF ( CAPPLY ) THEN
210:                DO I = 1, N
211:                   WORK( I ) = WORK( I ) * C( I )
212:                END DO
213:             END IF
214: *
215:             IF ( UP ) THEN
216:                CALL CSYTRS( 'U', N, 1, AF, LDAF, IPIV,
217:      \$            WORK, N, INFO )
218:             ELSE
219:                CALL CSYTRS( 'L', N, 1, AF, LDAF, IPIV,
220:      \$            WORK, N, INFO )
221:             END IF
222: *
223: *           Multiply by R.
224: *
225:             DO I = 1, N
226:                WORK( I ) = WORK( I ) * RWORK( I )
227:             END DO
228:          END IF
229:          GO TO 10
230:       END IF
231: *
232: *     Compute the estimate of the reciprocal condition number.
233: *
234:       IF( AINVNM .NE. 0.0E+0 )
235:      \$   CLA_SYRCOND_C = 1.0E+0 / AINVNM
236: *
237:       RETURN
238: *
239:       END
240: ```