001:       SUBROUTINE CSYCON( UPLO, N, A, LDA, IPIV, ANORM, RCOND, WORK,
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:       INTEGER            IPIV( * )
018:       COMPLEX            A( LDA, * ), WORK( * )
019: *     ..
020: *
021: *  Purpose
022: *  =======
023: *
024: *  CSYCON estimates the reciprocal of the condition number (in the
025: *  1-norm) of a complex symmetric matrix A using the factorization
026: *  A = U*D*U**T or A = L*D*L**T computed by CSYTRF.
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: *          Specifies whether the details of the factorization are stored
036: *          as an upper or lower triangular matrix.
037: *          = 'U':  Upper triangular, form is A = U*D*U**T;
038: *          = 'L':  Lower triangular, form is A = L*D*L**T.
039: *
040: *  N       (input) INTEGER
041: *          The order of the matrix A.  N >= 0.
042: *
043: *  A       (input) COMPLEX array, dimension (LDA,N)
044: *          The block diagonal matrix D and the multipliers used to
045: *          obtain the factor U or L as computed by CSYTRF.
046: *
047: *  LDA     (input) INTEGER
048: *          The leading dimension of the array A.  LDA >= max(1,N).
049: *
050: *  IPIV    (input) INTEGER array, dimension (N)
051: *          Details of the interchanges and the block structure of D
052: *          as determined by CSYTRF.
053: *
054: *  ANORM   (input) REAL
055: *          The 1-norm of the original matrix A.
056: *
057: *  RCOND   (output) REAL
058: *          The reciprocal of the condition number of the matrix A,
059: *          computed as RCOND = 1/(ANORM * AINVNM), where AINVNM is an
060: *          estimate of the 1-norm of inv(A) computed in this routine.
061: *
062: *  WORK    (workspace) COMPLEX array, dimension (2*N)
063: *
064: *  INFO    (output) INTEGER
065: *          = 0:  successful exit
066: *          < 0:  if INFO = -i, the i-th argument had an illegal value
067: *
068: *  =====================================================================
069: *
070: *     .. Parameters ..
071:       REAL               ONE, ZERO
072:       PARAMETER          ( ONE = 1.0E+0, ZERO = 0.0E+0 )
073: *     ..
074: *     .. Local Scalars ..
075:       LOGICAL            UPPER
076:       INTEGER            I, KASE
077:       REAL               AINVNM
078: *     ..
079: *     .. Local Arrays ..
080:       INTEGER            ISAVE( 3 )
081: *     ..
082: *     .. External Functions ..
083:       LOGICAL            LSAME
084:       EXTERNAL           LSAME
085: *     ..
086: *     .. External Subroutines ..
087:       EXTERNAL           CLACN2, CSYTRS, XERBLA
088: *     ..
089: *     .. Intrinsic Functions ..
090:       INTRINSIC          MAX
091: *     ..
092: *     .. Executable Statements ..
093: *
094: *     Test the input parameters.
095: *
096:       INFO = 0
097:       UPPER = LSAME( UPLO, 'U' )
098:       IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
099:          INFO = -1
100:       ELSE IF( N.LT.0 ) THEN
101:          INFO = -2
102:       ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
103:          INFO = -4
104:       ELSE IF( ANORM.LT.ZERO ) THEN
105:          INFO = -6
106:       END IF
107:       IF( INFO.NE.0 ) THEN
108:          CALL XERBLA( 'CSYCON', -INFO )
109:          RETURN
110:       END IF
111: *
112: *     Quick return if possible
113: *
114:       RCOND = ZERO
115:       IF( N.EQ.0 ) THEN
116:          RCOND = ONE
117:          RETURN
118:       ELSE IF( ANORM.LE.ZERO ) THEN
119:          RETURN
120:       END IF
121: *
122: *     Check that the diagonal matrix D is nonsingular.
123: *
124:       IF( UPPER ) THEN
125: *
126: *        Upper triangular storage: examine D from bottom to top
127: *
128:          DO 10 I = N, 1, -1
129:             IF( IPIV( I ).GT.0 .AND. A( I, I ).EQ.ZERO )
130:      $         RETURN
131:    10    CONTINUE
132:       ELSE
133: *
134: *        Lower triangular storage: examine D from top to bottom.
135: *
136:          DO 20 I = 1, N
137:             IF( IPIV( I ).GT.0 .AND. A( I, I ).EQ.ZERO )
138:      $         RETURN
139:    20    CONTINUE
140:       END IF
141: *
142: *     Estimate the 1-norm of the inverse.
143: *
144:       KASE = 0
145:    30 CONTINUE
146:       CALL CLACN2( N, WORK( N+1 ), WORK, AINVNM, KASE, ISAVE )
147:       IF( KASE.NE.0 ) THEN
148: *
149: *        Multiply by inv(L*D*L') or inv(U*D*U').
150: *
151:          CALL CSYTRS( UPLO, N, 1, A, LDA, IPIV, WORK, N, INFO )
152:          GO TO 30
153:       END IF
154: *
155: *     Compute the estimate of the reciprocal condition number.
156: *
157:       IF( AINVNM.NE.ZERO )
158:      $   RCOND = ( ONE / AINVNM ) / ANORM
159: *
160:       RETURN
161: *
162: *     End of CSYCON
163: *
164:       END
165: