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