![]() |
LAPACK
3.4.1
LAPACK: Linear Algebra PACKage
|
00001 *> \brief \b ZHPGST 00002 * 00003 * =========== DOCUMENTATION =========== 00004 * 00005 * Online html documentation available at 00006 * http://www.netlib.org/lapack/explore-html/ 00007 * 00008 *> \htmlonly 00009 *> Download ZHPGVD + dependencies 00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zhpgvd.f"> 00011 *> [TGZ]</a> 00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zhpgvd.f"> 00013 *> [ZIP]</a> 00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zhpgvd.f"> 00015 *> [TXT]</a> 00016 *> \endhtmlonly 00017 * 00018 * Definition: 00019 * =========== 00020 * 00021 * SUBROUTINE ZHPGVD( ITYPE, JOBZ, UPLO, N, AP, BP, W, Z, LDZ, WORK, 00022 * LWORK, RWORK, LRWORK, IWORK, LIWORK, INFO ) 00023 * 00024 * .. Scalar Arguments .. 00025 * CHARACTER JOBZ, UPLO 00026 * INTEGER INFO, ITYPE, LDZ, LIWORK, LRWORK, LWORK, N 00027 * .. 00028 * .. Array Arguments .. 00029 * INTEGER IWORK( * ) 00030 * DOUBLE PRECISION RWORK( * ), W( * ) 00031 * COMPLEX*16 AP( * ), BP( * ), WORK( * ), Z( LDZ, * ) 00032 * .. 00033 * 00034 * 00035 *> \par Purpose: 00036 * ============= 00037 *> 00038 *> \verbatim 00039 *> 00040 *> ZHPGVD computes all the eigenvalues and, optionally, the eigenvectors 00041 *> of a complex generalized Hermitian-definite eigenproblem, of the form 00042 *> A*x=(lambda)*B*x, A*Bx=(lambda)*x, or B*A*x=(lambda)*x. Here A and 00043 *> B are assumed to be Hermitian, stored in packed format, and B is also 00044 *> positive definite. 00045 *> If eigenvectors are desired, it uses a divide and conquer algorithm. 00046 *> 00047 *> The divide and conquer algorithm makes very mild assumptions about 00048 *> floating point arithmetic. It will work on machines with a guard 00049 *> digit in add/subtract, or on those binary machines without guard 00050 *> digits which subtract like the Cray X-MP, Cray Y-MP, Cray C-90, or 00051 *> Cray-2. It could conceivably fail on hexadecimal or decimal machines 00052 *> without guard digits, but we know of none. 00053 *> \endverbatim 00054 * 00055 * Arguments: 00056 * ========== 00057 * 00058 *> \param[in] ITYPE 00059 *> \verbatim 00060 *> ITYPE is INTEGER 00061 *> Specifies the problem type to be solved: 00062 *> = 1: A*x = (lambda)*B*x 00063 *> = 2: A*B*x = (lambda)*x 00064 *> = 3: B*A*x = (lambda)*x 00065 *> \endverbatim 00066 *> 00067 *> \param[in] JOBZ 00068 *> \verbatim 00069 *> JOBZ is CHARACTER*1 00070 *> = 'N': Compute eigenvalues only; 00071 *> = 'V': Compute eigenvalues and eigenvectors. 00072 *> \endverbatim 00073 *> 00074 *> \param[in] UPLO 00075 *> \verbatim 00076 *> UPLO is CHARACTER*1 00077 *> = 'U': Upper triangles of A and B are stored; 00078 *> = 'L': Lower triangles of A and B are stored. 00079 *> \endverbatim 00080 *> 00081 *> \param[in] N 00082 *> \verbatim 00083 *> N is INTEGER 00084 *> The order of the matrices A and B. N >= 0. 00085 *> \endverbatim 00086 *> 00087 *> \param[in,out] AP 00088 *> \verbatim 00089 *> AP is COMPLEX*16 array, dimension (N*(N+1)/2) 00090 *> On entry, the upper or lower triangle of the Hermitian matrix 00091 *> A, packed columnwise in a linear array. The j-th column of A 00092 *> is stored in the array AP as follows: 00093 *> if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; 00094 *> if UPLO = 'L', AP(i + (j-1)*(2*n-j)/2) = A(i,j) for j<=i<=n. 00095 *> 00096 *> On exit, the contents of AP are destroyed. 00097 *> \endverbatim 00098 *> 00099 *> \param[in,out] BP 00100 *> \verbatim 00101 *> BP is COMPLEX*16 array, dimension (N*(N+1)/2) 00102 *> On entry, the upper or lower triangle of the Hermitian matrix 00103 *> B, packed columnwise in a linear array. The j-th column of B 00104 *> is stored in the array BP as follows: 00105 *> if UPLO = 'U', BP(i + (j-1)*j/2) = B(i,j) for 1<=i<=j; 00106 *> if UPLO = 'L', BP(i + (j-1)*(2*n-j)/2) = B(i,j) for j<=i<=n. 00107 *> 00108 *> On exit, the triangular factor U or L from the Cholesky 00109 *> factorization B = U**H*U or B = L*L**H, in the same storage 00110 *> format as B. 00111 *> \endverbatim 00112 *> 00113 *> \param[out] W 00114 *> \verbatim 00115 *> W is DOUBLE PRECISION array, dimension (N) 00116 *> If INFO = 0, the eigenvalues in ascending order. 00117 *> \endverbatim 00118 *> 00119 *> \param[out] Z 00120 *> \verbatim 00121 *> Z is COMPLEX*16 array, dimension (LDZ, N) 00122 *> If JOBZ = 'V', then if INFO = 0, Z contains the matrix Z of 00123 *> eigenvectors. The eigenvectors are normalized as follows: 00124 *> if ITYPE = 1 or 2, Z**H*B*Z = I; 00125 *> if ITYPE = 3, Z**H*inv(B)*Z = I. 00126 *> If JOBZ = 'N', then Z is not referenced. 00127 *> \endverbatim 00128 *> 00129 *> \param[in] LDZ 00130 *> \verbatim 00131 *> LDZ is INTEGER 00132 *> The leading dimension of the array Z. LDZ >= 1, and if 00133 *> JOBZ = 'V', LDZ >= max(1,N). 00134 *> \endverbatim 00135 *> 00136 *> \param[out] WORK 00137 *> \verbatim 00138 *> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK)) 00139 *> On exit, if INFO = 0, WORK(1) returns the required LWORK. 00140 *> \endverbatim 00141 *> 00142 *> \param[in] LWORK 00143 *> \verbatim 00144 *> LWORK is INTEGER 00145 *> The dimension of the array WORK. 00146 *> If N <= 1, LWORK >= 1. 00147 *> If JOBZ = 'N' and N > 1, LWORK >= N. 00148 *> If JOBZ = 'V' and N > 1, LWORK >= 2*N. 00149 *> 00150 *> If LWORK = -1, then a workspace query is assumed; the routine 00151 *> only calculates the required sizes of the WORK, RWORK and 00152 *> IWORK arrays, returns these values as the first entries of 00153 *> the WORK, RWORK and IWORK arrays, and no error message 00154 *> related to LWORK or LRWORK or LIWORK is issued by XERBLA. 00155 *> \endverbatim 00156 *> 00157 *> \param[out] RWORK 00158 *> \verbatim 00159 *> RWORK is DOUBLE PRECISION array, dimension (MAX(1,LRWORK)) 00160 *> On exit, if INFO = 0, RWORK(1) returns the required LRWORK. 00161 *> \endverbatim 00162 *> 00163 *> \param[in] LRWORK 00164 *> \verbatim 00165 *> LRWORK is INTEGER 00166 *> The dimension of array RWORK. 00167 *> If N <= 1, LRWORK >= 1. 00168 *> If JOBZ = 'N' and N > 1, LRWORK >= N. 00169 *> If JOBZ = 'V' and N > 1, LRWORK >= 1 + 5*N + 2*N**2. 00170 *> 00171 *> If LRWORK = -1, then a workspace query is assumed; the 00172 *> routine only calculates the required sizes of the WORK, RWORK 00173 *> and IWORK arrays, returns these values as the first entries 00174 *> of the WORK, RWORK and IWORK arrays, and no error message 00175 *> related to LWORK or LRWORK or LIWORK is issued by XERBLA. 00176 *> \endverbatim 00177 *> 00178 *> \param[out] IWORK 00179 *> \verbatim 00180 *> IWORK is INTEGER array, dimension (MAX(1,LIWORK)) 00181 *> On exit, if INFO = 0, IWORK(1) returns the required LIWORK. 00182 *> \endverbatim 00183 *> 00184 *> \param[in] LIWORK 00185 *> \verbatim 00186 *> LIWORK is INTEGER 00187 *> The dimension of array IWORK. 00188 *> If JOBZ = 'N' or N <= 1, LIWORK >= 1. 00189 *> If JOBZ = 'V' and N > 1, LIWORK >= 3 + 5*N. 00190 *> 00191 *> If LIWORK = -1, then a workspace query is assumed; the 00192 *> routine only calculates the required sizes of the WORK, RWORK 00193 *> and IWORK arrays, returns these values as the first entries 00194 *> of the WORK, RWORK and IWORK arrays, and no error message 00195 *> related to LWORK or LRWORK or LIWORK is issued by XERBLA. 00196 *> \endverbatim 00197 *> 00198 *> \param[out] INFO 00199 *> \verbatim 00200 *> INFO is INTEGER 00201 *> = 0: successful exit 00202 *> < 0: if INFO = -i, the i-th argument had an illegal value 00203 *> > 0: ZPPTRF or ZHPEVD returned an error code: 00204 *> <= N: if INFO = i, ZHPEVD failed to converge; 00205 *> i off-diagonal elements of an intermediate 00206 *> tridiagonal form did not convergeto zero; 00207 *> > N: if INFO = N + i, for 1 <= i <= n, then the leading 00208 *> minor of order i of B is not positive definite. 00209 *> The factorization of B could not be completed and 00210 *> no eigenvalues or eigenvectors were computed. 00211 *> \endverbatim 00212 * 00213 * Authors: 00214 * ======== 00215 * 00216 *> \author Univ. of Tennessee 00217 *> \author Univ. of California Berkeley 00218 *> \author Univ. of Colorado Denver 00219 *> \author NAG Ltd. 00220 * 00221 *> \date November 2011 00222 * 00223 *> \ingroup complex16OTHEReigen 00224 * 00225 *> \par Contributors: 00226 * ================== 00227 *> 00228 *> Mark Fahey, Department of Mathematics, Univ. of Kentucky, USA 00229 * 00230 * ===================================================================== 00231 SUBROUTINE ZHPGVD( ITYPE, JOBZ, UPLO, N, AP, BP, W, Z, LDZ, WORK, 00232 $ LWORK, RWORK, LRWORK, IWORK, LIWORK, INFO ) 00233 * 00234 * -- LAPACK driver routine (version 3.4.0) -- 00235 * -- LAPACK is a software package provided by Univ. of Tennessee, -- 00236 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- 00237 * November 2011 00238 * 00239 * .. Scalar Arguments .. 00240 CHARACTER JOBZ, UPLO 00241 INTEGER INFO, ITYPE, LDZ, LIWORK, LRWORK, LWORK, N 00242 * .. 00243 * .. Array Arguments .. 00244 INTEGER IWORK( * ) 00245 DOUBLE PRECISION RWORK( * ), W( * ) 00246 COMPLEX*16 AP( * ), BP( * ), WORK( * ), Z( LDZ, * ) 00247 * .. 00248 * 00249 * ===================================================================== 00250 * 00251 * .. Local Scalars .. 00252 LOGICAL LQUERY, UPPER, WANTZ 00253 CHARACTER TRANS 00254 INTEGER J, LIWMIN, LRWMIN, LWMIN, NEIG 00255 * .. 00256 * .. External Functions .. 00257 LOGICAL LSAME 00258 EXTERNAL LSAME 00259 * .. 00260 * .. External Subroutines .. 00261 EXTERNAL XERBLA, ZHPEVD, ZHPGST, ZPPTRF, ZTPMV, ZTPSV 00262 * .. 00263 * .. Intrinsic Functions .. 00264 INTRINSIC DBLE, MAX 00265 * .. 00266 * .. Executable Statements .. 00267 * 00268 * Test the input parameters. 00269 * 00270 WANTZ = LSAME( JOBZ, 'V' ) 00271 UPPER = LSAME( UPLO, 'U' ) 00272 LQUERY = ( LWORK.EQ.-1 .OR. LRWORK.EQ.-1 .OR. LIWORK.EQ.-1 ) 00273 * 00274 INFO = 0 00275 IF( ITYPE.LT.1 .OR. ITYPE.GT.3 ) THEN 00276 INFO = -1 00277 ELSE IF( .NOT.( WANTZ .OR. LSAME( JOBZ, 'N' ) ) ) THEN 00278 INFO = -2 00279 ELSE IF( .NOT.( UPPER .OR. LSAME( UPLO, 'L' ) ) ) THEN 00280 INFO = -3 00281 ELSE IF( N.LT.0 ) THEN 00282 INFO = -4 00283 ELSE IF( LDZ.LT.1 .OR. ( WANTZ .AND. LDZ.LT.N ) ) THEN 00284 INFO = -9 00285 END IF 00286 * 00287 IF( INFO.EQ.0 ) THEN 00288 IF( N.LE.1 ) THEN 00289 LWMIN = 1 00290 LIWMIN = 1 00291 LRWMIN = 1 00292 ELSE 00293 IF( WANTZ ) THEN 00294 LWMIN = 2*N 00295 LRWMIN = 1 + 5*N + 2*N**2 00296 LIWMIN = 3 + 5*N 00297 ELSE 00298 LWMIN = N 00299 LRWMIN = N 00300 LIWMIN = 1 00301 END IF 00302 END IF 00303 * 00304 WORK( 1 ) = LWMIN 00305 RWORK( 1 ) = LRWMIN 00306 IWORK( 1 ) = LIWMIN 00307 IF( LWORK.LT.LWMIN .AND. .NOT.LQUERY ) THEN 00308 INFO = -11 00309 ELSE IF( LRWORK.LT.LRWMIN .AND. .NOT.LQUERY ) THEN 00310 INFO = -13 00311 ELSE IF( LIWORK.LT.LIWMIN .AND. .NOT.LQUERY ) THEN 00312 INFO = -15 00313 END IF 00314 END IF 00315 * 00316 IF( INFO.NE.0 ) THEN 00317 CALL XERBLA( 'ZHPGVD', -INFO ) 00318 RETURN 00319 ELSE IF( LQUERY ) THEN 00320 RETURN 00321 END IF 00322 * 00323 * Quick return if possible 00324 * 00325 IF( N.EQ.0 ) 00326 $ RETURN 00327 * 00328 * Form a Cholesky factorization of B. 00329 * 00330 CALL ZPPTRF( UPLO, N, BP, INFO ) 00331 IF( INFO.NE.0 ) THEN 00332 INFO = N + INFO 00333 RETURN 00334 END IF 00335 * 00336 * Transform problem to standard eigenvalue problem and solve. 00337 * 00338 CALL ZHPGST( ITYPE, UPLO, N, AP, BP, INFO ) 00339 CALL ZHPEVD( JOBZ, UPLO, N, AP, W, Z, LDZ, WORK, LWORK, RWORK, 00340 $ LRWORK, IWORK, LIWORK, INFO ) 00341 LWMIN = MAX( DBLE( LWMIN ), DBLE( WORK( 1 ) ) ) 00342 LRWMIN = MAX( DBLE( LRWMIN ), DBLE( RWORK( 1 ) ) ) 00343 LIWMIN = MAX( DBLE( LIWMIN ), DBLE( IWORK( 1 ) ) ) 00344 * 00345 IF( WANTZ ) THEN 00346 * 00347 * Backtransform eigenvectors to the original problem. 00348 * 00349 NEIG = N 00350 IF( INFO.GT.0 ) 00351 $ NEIG = INFO - 1 00352 IF( ITYPE.EQ.1 .OR. ITYPE.EQ.2 ) THEN 00353 * 00354 * For A*x=(lambda)*B*x and A*B*x=(lambda)*x; 00355 * backtransform eigenvectors: x = inv(L)**H *y or inv(U)*y 00356 * 00357 IF( UPPER ) THEN 00358 TRANS = 'N' 00359 ELSE 00360 TRANS = 'C' 00361 END IF 00362 * 00363 DO 10 J = 1, NEIG 00364 CALL ZTPSV( UPLO, TRANS, 'Non-unit', N, BP, Z( 1, J ), 00365 $ 1 ) 00366 10 CONTINUE 00367 * 00368 ELSE IF( ITYPE.EQ.3 ) THEN 00369 * 00370 * For B*A*x=(lambda)*x; 00371 * backtransform eigenvectors: x = L*y or U**H *y 00372 * 00373 IF( UPPER ) THEN 00374 TRANS = 'C' 00375 ELSE 00376 TRANS = 'N' 00377 END IF 00378 * 00379 DO 20 J = 1, NEIG 00380 CALL ZTPMV( UPLO, TRANS, 'Non-unit', N, BP, Z( 1, J ), 00381 $ 1 ) 00382 20 CONTINUE 00383 END IF 00384 END IF 00385 * 00386 WORK( 1 ) = LWMIN 00387 RWORK( 1 ) = LRWMIN 00388 IWORK( 1 ) = LIWMIN 00389 RETURN 00390 * 00391 * End of ZHPGVD 00392 * 00393 END