1 SUBROUTINE STPCON( NORM, UPLO, DIAG, N, AP, RCOND, WORK, IWORK, 2 $ INFO ) 3* 4* -- LAPACK routine (version 3.0) -- 5* Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd., 6* Courant Institute, Argonne National Lab, and Rice University 7* March 31, 1993 8* 9* .. Scalar Arguments .. 10 CHARACTER DIAG, NORM, UPLO 11 INTEGER INFO, N 12 REAL RCOND 13* .. 14* .. Array Arguments .. 15 INTEGER IWORK( * ) 16 REAL AP( * ), WORK( * ) 17* .. 18* 19* Purpose 20* ======= 21* 22* STPCON estimates the reciprocal of the condition number of a packed 23* triangular matrix A, in either the 1-norm or the infinity-norm. 24* 25* The norm of A is computed and an estimate is obtained for 26* norm(inv(A)), then the reciprocal of the condition number is 27* computed as 28* RCOND = 1 / ( norm(A) * norm(inv(A)) ). 29* 30* Arguments 31* ========= 32* 33* NORM (input) CHARACTER*1 34* Specifies whether the 1-norm condition number or the 35* infinity-norm condition number is required: 36* = '1' or 'O': 1-norm; 37* = 'I': Infinity-norm. 38* 39* UPLO (input) CHARACTER*1 40* = 'U': A is upper triangular; 41* = 'L': A is lower triangular. 42* 43* DIAG (input) CHARACTER*1 44* = 'N': A is non-unit triangular; 45* = 'U': A is unit triangular. 46* 47* N (input) INTEGER 48* The order of the matrix A. N >= 0. 49* 50* AP (input) REAL array, dimension (N*(N+1)/2) 51* The upper or lower triangular matrix A, packed columnwise in 52* a linear array. The j-th column of A is stored in the array 53* AP as follows: 54* if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; 55* if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n. 56* If DIAG = 'U', the diagonal elements of A are not referenced 57* and are assumed to be 1. 58* 59* RCOND (output) REAL 60* The reciprocal of the condition number of the matrix A, 61* computed as RCOND = 1/(norm(A) * norm(inv(A))). 62* 63* WORK (workspace) REAL array, dimension (3*N) 64* 65* IWORK (workspace) INTEGER array, dimension (N) 66* 67* INFO (output) INTEGER 68* = 0: successful exit 69* < 0: if INFO = -i, the i-th argument had an illegal value 70* 71* ===================================================================== 72* 73* .. Parameters .. 74 REAL ONE, ZERO 75 PARAMETER ( ONE = 1.0E+0, ZERO = 0.0E+0 ) 76* .. 77* .. Local Scalars .. 78 LOGICAL NOUNIT, ONENRM, UPPER 79 CHARACTER NORMIN 80 INTEGER IX, KASE, KASE1 81 REAL AINVNM, ANORM, SCALE, SMLNUM, XNORM 82* .. 83* .. External Functions .. 84 LOGICAL LSAME 85 INTEGER ISAMAX 86 REAL SLAMCH, SLANTP 87 EXTERNAL LSAME, ISAMAX, SLAMCH, SLANTP 88* .. 89* .. External Subroutines .. 90 EXTERNAL SLACON, SLATPS, SRSCL, XERBLA 91* .. 92* .. Intrinsic Functions .. 93 INTRINSIC ABS, MAX, REAL 94* .. 95* .. Executable Statements .. 96* 97* Test the input parameters. 98* 99 INFO = 0 100 UPPER = LSAME( UPLO, 'U' ) 101 ONENRM = NORM.EQ.'1' .OR. LSAME( NORM, 'O' ) 102 NOUNIT = LSAME( DIAG, 'N' ) 103* 104 IF( .NOT.ONENRM .AND. .NOT.LSAME( NORM, 'I' ) ) THEN 105 INFO = -1 106 ELSE IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN 107 INFO = -2 108 ELSE IF( .NOT.NOUNIT .AND. .NOT.LSAME( DIAG, 'U' ) ) THEN 109 INFO = -3 110 ELSE IF( N.LT.0 ) THEN 111 INFO = -4 112 END IF 113 IF( INFO.NE.0 ) THEN 114 CALL XERBLA( 'STPCON', -INFO ) 115 RETURN 116 END IF 117* 118* Quick return if possible 119* 120 IF( N.EQ.0 ) THEN 121 RCOND = ONE 122 RETURN 123 END IF 124* 125 RCOND = ZERO 126 SMLNUM = SLAMCH( 'Safe minimum' )*REAL( MAX( 1, N ) ) 127* 128* Compute the norm of the triangular matrix A. 129* 130 ANORM = SLANTP( NORM, UPLO, DIAG, N, AP, WORK ) 131* 132* Continue only if ANORM > 0. 133* 134 IF( ANORM.GT.ZERO ) THEN 135* 136* Estimate the norm of the inverse of A. 137* 138 AINVNM = ZERO 139 NORMIN = 'N' 140 IF( ONENRM ) THEN 141 KASE1 = 1 142 ELSE 143 KASE1 = 2 144 END IF 145 KASE = 0 146 10 CONTINUE 147 CALL SLACON( N, WORK( N+1 ), WORK, IWORK, AINVNM, KASE ) 148 IF( KASE.NE.0 ) THEN 149 IF( KASE.EQ.KASE1 ) THEN 150* 151* Multiply by inv(A). 152* 153 CALL SLATPS( UPLO, 'No transpose', DIAG, NORMIN, N, AP, 154 $ WORK, SCALE, WORK( 2*N+1 ), INFO ) 155 ELSE 156* 157* Multiply by inv(A'). 158* 159 CALL SLATPS( UPLO, 'Transpose', DIAG, NORMIN, N, AP, 160 $ WORK, SCALE, WORK( 2*N+1 ), INFO ) 161 END IF 162 NORMIN = 'Y' 163* 164* Multiply by 1/SCALE if doing so will not cause overflow. 165* 166 IF( SCALE.NE.ONE ) THEN 167 IX = ISAMAX( N, WORK, 1 ) 168 XNORM = ABS( WORK( IX ) ) 169 IF( SCALE.LT.XNORM*SMLNUM .OR. SCALE.EQ.ZERO ) 170 $ GO TO 20 171 CALL SRSCL( N, SCALE, WORK, 1 ) 172 END IF 173 GO TO 10 174 END IF 175* 176* Compute the estimate of the reciprocal condition number. 177* 178 IF( AINVNM.NE.ZERO ) 179 $ RCOND = ( ONE / ANORM ) / AINVNM 180 END IF 181* 182 20 CONTINUE 183 RETURN 184* 185* End of STPCON 186* 187 END 188