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