LAPACK 3.3.0
|
00001 SUBROUTINE SSYGVX( ITYPE, JOBZ, RANGE, UPLO, N, A, LDA, B, LDB, 00002 $ VL, VU, IL, IU, ABSTOL, M, W, Z, LDZ, WORK, 00003 $ LWORK, IWORK, IFAIL, INFO ) 00004 * 00005 * -- LAPACK driver routine (version 3.2) -- 00006 * -- LAPACK is a software package provided by Univ. of Tennessee, -- 00007 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- 00008 * November 2006 00009 * 00010 * .. Scalar Arguments .. 00011 CHARACTER JOBZ, RANGE, UPLO 00012 INTEGER IL, INFO, ITYPE, IU, LDA, LDB, LDZ, LWORK, M, N 00013 REAL ABSTOL, VL, VU 00014 * .. 00015 * .. Array Arguments .. 00016 INTEGER IFAIL( * ), IWORK( * ) 00017 REAL A( LDA, * ), B( LDB, * ), W( * ), WORK( * ), 00018 $ Z( LDZ, * ) 00019 * .. 00020 * 00021 * Purpose 00022 * ======= 00023 * 00024 * SSYGVX computes selected eigenvalues, and optionally, eigenvectors 00025 * of a real generalized symmetric-definite eigenproblem, of the form 00026 * A*x=(lambda)*B*x, A*Bx=(lambda)*x, or B*A*x=(lambda)*x. Here A 00027 * and B are assumed to be symmetric and B is also positive definite. 00028 * Eigenvalues and eigenvectors can be selected by specifying either a 00029 * range of values or a range of indices for the desired eigenvalues. 00030 * 00031 * Arguments 00032 * ========= 00033 * 00034 * ITYPE (input) INTEGER 00035 * Specifies the problem type to be solved: 00036 * = 1: A*x = (lambda)*B*x 00037 * = 2: A*B*x = (lambda)*x 00038 * = 3: B*A*x = (lambda)*x 00039 * 00040 * JOBZ (input) CHARACTER*1 00041 * = 'N': Compute eigenvalues only; 00042 * = 'V': Compute eigenvalues and eigenvectors. 00043 * 00044 * RANGE (input) CHARACTER*1 00045 * = 'A': all eigenvalues will be found. 00046 * = 'V': all eigenvalues in the half-open interval (VL,VU] 00047 * will be found. 00048 * = 'I': the IL-th through IU-th eigenvalues will be found. 00049 * 00050 * UPLO (input) CHARACTER*1 00051 * = 'U': Upper triangle of A and B are stored; 00052 * = 'L': Lower triangle of A and B are stored. 00053 * 00054 * N (input) INTEGER 00055 * The order of the matrix pencil (A,B). N >= 0. 00056 * 00057 * A (input/output) REAL array, dimension (LDA, N) 00058 * On entry, the symmetric matrix A. If UPLO = 'U', the 00059 * leading N-by-N upper triangular part of A contains the 00060 * upper triangular part of the matrix A. If UPLO = 'L', 00061 * the leading N-by-N lower triangular part of A contains 00062 * the lower triangular part of the matrix A. 00063 * 00064 * On exit, the lower triangle (if UPLO='L') or the upper 00065 * triangle (if UPLO='U') of A, including the diagonal, is 00066 * destroyed. 00067 * 00068 * LDA (input) INTEGER 00069 * The leading dimension of the array A. LDA >= max(1,N). 00070 * 00071 * B (input/output) REAL array, dimension (LDA, N) 00072 * On entry, the symmetric matrix B. If UPLO = 'U', the 00073 * leading N-by-N upper triangular part of B contains the 00074 * upper triangular part of the matrix B. If UPLO = 'L', 00075 * the leading N-by-N lower triangular part of B contains 00076 * the lower triangular part of the matrix B. 00077 * 00078 * On exit, if INFO <= N, the part of B containing the matrix is 00079 * overwritten by the triangular factor U or L from the Cholesky 00080 * factorization B = U**T*U or B = L*L**T. 00081 * 00082 * LDB (input) INTEGER 00083 * The leading dimension of the array B. LDB >= max(1,N). 00084 * 00085 * VL (input) REAL 00086 * VU (input) REAL 00087 * If RANGE='V', the lower and upper bounds of the interval to 00088 * be searched for eigenvalues. VL < VU. 00089 * Not referenced if RANGE = 'A' or 'I'. 00090 * 00091 * IL (input) INTEGER 00092 * IU (input) INTEGER 00093 * If RANGE='I', the indices (in ascending order) of the 00094 * smallest and largest eigenvalues to be returned. 00095 * 1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0. 00096 * Not referenced if RANGE = 'A' or 'V'. 00097 * 00098 * ABSTOL (input) REAL 00099 * The absolute error tolerance for the eigenvalues. 00100 * An approximate eigenvalue is accepted as converged 00101 * when it is determined to lie in an interval [a,b] 00102 * of width less than or equal to 00103 * 00104 * ABSTOL + EPS * max( |a|,|b| ) , 00105 * 00106 * where EPS is the machine precision. If ABSTOL is less than 00107 * or equal to zero, then EPS*|T| will be used in its place, 00108 * where |T| is the 1-norm of the tridiagonal matrix obtained 00109 * by reducing A to tridiagonal form. 00110 * 00111 * Eigenvalues will be computed most accurately when ABSTOL is 00112 * set to twice the underflow threshold 2*DLAMCH('S'), not zero. 00113 * If this routine returns with INFO>0, indicating that some 00114 * eigenvectors did not converge, try setting ABSTOL to 00115 * 2*SLAMCH('S'). 00116 * 00117 * M (output) INTEGER 00118 * The total number of eigenvalues found. 0 <= M <= N. 00119 * If RANGE = 'A', M = N, and if RANGE = 'I', M = IU-IL+1. 00120 * 00121 * W (output) REAL array, dimension (N) 00122 * On normal exit, the first M elements contain the selected 00123 * eigenvalues in ascending order. 00124 * 00125 * Z (output) REAL array, dimension (LDZ, max(1,M)) 00126 * If JOBZ = 'N', then Z is not referenced. 00127 * If JOBZ = 'V', then if INFO = 0, the first M columns of Z 00128 * contain the orthonormal eigenvectors of the matrix A 00129 * corresponding to the selected eigenvalues, with the i-th 00130 * column of Z holding the eigenvector associated with W(i). 00131 * The eigenvectors are normalized as follows: 00132 * if ITYPE = 1 or 2, Z**T*B*Z = I; 00133 * if ITYPE = 3, Z**T*inv(B)*Z = I. 00134 * 00135 * If an eigenvector fails to converge, then that column of Z 00136 * contains the latest approximation to the eigenvector, and the 00137 * index of the eigenvector is returned in IFAIL. 00138 * Note: the user must ensure that at least max(1,M) columns are 00139 * supplied in the array Z; if RANGE = 'V', the exact value of M 00140 * is not known in advance and an upper bound must be used. 00141 * 00142 * LDZ (input) INTEGER 00143 * The leading dimension of the array Z. LDZ >= 1, and if 00144 * JOBZ = 'V', LDZ >= max(1,N). 00145 * 00146 * WORK (workspace/output) REAL array, dimension (MAX(1,LWORK)) 00147 * On exit, if INFO = 0, WORK(1) returns the optimal LWORK. 00148 * 00149 * LWORK (input) INTEGER 00150 * The length of the array WORK. LWORK >= max(1,8*N). 00151 * For optimal efficiency, LWORK >= (NB+3)*N, 00152 * where NB is the blocksize for SSYTRD returned by ILAENV. 00153 * 00154 * If LWORK = -1, then a workspace query is assumed; the routine 00155 * only calculates the optimal size of the WORK array, returns 00156 * this value as the first entry of the WORK array, and no error 00157 * message related to LWORK is issued by XERBLA. 00158 * 00159 * IWORK (workspace) INTEGER array, dimension (5*N) 00160 * 00161 * IFAIL (output) INTEGER array, dimension (N) 00162 * If JOBZ = 'V', then if INFO = 0, the first M elements of 00163 * IFAIL are zero. If INFO > 0, then IFAIL contains the 00164 * indices of the eigenvectors that failed to converge. 00165 * If JOBZ = 'N', then IFAIL is not referenced. 00166 * 00167 * INFO (output) INTEGER 00168 * = 0: successful exit 00169 * < 0: if INFO = -i, the i-th argument had an illegal value 00170 * > 0: SPOTRF or SSYEVX returned an error code: 00171 * <= N: if INFO = i, SSYEVX failed to converge; 00172 * i eigenvectors failed to converge. Their indices 00173 * are stored in array IFAIL. 00174 * > N: if INFO = N + i, for 1 <= i <= N, then the leading 00175 * minor of order i of B is not positive definite. 00176 * The factorization of B could not be completed and 00177 * no eigenvalues or eigenvectors were computed. 00178 * 00179 * Further Details 00180 * =============== 00181 * 00182 * Based on contributions by 00183 * Mark Fahey, Department of Mathematics, Univ. of Kentucky, USA 00184 * 00185 * ===================================================================== 00186 * 00187 * .. Parameters .. 00188 REAL ONE 00189 PARAMETER ( ONE = 1.0E+0 ) 00190 * .. 00191 * .. Local Scalars .. 00192 LOGICAL ALLEIG, INDEIG, LQUERY, UPPER, VALEIG, WANTZ 00193 CHARACTER TRANS 00194 INTEGER LWKMIN, LWKOPT, NB 00195 * .. 00196 * .. External Functions .. 00197 LOGICAL LSAME 00198 INTEGER ILAENV 00199 EXTERNAL ILAENV, LSAME 00200 * .. 00201 * .. External Subroutines .. 00202 EXTERNAL SPOTRF, SSYEVX, SSYGST, STRMM, STRSM, XERBLA 00203 * .. 00204 * .. Intrinsic Functions .. 00205 INTRINSIC MAX, MIN 00206 * .. 00207 * .. Executable Statements .. 00208 * 00209 * Test the input parameters. 00210 * 00211 UPPER = LSAME( UPLO, 'U' ) 00212 WANTZ = LSAME( JOBZ, 'V' ) 00213 ALLEIG = LSAME( RANGE, 'A' ) 00214 VALEIG = LSAME( RANGE, 'V' ) 00215 INDEIG = LSAME( RANGE, 'I' ) 00216 LQUERY = ( LWORK.EQ.-1 ) 00217 * 00218 INFO = 0 00219 IF( ITYPE.LT.1 .OR. ITYPE.GT.3 ) THEN 00220 INFO = -1 00221 ELSE IF( .NOT.( WANTZ .OR. LSAME( JOBZ, 'N' ) ) ) THEN 00222 INFO = -2 00223 ELSE IF( .NOT.( ALLEIG .OR. VALEIG .OR. INDEIG ) ) THEN 00224 INFO = -3 00225 ELSE IF( .NOT.( UPPER .OR. LSAME( UPLO, 'L' ) ) ) THEN 00226 INFO = -4 00227 ELSE IF( N.LT.0 ) THEN 00228 INFO = -5 00229 ELSE IF( LDA.LT.MAX( 1, N ) ) THEN 00230 INFO = -7 00231 ELSE IF( LDB.LT.MAX( 1, N ) ) THEN 00232 INFO = -9 00233 ELSE 00234 IF( VALEIG ) THEN 00235 IF( N.GT.0 .AND. VU.LE.VL ) 00236 $ INFO = -11 00237 ELSE IF( INDEIG ) THEN 00238 IF( IL.LT.1 .OR. IL.GT.MAX( 1, N ) ) THEN 00239 INFO = -12 00240 ELSE IF( IU.LT.MIN( N, IL ) .OR. IU.GT.N ) THEN 00241 INFO = -13 00242 END IF 00243 END IF 00244 END IF 00245 IF (INFO.EQ.0) THEN 00246 IF (LDZ.LT.1 .OR. (WANTZ .AND. LDZ.LT.N)) THEN 00247 INFO = -18 00248 END IF 00249 END IF 00250 * 00251 IF( INFO.EQ.0 ) THEN 00252 LWKMIN = MAX( 1, 8*N ) 00253 NB = ILAENV( 1, 'SSYTRD', UPLO, N, -1, -1, -1 ) 00254 LWKOPT = MAX( LWKMIN, ( NB + 3 )*N ) 00255 WORK( 1 ) = LWKOPT 00256 * 00257 IF( LWORK.LT.LWKMIN .AND. .NOT.LQUERY ) THEN 00258 INFO = -20 00259 END IF 00260 END IF 00261 * 00262 IF( INFO.NE.0 ) THEN 00263 CALL XERBLA( 'SSYGVX', -INFO ) 00264 RETURN 00265 ELSE IF( LQUERY ) THEN 00266 RETURN 00267 END IF 00268 * 00269 * Quick return if possible 00270 * 00271 M = 0 00272 IF( N.EQ.0 ) THEN 00273 RETURN 00274 END IF 00275 * 00276 * Form a Cholesky factorization of B. 00277 * 00278 CALL SPOTRF( UPLO, N, B, LDB, INFO ) 00279 IF( INFO.NE.0 ) THEN 00280 INFO = N + INFO 00281 RETURN 00282 END IF 00283 * 00284 * Transform problem to standard eigenvalue problem and solve. 00285 * 00286 CALL SSYGST( ITYPE, UPLO, N, A, LDA, B, LDB, INFO ) 00287 CALL SSYEVX( JOBZ, RANGE, UPLO, N, A, LDA, VL, VU, IL, IU, ABSTOL, 00288 $ M, W, Z, LDZ, WORK, LWORK, IWORK, IFAIL, INFO ) 00289 * 00290 IF( WANTZ ) THEN 00291 * 00292 * Backtransform eigenvectors to the original problem. 00293 * 00294 IF( INFO.GT.0 ) 00295 $ M = INFO - 1 00296 IF( ITYPE.EQ.1 .OR. ITYPE.EQ.2 ) THEN 00297 * 00298 * For A*x=(lambda)*B*x and A*B*x=(lambda)*x; 00299 * backtransform eigenvectors: x = inv(L)'*y or inv(U)*y 00300 * 00301 IF( UPPER ) THEN 00302 TRANS = 'N' 00303 ELSE 00304 TRANS = 'T' 00305 END IF 00306 * 00307 CALL STRSM( 'Left', UPLO, TRANS, 'Non-unit', N, M, ONE, B, 00308 $ LDB, Z, LDZ ) 00309 * 00310 ELSE IF( ITYPE.EQ.3 ) THEN 00311 * 00312 * For B*A*x=(lambda)*x; 00313 * backtransform eigenvectors: x = L*y or U'*y 00314 * 00315 IF( UPPER ) THEN 00316 TRANS = 'T' 00317 ELSE 00318 TRANS = 'N' 00319 END IF 00320 * 00321 CALL STRMM( 'Left', UPLO, TRANS, 'Non-unit', N, M, ONE, B, 00322 $ LDB, Z, LDZ ) 00323 END IF 00324 END IF 00325 * 00326 * Set WORK(1) to optimal workspace size. 00327 * 00328 WORK( 1 ) = LWKOPT 00329 * 00330 RETURN 00331 * 00332 * End of SSYGVX 00333 * 00334 END