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