LAPACK 3.3.0
|
00001 SUBROUTINE CHPGVD( ITYPE, JOBZ, UPLO, N, AP, BP, W, Z, LDZ, WORK, 00002 $ LWORK, RWORK, LRWORK, IWORK, LIWORK, INFO ) 00003 * 00004 * -- LAPACK driver 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 * .. Scalar Arguments .. 00010 CHARACTER JOBZ, UPLO 00011 INTEGER INFO, ITYPE, LDZ, LIWORK, LRWORK, LWORK, N 00012 * .. 00013 * .. Array Arguments .. 00014 INTEGER IWORK( * ) 00015 REAL RWORK( * ), W( * ) 00016 COMPLEX AP( * ), BP( * ), WORK( * ), Z( LDZ, * ) 00017 * .. 00018 * 00019 * Purpose 00020 * ======= 00021 * 00022 * CHPGVD computes all the eigenvalues and, optionally, the eigenvectors 00023 * of a complex generalized Hermitian-definite eigenproblem, of the form 00024 * A*x=(lambda)*B*x, A*Bx=(lambda)*x, or B*A*x=(lambda)*x. Here A and 00025 * B are assumed to be Hermitian, stored in packed format, and B is also 00026 * positive definite. 00027 * If eigenvectors are desired, it uses a divide and conquer algorithm. 00028 * 00029 * The divide and conquer algorithm makes very mild assumptions about 00030 * floating point arithmetic. It will work on machines with a guard 00031 * digit in add/subtract, or on those binary machines without guard 00032 * digits which subtract like the Cray X-MP, Cray Y-MP, Cray C-90, or 00033 * Cray-2. It could conceivably fail on hexadecimal or decimal machines 00034 * without guard digits, but we know of none. 00035 * 00036 * Arguments 00037 * ========= 00038 * 00039 * ITYPE (input) INTEGER 00040 * Specifies the problem type to be solved: 00041 * = 1: A*x = (lambda)*B*x 00042 * = 2: A*B*x = (lambda)*x 00043 * = 3: B*A*x = (lambda)*x 00044 * 00045 * JOBZ (input) CHARACTER*1 00046 * = 'N': Compute eigenvalues only; 00047 * = 'V': Compute eigenvalues and eigenvectors. 00048 * 00049 * UPLO (input) CHARACTER*1 00050 * = 'U': Upper triangles of A and B are stored; 00051 * = 'L': Lower triangles of A and B are stored. 00052 * 00053 * N (input) INTEGER 00054 * The order of the matrices A and B. N >= 0. 00055 * 00056 * AP (input/output) COMPLEX array, dimension (N*(N+1)/2) 00057 * On entry, the upper or lower triangle of the Hermitian matrix 00058 * A, packed columnwise in a linear array. The j-th column of A 00059 * is stored in the array AP as follows: 00060 * if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; 00061 * if UPLO = 'L', AP(i + (j-1)*(2*n-j)/2) = A(i,j) for j<=i<=n. 00062 * 00063 * On exit, the contents of AP are destroyed. 00064 * 00065 * BP (input/output) COMPLEX array, dimension (N*(N+1)/2) 00066 * On entry, the upper or lower triangle of the Hermitian matrix 00067 * B, packed columnwise in a linear array. The j-th column of B 00068 * is stored in the array BP as follows: 00069 * if UPLO = 'U', BP(i + (j-1)*j/2) = B(i,j) for 1<=i<=j; 00070 * if UPLO = 'L', BP(i + (j-1)*(2*n-j)/2) = B(i,j) for j<=i<=n. 00071 * 00072 * On exit, the triangular factor U or L from the Cholesky 00073 * factorization B = U**H*U or B = L*L**H, in the same storage 00074 * format as B. 00075 * 00076 * W (output) REAL array, dimension (N) 00077 * If INFO = 0, the eigenvalues in ascending order. 00078 * 00079 * Z (output) COMPLEX array, dimension (LDZ, N) 00080 * If JOBZ = 'V', then if INFO = 0, Z contains the matrix Z of 00081 * eigenvectors. The eigenvectors are normalized as follows: 00082 * if ITYPE = 1 or 2, Z**H*B*Z = I; 00083 * if ITYPE = 3, Z**H*inv(B)*Z = I. 00084 * If JOBZ = 'N', then Z is not referenced. 00085 * 00086 * LDZ (input) INTEGER 00087 * The leading dimension of the array Z. LDZ >= 1, and if 00088 * JOBZ = 'V', LDZ >= max(1,N). 00089 * 00090 * WORK (workspace) COMPLEX array, dimension (MAX(1,LWORK)) 00091 * On exit, if INFO = 0, WORK(1) returns the required LWORK. 00092 * 00093 * LWORK (input) INTEGER 00094 * The dimension of array WORK. 00095 * If N <= 1, LWORK >= 1. 00096 * If JOBZ = 'N' and N > 1, LWORK >= N. 00097 * If JOBZ = 'V' and N > 1, LWORK >= 2*N. 00098 * 00099 * If LWORK = -1, then a workspace query is assumed; the routine 00100 * only calculates the required sizes of the WORK, RWORK and 00101 * IWORK arrays, returns these values as the first entries of 00102 * the WORK, RWORK and IWORK arrays, and no error message 00103 * related to LWORK or LRWORK or LIWORK is issued by XERBLA. 00104 * 00105 * RWORK (workspace) REAL array, dimension (MAX(1,LRWORK)) 00106 * On exit, if INFO = 0, RWORK(1) returns the required LRWORK. 00107 * 00108 * LRWORK (input) INTEGER 00109 * The dimension of array RWORK. 00110 * If N <= 1, LRWORK >= 1. 00111 * If JOBZ = 'N' and N > 1, LRWORK >= N. 00112 * If JOBZ = 'V' and N > 1, LRWORK >= 1 + 5*N + 2*N**2. 00113 * 00114 * If LRWORK = -1, then a workspace query is assumed; the 00115 * routine only calculates the required sizes of the WORK, RWORK 00116 * and IWORK arrays, returns these values as the first entries 00117 * of the WORK, RWORK and IWORK arrays, and no error message 00118 * related to LWORK or LRWORK or LIWORK is issued by XERBLA. 00119 * 00120 * IWORK (workspace/output) INTEGER array, dimension (MAX(1,LIWORK)) 00121 * On exit, if INFO = 0, IWORK(1) returns the required LIWORK. 00122 * 00123 * LIWORK (input) INTEGER 00124 * The dimension of array IWORK. 00125 * If JOBZ = 'N' or N <= 1, LIWORK >= 1. 00126 * If JOBZ = 'V' and N > 1, LIWORK >= 3 + 5*N. 00127 * 00128 * If LIWORK = -1, then a workspace query is assumed; the 00129 * routine only calculates the required sizes of the WORK, RWORK 00130 * and IWORK arrays, returns these values as the first entries 00131 * of the WORK, RWORK and IWORK arrays, and no error message 00132 * related to LWORK or LRWORK or LIWORK is issued by XERBLA. 00133 * 00134 * INFO (output) INTEGER 00135 * = 0: successful exit 00136 * < 0: if INFO = -i, the i-th argument had an illegal value 00137 * > 0: CPPTRF or CHPEVD returned an error code: 00138 * <= N: if INFO = i, CHPEVD failed to converge; 00139 * i off-diagonal elements of an intermediate 00140 * tridiagonal form did not convergeto zero; 00141 * > N: if INFO = N + i, for 1 <= i <= n, then the leading 00142 * minor of order i of B is not positive definite. 00143 * The factorization of B could not be completed and 00144 * no eigenvalues or eigenvectors were computed. 00145 * 00146 * Further Details 00147 * =============== 00148 * 00149 * Based on contributions by 00150 * Mark Fahey, Department of Mathematics, Univ. of Kentucky, USA 00151 * 00152 * ===================================================================== 00153 * 00154 * .. Local Scalars .. 00155 LOGICAL LQUERY, UPPER, WANTZ 00156 CHARACTER TRANS 00157 INTEGER J, LIWMIN, LRWMIN, LWMIN, NEIG 00158 * .. 00159 * .. External Functions .. 00160 LOGICAL LSAME 00161 EXTERNAL LSAME 00162 * .. 00163 * .. External Subroutines .. 00164 EXTERNAL CHPEVD, CHPGST, CPPTRF, CTPMV, CTPSV, XERBLA 00165 * .. 00166 * .. Intrinsic Functions .. 00167 INTRINSIC MAX, REAL 00168 * .. 00169 * .. Executable Statements .. 00170 * 00171 * Test the input parameters. 00172 * 00173 WANTZ = LSAME( JOBZ, 'V' ) 00174 UPPER = LSAME( UPLO, 'U' ) 00175 LQUERY = ( LWORK.EQ.-1 .OR. LRWORK.EQ.-1 .OR. LIWORK.EQ.-1 ) 00176 * 00177 INFO = 0 00178 IF( ITYPE.LT.1 .OR. ITYPE.GT.3 ) THEN 00179 INFO = -1 00180 ELSE IF( .NOT.( WANTZ .OR. LSAME( JOBZ, 'N' ) ) ) THEN 00181 INFO = -2 00182 ELSE IF( .NOT.( UPPER .OR. LSAME( UPLO, 'L' ) ) ) THEN 00183 INFO = -3 00184 ELSE IF( N.LT.0 ) THEN 00185 INFO = -4 00186 ELSE IF( LDZ.LT.1 .OR. ( WANTZ .AND. LDZ.LT.N ) ) THEN 00187 INFO = -9 00188 END IF 00189 * 00190 IF( INFO.EQ.0 ) THEN 00191 IF( N.LE.1 ) THEN 00192 LWMIN = 1 00193 LIWMIN = 1 00194 LRWMIN = 1 00195 ELSE 00196 IF( WANTZ ) THEN 00197 LWMIN = 2*N 00198 LRWMIN = 1 + 5*N + 2*N**2 00199 LIWMIN = 3 + 5*N 00200 ELSE 00201 LWMIN = N 00202 LRWMIN = N 00203 LIWMIN = 1 00204 END IF 00205 END IF 00206 WORK( 1 ) = LWMIN 00207 RWORK( 1 ) = LRWMIN 00208 IWORK( 1 ) = LIWMIN 00209 * 00210 IF( LWORK.LT.LWMIN .AND. .NOT.LQUERY ) THEN 00211 INFO = -11 00212 ELSE IF( LRWORK.LT.LRWMIN .AND. .NOT.LQUERY ) THEN 00213 INFO = -13 00214 ELSE IF( LIWORK.LT.LIWMIN .AND. .NOT.LQUERY ) THEN 00215 INFO = -15 00216 END IF 00217 END IF 00218 * 00219 IF( INFO.NE.0 ) THEN 00220 CALL XERBLA( 'CHPGVD', -INFO ) 00221 RETURN 00222 ELSE IF( LQUERY ) THEN 00223 RETURN 00224 END IF 00225 * 00226 * Quick return if possible 00227 * 00228 IF( N.EQ.0 ) 00229 $ RETURN 00230 * 00231 * Form a Cholesky factorization of B. 00232 * 00233 CALL CPPTRF( UPLO, N, BP, INFO ) 00234 IF( INFO.NE.0 ) THEN 00235 INFO = N + INFO 00236 RETURN 00237 END IF 00238 * 00239 * Transform problem to standard eigenvalue problem and solve. 00240 * 00241 CALL CHPGST( ITYPE, UPLO, N, AP, BP, INFO ) 00242 CALL CHPEVD( JOBZ, UPLO, N, AP, W, Z, LDZ, WORK, LWORK, RWORK, 00243 $ LRWORK, IWORK, LIWORK, INFO ) 00244 LWMIN = MAX( REAL( LWMIN ), REAL( WORK( 1 ) ) ) 00245 LRWMIN = MAX( REAL( LRWMIN ), REAL( RWORK( 1 ) ) ) 00246 LIWMIN = MAX( REAL( LIWMIN ), REAL( IWORK( 1 ) ) ) 00247 * 00248 IF( WANTZ ) THEN 00249 * 00250 * Backtransform eigenvectors to the original problem. 00251 * 00252 NEIG = N 00253 IF( INFO.GT.0 ) 00254 $ NEIG = INFO - 1 00255 IF( ITYPE.EQ.1 .OR. ITYPE.EQ.2 ) THEN 00256 * 00257 * For A*x=(lambda)*B*x and A*B*x=(lambda)*x; 00258 * backtransform eigenvectors: x = inv(L)'*y or inv(U)*y 00259 * 00260 IF( UPPER ) THEN 00261 TRANS = 'N' 00262 ELSE 00263 TRANS = 'C' 00264 END IF 00265 * 00266 DO 10 J = 1, NEIG 00267 CALL CTPSV( UPLO, TRANS, 'Non-unit', N, BP, Z( 1, J ), 00268 $ 1 ) 00269 10 CONTINUE 00270 * 00271 ELSE IF( ITYPE.EQ.3 ) THEN 00272 * 00273 * For B*A*x=(lambda)*x; 00274 * backtransform eigenvectors: x = L*y or U'*y 00275 * 00276 IF( UPPER ) THEN 00277 TRANS = 'C' 00278 ELSE 00279 TRANS = 'N' 00280 END IF 00281 * 00282 DO 20 J = 1, NEIG 00283 CALL CTPMV( UPLO, TRANS, 'Non-unit', N, BP, Z( 1, J ), 00284 $ 1 ) 00285 20 CONTINUE 00286 END IF 00287 END IF 00288 * 00289 WORK( 1 ) = LWMIN 00290 RWORK( 1 ) = LRWMIN 00291 IWORK( 1 ) = LIWMIN 00292 RETURN 00293 * 00294 * End of CHPGVD 00295 * 00296 END