001:       SUBROUTINE DSYCON( UPLO, N, A, LDA, IPIV, ANORM, RCOND, WORK,
002:      $                   IWORK, 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 DLACN2 in place of DLACON, 5 Feb 03, SJH.
010: *
011: *     .. Scalar Arguments ..
012:       CHARACTER          UPLO
013:       INTEGER            INFO, LDA, N
014:       DOUBLE PRECISION   ANORM, RCOND
015: *     ..
016: *     .. Array Arguments ..
017:       INTEGER            IPIV( * ), IWORK( * )
018:       DOUBLE PRECISION   A( LDA, * ), WORK( * )
019: *     ..
020: *
021: *  Purpose
022: *  =======
023: *
024: *  DSYCON estimates the reciprocal of the condition number (in the
025: *  1-norm) of a real symmetric matrix A using the factorization
026: *  A = U*D*U**T or A = L*D*L**T computed by DSYTRF.
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) DOUBLE PRECISION 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 DSYTRF.
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 DSYTRF.
053: *
054: *  ANORM   (input) DOUBLE PRECISION
055: *          The 1-norm of the original matrix A.
056: *
057: *  RCOND   (output) DOUBLE PRECISION
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) DOUBLE PRECISION array, dimension (2*N)
063: *
064: *  IWORK    (workspace) INTEGER array, dimension (N)
065: *
066: *  INFO    (output) INTEGER
067: *          = 0:  successful exit
068: *          < 0:  if INFO = -i, the i-th argument had an illegal value
069: *
070: *  =====================================================================
071: *
072: *     .. Parameters ..
073:       DOUBLE PRECISION   ONE, ZERO
074:       PARAMETER          ( ONE = 1.0D+0, ZERO = 0.0D+0 )
075: *     ..
076: *     .. Local Scalars ..
077:       LOGICAL            UPPER
078:       INTEGER            I, KASE
079:       DOUBLE PRECISION   AINVNM
080: *     ..
081: *     .. Local Arrays ..
082:       INTEGER            ISAVE( 3 )
083: *     ..
084: *     .. External Functions ..
085:       LOGICAL            LSAME
086:       EXTERNAL           LSAME
087: *     ..
088: *     .. External Subroutines ..
089:       EXTERNAL           DLACN2, DSYTRS, XERBLA
090: *     ..
091: *     .. Intrinsic Functions ..
092:       INTRINSIC          MAX
093: *     ..
094: *     .. Executable Statements ..
095: *
096: *     Test the input parameters.
097: *
098:       INFO = 0
099:       UPPER = LSAME( UPLO, 'U' )
100:       IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
101:          INFO = -1
102:       ELSE IF( N.LT.0 ) THEN
103:          INFO = -2
104:       ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
105:          INFO = -4
106:       ELSE IF( ANORM.LT.ZERO ) THEN
107:          INFO = -6
108:       END IF
109:       IF( INFO.NE.0 ) THEN
110:          CALL XERBLA( 'DSYCON', -INFO )
111:          RETURN
112:       END IF
113: *
114: *     Quick return if possible
115: *
116:       RCOND = ZERO
117:       IF( N.EQ.0 ) THEN
118:          RCOND = ONE
119:          RETURN
120:       ELSE IF( ANORM.LE.ZERO ) THEN
121:          RETURN
122:       END IF
123: *
124: *     Check that the diagonal matrix D is nonsingular.
125: *
126:       IF( UPPER ) THEN
127: *
128: *        Upper triangular storage: examine D from bottom to top
129: *
130:          DO 10 I = N, 1, -1
131:             IF( IPIV( I ).GT.0 .AND. A( I, I ).EQ.ZERO )
132:      $         RETURN
133:    10    CONTINUE
134:       ELSE
135: *
136: *        Lower triangular storage: examine D from top to bottom.
137: *
138:          DO 20 I = 1, N
139:             IF( IPIV( I ).GT.0 .AND. A( I, I ).EQ.ZERO )
140:      $         RETURN
141:    20    CONTINUE
142:       END IF
143: *
144: *     Estimate the 1-norm of the inverse.
145: *
146:       KASE = 0
147:    30 CONTINUE
148:       CALL DLACN2( N, WORK( N+1 ), WORK, IWORK, AINVNM, KASE, ISAVE )
149:       IF( KASE.NE.0 ) THEN
150: *
151: *        Multiply by inv(L*D*L') or inv(U*D*U').
152: *
153:          CALL DSYTRS( UPLO, N, 1, A, LDA, IPIV, WORK, N, INFO )
154:          GO TO 30
155:       END IF
156: *
157: *     Compute the estimate of the reciprocal condition number.
158: *
159:       IF( AINVNM.NE.ZERO )
160:      $   RCOND = ( ONE / AINVNM ) / ANORM
161: *
162:       RETURN
163: *
164: *     End of DSYCON
165: *
166:       END
167: