001:       SUBROUTINE SSPCON( UPLO, N, AP, IPIV, ANORM, RCOND, WORK, IWORK,
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 SLACN2 in place of SLACON, 5 Feb 03, SJH.
010: *
011: *     .. Scalar Arguments ..
012:       CHARACTER          UPLO
013:       INTEGER            INFO, N
014:       REAL               ANORM, RCOND
015: *     ..
016: *     .. Array Arguments ..
017:       INTEGER            IPIV( * ), IWORK( * )
018:       REAL               AP( * ), WORK( * )
019: *     ..
020: *
021: *  Purpose
022: *  =======
023: *
024: *  SSPCON estimates the reciprocal of the condition number (in the
025: *  1-norm) of a real symmetric packed matrix A using the factorization
026: *  A = U*D*U**T or A = L*D*L**T computed by SSPTRF.
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: *  AP      (input) REAL array, dimension (N*(N+1)/2)
044: *          The block diagonal matrix D and the multipliers used to
045: *          obtain the factor U or L as computed by SSPTRF, stored as a
046: *          packed triangular matrix.
047: *
048: *  IPIV    (input) INTEGER array, dimension (N)
049: *          Details of the interchanges and the block structure of D
050: *          as determined by SSPTRF.
051: *
052: *  ANORM   (input) REAL
053: *          The 1-norm of the original matrix A.
054: *
055: *  RCOND   (output) REAL
056: *          The reciprocal of the condition number of the matrix A,
057: *          computed as RCOND = 1/(ANORM * AINVNM), where AINVNM is an
058: *          estimate of the 1-norm of inv(A) computed in this routine.
059: *
060: *  WORK    (workspace) REAL array, dimension (2*N)
061: *
062: *  IWORK    (workspace) INTEGER array, dimension (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, IP, 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           SLACN2, SSPTRS, XERBLA
088: *     ..
089: *     .. Executable Statements ..
090: *
091: *     Test the input parameters.
092: *
093:       INFO = 0
094:       UPPER = LSAME( UPLO, 'U' )
095:       IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
096:          INFO = -1
097:       ELSE IF( N.LT.0 ) THEN
098:          INFO = -2
099:       ELSE IF( ANORM.LT.ZERO ) THEN
100:          INFO = -5
101:       END IF
102:       IF( INFO.NE.0 ) THEN
103:          CALL XERBLA( 'SSPCON', -INFO )
104:          RETURN
105:       END IF
106: *
107: *     Quick return if possible
108: *
109:       RCOND = ZERO
110:       IF( N.EQ.0 ) THEN
111:          RCOND = ONE
112:          RETURN
113:       ELSE IF( ANORM.LE.ZERO ) THEN
114:          RETURN
115:       END IF
116: *
117: *     Check that the diagonal matrix D is nonsingular.
118: *
119:       IF( UPPER ) THEN
120: *
121: *        Upper triangular storage: examine D from bottom to top
122: *
123:          IP = N*( N+1 ) / 2
124:          DO 10 I = N, 1, -1
125:             IF( IPIV( I ).GT.0 .AND. AP( IP ).EQ.ZERO )
126:      $         RETURN
127:             IP = IP - I
128:    10    CONTINUE
129:       ELSE
130: *
131: *        Lower triangular storage: examine D from top to bottom.
132: *
133:          IP = 1
134:          DO 20 I = 1, N
135:             IF( IPIV( I ).GT.0 .AND. AP( IP ).EQ.ZERO )
136:      $         RETURN
137:             IP = IP + N - I + 1
138:    20    CONTINUE
139:       END IF
140: *
141: *     Estimate the 1-norm of the inverse.
142: *
143:       KASE = 0
144:    30 CONTINUE
145:       CALL SLACN2( N, WORK( N+1 ), WORK, IWORK, AINVNM, KASE, ISAVE )
146:       IF( KASE.NE.0 ) THEN
147: *
148: *        Multiply by inv(L*D*L') or inv(U*D*U').
149: *
150:          CALL SSPTRS( UPLO, N, 1, AP, IPIV, WORK, N, INFO )
151:          GO TO 30
152:       END IF
153: *
154: *     Compute the estimate of the reciprocal condition number.
155: *
156:       IF( AINVNM.NE.ZERO )
157:      $   RCOND = ( ONE / AINVNM ) / ANORM
158: *
159:       RETURN
160: *
161: *     End of SSPCON
162: *
163:       END
164: