LAPACK 3.3.1
Linear Algebra PACKage
|
00001 SUBROUTINE STPCON( NORM, UPLO, DIAG, N, AP, RCOND, WORK, IWORK, 00002 $ INFO ) 00003 * 00004 * -- LAPACK routine (version 3.2) -- 00005 * -- LAPACK is a software package provided by Univ. of Tennessee, -- 00006 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- 00007 * November 2006 00008 * 00009 * Modified to call SLACN2 in place of SLACON, 7 Feb 03, SJH. 00010 * 00011 * .. Scalar Arguments .. 00012 CHARACTER DIAG, NORM, UPLO 00013 INTEGER INFO, N 00014 REAL RCOND 00015 * .. 00016 * .. Array Arguments .. 00017 INTEGER IWORK( * ) 00018 REAL AP( * ), WORK( * ) 00019 * .. 00020 * 00021 * Purpose 00022 * ======= 00023 * 00024 * STPCON estimates the reciprocal of the condition number of a packed 00025 * triangular matrix A, in either the 1-norm or the infinity-norm. 00026 * 00027 * The norm of A is computed and an estimate is obtained for 00028 * norm(inv(A)), then the reciprocal of the condition number is 00029 * computed as 00030 * RCOND = 1 / ( norm(A) * norm(inv(A)) ). 00031 * 00032 * Arguments 00033 * ========= 00034 * 00035 * NORM (input) CHARACTER*1 00036 * Specifies whether the 1-norm condition number or the 00037 * infinity-norm condition number is required: 00038 * = '1' or 'O': 1-norm; 00039 * = 'I': Infinity-norm. 00040 * 00041 * UPLO (input) CHARACTER*1 00042 * = 'U': A is upper triangular; 00043 * = 'L': A is lower triangular. 00044 * 00045 * DIAG (input) CHARACTER*1 00046 * = 'N': A is non-unit triangular; 00047 * = 'U': A is unit triangular. 00048 * 00049 * N (input) INTEGER 00050 * The order of the matrix A. N >= 0. 00051 * 00052 * AP (input) REAL array, dimension (N*(N+1)/2) 00053 * The upper or lower triangular matrix A, packed columnwise in 00054 * a linear array. The j-th column of A is stored in the array 00055 * AP as follows: 00056 * if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; 00057 * if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n. 00058 * If DIAG = 'U', the diagonal elements of A are not referenced 00059 * and are assumed to be 1. 00060 * 00061 * RCOND (output) REAL 00062 * The reciprocal of the condition number of the matrix A, 00063 * computed as RCOND = 1/(norm(A) * norm(inv(A))). 00064 * 00065 * WORK (workspace) REAL array, dimension (3*N) 00066 * 00067 * IWORK (workspace) INTEGER array, dimension (N) 00068 * 00069 * INFO (output) INTEGER 00070 * = 0: successful exit 00071 * < 0: if INFO = -i, the i-th argument had an illegal value 00072 * 00073 * ===================================================================== 00074 * 00075 * .. Parameters .. 00076 REAL ONE, ZERO 00077 PARAMETER ( ONE = 1.0E+0, ZERO = 0.0E+0 ) 00078 * .. 00079 * .. Local Scalars .. 00080 LOGICAL NOUNIT, ONENRM, UPPER 00081 CHARACTER NORMIN 00082 INTEGER IX, KASE, KASE1 00083 REAL AINVNM, ANORM, SCALE, SMLNUM, XNORM 00084 * .. 00085 * .. Local Arrays .. 00086 INTEGER ISAVE( 3 ) 00087 * .. 00088 * .. External Functions .. 00089 LOGICAL LSAME 00090 INTEGER ISAMAX 00091 REAL SLAMCH, SLANTP 00092 EXTERNAL LSAME, ISAMAX, SLAMCH, SLANTP 00093 * .. 00094 * .. External Subroutines .. 00095 EXTERNAL SLACN2, SLATPS, SRSCL, XERBLA 00096 * .. 00097 * .. Intrinsic Functions .. 00098 INTRINSIC ABS, MAX, REAL 00099 * .. 00100 * .. Executable Statements .. 00101 * 00102 * Test the input parameters. 00103 * 00104 INFO = 0 00105 UPPER = LSAME( UPLO, 'U' ) 00106 ONENRM = NORM.EQ.'1' .OR. LSAME( NORM, 'O' ) 00107 NOUNIT = LSAME( DIAG, 'N' ) 00108 * 00109 IF( .NOT.ONENRM .AND. .NOT.LSAME( NORM, 'I' ) ) THEN 00110 INFO = -1 00111 ELSE IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN 00112 INFO = -2 00113 ELSE IF( .NOT.NOUNIT .AND. .NOT.LSAME( DIAG, 'U' ) ) THEN 00114 INFO = -3 00115 ELSE IF( N.LT.0 ) THEN 00116 INFO = -4 00117 END IF 00118 IF( INFO.NE.0 ) THEN 00119 CALL XERBLA( 'STPCON', -INFO ) 00120 RETURN 00121 END IF 00122 * 00123 * Quick return if possible 00124 * 00125 IF( N.EQ.0 ) THEN 00126 RCOND = ONE 00127 RETURN 00128 END IF 00129 * 00130 RCOND = ZERO 00131 SMLNUM = SLAMCH( 'Safe minimum' )*REAL( MAX( 1, N ) ) 00132 * 00133 * Compute the norm of the triangular matrix A. 00134 * 00135 ANORM = SLANTP( NORM, UPLO, DIAG, N, AP, WORK ) 00136 * 00137 * Continue only if ANORM > 0. 00138 * 00139 IF( ANORM.GT.ZERO ) THEN 00140 * 00141 * Estimate the norm of the inverse of A. 00142 * 00143 AINVNM = ZERO 00144 NORMIN = 'N' 00145 IF( ONENRM ) THEN 00146 KASE1 = 1 00147 ELSE 00148 KASE1 = 2 00149 END IF 00150 KASE = 0 00151 10 CONTINUE 00152 CALL SLACN2( N, WORK( N+1 ), WORK, IWORK, AINVNM, KASE, ISAVE ) 00153 IF( KASE.NE.0 ) THEN 00154 IF( KASE.EQ.KASE1 ) THEN 00155 * 00156 * Multiply by inv(A). 00157 * 00158 CALL SLATPS( UPLO, 'No transpose', DIAG, NORMIN, N, AP, 00159 $ WORK, SCALE, WORK( 2*N+1 ), INFO ) 00160 ELSE 00161 * 00162 * Multiply by inv(A**T). 00163 * 00164 CALL SLATPS( UPLO, 'Transpose', DIAG, NORMIN, N, AP, 00165 $ WORK, SCALE, WORK( 2*N+1 ), INFO ) 00166 END IF 00167 NORMIN = 'Y' 00168 * 00169 * Multiply by 1/SCALE if doing so will not cause overflow. 00170 * 00171 IF( SCALE.NE.ONE ) THEN 00172 IX = ISAMAX( N, WORK, 1 ) 00173 XNORM = ABS( WORK( IX ) ) 00174 IF( SCALE.LT.XNORM*SMLNUM .OR. SCALE.EQ.ZERO ) 00175 $ GO TO 20 00176 CALL SRSCL( N, SCALE, WORK, 1 ) 00177 END IF 00178 GO TO 10 00179 END IF 00180 * 00181 * Compute the estimate of the reciprocal condition number. 00182 * 00183 IF( AINVNM.NE.ZERO ) 00184 $ RCOND = ( ONE / ANORM ) / AINVNM 00185 END IF 00186 * 00187 20 CONTINUE 00188 RETURN 00189 * 00190 * End of STPCON 00191 * 00192 END