```001:       SUBROUTINE DPOCON( UPLO, N, A, LDA, 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 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            IWORK( * )
018:       DOUBLE PRECISION   A( LDA, * ), WORK( * )
019: *     ..
020: *
021: *  Purpose
022: *  =======
023: *
024: *  DPOCON estimates the reciprocal of the condition number (in the
025: *  1-norm) of a real symmetric positive definite matrix using the
026: *  Cholesky factorization A = U**T*U or A = L*L**T computed by DPOTRF.
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: *          = 'U':  Upper triangle of A is stored;
036: *          = 'L':  Lower triangle of A is stored.
037: *
038: *  N       (input) INTEGER
039: *          The order of the matrix A.  N >= 0.
040: *
041: *  A       (input) DOUBLE PRECISION array, dimension (LDA,N)
042: *          The triangular factor U or L from the Cholesky factorization
043: *          A = U**T*U or A = L*L**T, as computed by DPOTRF.
044: *
045: *  LDA     (input) INTEGER
046: *          The leading dimension of the array A.  LDA >= max(1,N).
047: *
048: *  ANORM   (input) DOUBLE PRECISION
049: *          The 1-norm (or infinity-norm) of the symmetric matrix A.
050: *
051: *  RCOND   (output) DOUBLE PRECISION
052: *          The reciprocal of the condition number of the matrix A,
053: *          computed as RCOND = 1/(ANORM * AINVNM), where AINVNM is an
054: *          estimate of the 1-norm of inv(A) computed in this routine.
055: *
056: *  WORK    (workspace) DOUBLE PRECISION array, dimension (3*N)
057: *
058: *  IWORK   (workspace) INTEGER array, dimension (N)
059: *
060: *  INFO    (output) INTEGER
061: *          = 0:  successful exit
062: *          < 0:  if INFO = -i, the i-th argument had an illegal value
063: *
064: *  =====================================================================
065: *
066: *     .. Parameters ..
067:       DOUBLE PRECISION   ONE, ZERO
068:       PARAMETER          ( ONE = 1.0D+0, ZERO = 0.0D+0 )
069: *     ..
070: *     .. Local Scalars ..
071:       LOGICAL            UPPER
072:       CHARACTER          NORMIN
073:       INTEGER            IX, KASE
074:       DOUBLE PRECISION   AINVNM, SCALE, SCALEL, SCALEU, SMLNUM
075: *     ..
076: *     .. Local Arrays ..
077:       INTEGER            ISAVE( 3 )
078: *     ..
079: *     .. External Functions ..
080:       LOGICAL            LSAME
081:       INTEGER            IDAMAX
082:       DOUBLE PRECISION   DLAMCH
083:       EXTERNAL           LSAME, IDAMAX, DLAMCH
084: *     ..
085: *     .. External Subroutines ..
086:       EXTERNAL           DLACN2, DLATRS, DRSCL, XERBLA
087: *     ..
088: *     .. Intrinsic Functions ..
089:       INTRINSIC          ABS, MAX
090: *     ..
091: *     .. Executable Statements ..
092: *
093: *     Test the input parameters.
094: *
095:       INFO = 0
096:       UPPER = LSAME( UPLO, 'U' )
097:       IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
098:          INFO = -1
099:       ELSE IF( N.LT.0 ) THEN
100:          INFO = -2
101:       ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
102:          INFO = -4
103:       ELSE IF( ANORM.LT.ZERO ) THEN
104:          INFO = -5
105:       END IF
106:       IF( INFO.NE.0 ) THEN
107:          CALL XERBLA( 'DPOCON', -INFO )
108:          RETURN
109:       END IF
110: *
111: *     Quick return if possible
112: *
113:       RCOND = ZERO
114:       IF( N.EQ.0 ) THEN
115:          RCOND = ONE
116:          RETURN
117:       ELSE IF( ANORM.EQ.ZERO ) THEN
118:          RETURN
119:       END IF
120: *
121:       SMLNUM = DLAMCH( 'Safe minimum' )
122: *
123: *     Estimate the 1-norm of inv(A).
124: *
125:       KASE = 0
126:       NORMIN = 'N'
127:    10 CONTINUE
128:       CALL DLACN2( N, WORK( N+1 ), WORK, IWORK, AINVNM, KASE, ISAVE )
129:       IF( KASE.NE.0 ) THEN
130:          IF( UPPER ) THEN
131: *
132: *           Multiply by inv(U').
133: *
134:             CALL DLATRS( 'Upper', 'Transpose', 'Non-unit', NORMIN, N, A,
135:      \$                   LDA, WORK, SCALEL, WORK( 2*N+1 ), INFO )
136:             NORMIN = 'Y'
137: *
138: *           Multiply by inv(U).
139: *
140:             CALL DLATRS( 'Upper', 'No transpose', 'Non-unit', NORMIN, N,
141:      \$                   A, LDA, WORK, SCALEU, WORK( 2*N+1 ), INFO )
142:          ELSE
143: *
144: *           Multiply by inv(L).
145: *
146:             CALL DLATRS( 'Lower', 'No transpose', 'Non-unit', NORMIN, N,
147:      \$                   A, LDA, WORK, SCALEL, WORK( 2*N+1 ), INFO )
148:             NORMIN = 'Y'
149: *
150: *           Multiply by inv(L').
151: *
152:             CALL DLATRS( 'Lower', 'Transpose', 'Non-unit', NORMIN, N, A,
153:      \$                   LDA, WORK, SCALEU, WORK( 2*N+1 ), INFO )
154:          END IF
155: *
156: *        Multiply by 1/SCALE if doing so will not cause overflow.
157: *
158:          SCALE = SCALEL*SCALEU
159:          IF( SCALE.NE.ONE ) THEN
160:             IX = IDAMAX( N, WORK, 1 )
161:             IF( SCALE.LT.ABS( WORK( IX ) )*SMLNUM .OR. SCALE.EQ.ZERO )
162:      \$         GO TO 20
163:             CALL DRSCL( N, SCALE, WORK, 1 )
164:          END IF
165:          GO TO 10
166:       END IF
167: *
168: *     Compute the estimate of the reciprocal condition number.
169: *
170:       IF( AINVNM.NE.ZERO )
171:      \$   RCOND = ( ONE / AINVNM ) / ANORM
172: *
173:    20 CONTINUE
174:       RETURN
175: *
176: *     End of DPOCON
177: *
178:       END
179: ```