![]() |
LAPACK
3.4.1
LAPACK: Linear Algebra PACKage
|
00001 *> \brief <b> ZHPEVD computes the eigenvalues and, optionally, the left and/or right eigenvectors for OTHER matrices</b> 00002 * 00003 * =========== DOCUMENTATION =========== 00004 * 00005 * Online html documentation available at 00006 * http://www.netlib.org/lapack/explore-html/ 00007 * 00008 *> \htmlonly 00009 *> Download ZHPEVD + dependencies 00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zhpevd.f"> 00011 *> [TGZ]</a> 00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zhpevd.f"> 00013 *> [ZIP]</a> 00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zhpevd.f"> 00015 *> [TXT]</a> 00016 *> \endhtmlonly 00017 * 00018 * Definition: 00019 * =========== 00020 * 00021 * SUBROUTINE ZHPEVD( JOBZ, UPLO, N, AP, W, Z, LDZ, WORK, LWORK, 00022 * RWORK, LRWORK, IWORK, LIWORK, INFO ) 00023 * 00024 * .. Scalar Arguments .. 00025 * CHARACTER JOBZ, UPLO 00026 * INTEGER INFO, LDZ, LIWORK, LRWORK, LWORK, N 00027 * .. 00028 * .. Array Arguments .. 00029 * INTEGER IWORK( * ) 00030 * DOUBLE PRECISION RWORK( * ), W( * ) 00031 * COMPLEX*16 AP( * ), WORK( * ), Z( LDZ, * ) 00032 * .. 00033 * 00034 * 00035 *> \par Purpose: 00036 * ============= 00037 *> 00038 *> \verbatim 00039 *> 00040 *> ZHPEVD computes all the eigenvalues and, optionally, eigenvectors of 00041 *> a complex Hermitian matrix A in packed storage. If eigenvectors are 00042 *> desired, it uses a divide and conquer algorithm. 00043 *> 00044 *> The divide and conquer algorithm makes very mild assumptions about 00045 *> floating point arithmetic. It will work on machines with a guard 00046 *> digit in add/subtract, or on those binary machines without guard 00047 *> digits which subtract like the Cray X-MP, Cray Y-MP, Cray C-90, or 00048 *> Cray-2. It could conceivably fail on hexadecimal or decimal machines 00049 *> without guard digits, but we know of none. 00050 *> \endverbatim 00051 * 00052 * Arguments: 00053 * ========== 00054 * 00055 *> \param[in] JOBZ 00056 *> \verbatim 00057 *> JOBZ is CHARACTER*1 00058 *> = 'N': Compute eigenvalues only; 00059 *> = 'V': Compute eigenvalues and eigenvectors. 00060 *> \endverbatim 00061 *> 00062 *> \param[in] UPLO 00063 *> \verbatim 00064 *> UPLO is CHARACTER*1 00065 *> = 'U': Upper triangle of A is stored; 00066 *> = 'L': Lower triangle of A is stored. 00067 *> \endverbatim 00068 *> 00069 *> \param[in] N 00070 *> \verbatim 00071 *> N is INTEGER 00072 *> The order of the matrix A. N >= 0. 00073 *> \endverbatim 00074 *> 00075 *> \param[in,out] AP 00076 *> \verbatim 00077 *> AP is COMPLEX*16 array, dimension (N*(N+1)/2) 00078 *> On entry, the upper or lower triangle of the Hermitian matrix 00079 *> A, packed columnwise in a linear array. The j-th column of A 00080 *> is stored in the array AP as follows: 00081 *> if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; 00082 *> if UPLO = 'L', AP(i + (j-1)*(2*n-j)/2) = A(i,j) for j<=i<=n. 00083 *> 00084 *> On exit, AP is overwritten by values generated during the 00085 *> reduction to tridiagonal form. If UPLO = 'U', the diagonal 00086 *> and first superdiagonal of the tridiagonal matrix T overwrite 00087 *> the corresponding elements of A, and if UPLO = 'L', the 00088 *> diagonal and first subdiagonal of T overwrite the 00089 *> corresponding elements of A. 00090 *> \endverbatim 00091 *> 00092 *> \param[out] W 00093 *> \verbatim 00094 *> W is DOUBLE PRECISION array, dimension (N) 00095 *> If INFO = 0, the eigenvalues in ascending order. 00096 *> \endverbatim 00097 *> 00098 *> \param[out] Z 00099 *> \verbatim 00100 *> Z is COMPLEX*16 array, dimension (LDZ, N) 00101 *> If JOBZ = 'V', then if INFO = 0, Z contains the orthonormal 00102 *> eigenvectors of the matrix A, with the i-th column of Z 00103 *> holding the eigenvector associated with W(i). 00104 *> If JOBZ = 'N', then Z is not referenced. 00105 *> \endverbatim 00106 *> 00107 *> \param[in] LDZ 00108 *> \verbatim 00109 *> LDZ is INTEGER 00110 *> The leading dimension of the array Z. LDZ >= 1, and if 00111 *> JOBZ = 'V', LDZ >= max(1,N). 00112 *> \endverbatim 00113 *> 00114 *> \param[out] WORK 00115 *> \verbatim 00116 *> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK)) 00117 *> On exit, if INFO = 0, WORK(1) returns the required LWORK. 00118 *> \endverbatim 00119 *> 00120 *> \param[in] LWORK 00121 *> \verbatim 00122 *> LWORK is INTEGER 00123 *> The dimension of array WORK. 00124 *> If N <= 1, LWORK must be at least 1. 00125 *> If JOBZ = 'N' and N > 1, LWORK must be at least N. 00126 *> If JOBZ = 'V' and N > 1, LWORK must be at least 2*N. 00127 *> 00128 *> If LWORK = -1, then a workspace query is assumed; the routine 00129 *> only calculates the required sizes of the WORK, RWORK and 00130 *> IWORK arrays, returns these values as the first entries of 00131 *> the WORK, RWORK and IWORK arrays, and no error message 00132 *> related to LWORK or LRWORK or LIWORK is issued by XERBLA. 00133 *> \endverbatim 00134 *> 00135 *> \param[out] RWORK 00136 *> \verbatim 00137 *> RWORK is DOUBLE PRECISION array, 00138 *> dimension (LRWORK) 00139 *> On exit, if INFO = 0, RWORK(1) returns the required LRWORK. 00140 *> \endverbatim 00141 *> 00142 *> \param[in] LRWORK 00143 *> \verbatim 00144 *> LRWORK is INTEGER 00145 *> The dimension of array RWORK. 00146 *> If N <= 1, LRWORK must be at least 1. 00147 *> If JOBZ = 'N' and N > 1, LRWORK must be at least N. 00148 *> If JOBZ = 'V' and N > 1, LRWORK must be at least 00149 *> 1 + 5*N + 2*N**2. 00150 *> 00151 *> If LRWORK = -1, then a workspace query is assumed; the 00152 *> routine only calculates the required sizes of the WORK, RWORK 00153 *> and IWORK arrays, returns these values as the first entries 00154 *> of the WORK, RWORK and IWORK arrays, and no error message 00155 *> related to LWORK or LRWORK or LIWORK is issued by XERBLA. 00156 *> \endverbatim 00157 *> 00158 *> \param[out] IWORK 00159 *> \verbatim 00160 *> IWORK is INTEGER array, dimension (MAX(1,LIWORK)) 00161 *> On exit, if INFO = 0, IWORK(1) returns the required LIWORK. 00162 *> \endverbatim 00163 *> 00164 *> \param[in] LIWORK 00165 *> \verbatim 00166 *> LIWORK is INTEGER 00167 *> The dimension of array IWORK. 00168 *> If JOBZ = 'N' or N <= 1, LIWORK must be at least 1. 00169 *> If JOBZ = 'V' and N > 1, LIWORK must be at least 3 + 5*N. 00170 *> 00171 *> If LIWORK = -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] INFO 00179 *> \verbatim 00180 *> INFO is INTEGER 00181 *> = 0: successful exit 00182 *> < 0: if INFO = -i, the i-th argument had an illegal value. 00183 *> > 0: if INFO = i, the algorithm failed to converge; i 00184 *> off-diagonal elements of an intermediate tridiagonal 00185 *> form did not converge to zero. 00186 *> \endverbatim 00187 * 00188 * Authors: 00189 * ======== 00190 * 00191 *> \author Univ. of Tennessee 00192 *> \author Univ. of California Berkeley 00193 *> \author Univ. of Colorado Denver 00194 *> \author NAG Ltd. 00195 * 00196 *> \date November 2011 00197 * 00198 *> \ingroup complex16OTHEReigen 00199 * 00200 * ===================================================================== 00201 SUBROUTINE ZHPEVD( JOBZ, UPLO, N, AP, W, Z, LDZ, WORK, LWORK, 00202 $ RWORK, LRWORK, IWORK, LIWORK, INFO ) 00203 * 00204 * -- LAPACK driver routine (version 3.4.0) -- 00205 * -- LAPACK is a software package provided by Univ. of Tennessee, -- 00206 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- 00207 * November 2011 00208 * 00209 * .. Scalar Arguments .. 00210 CHARACTER JOBZ, UPLO 00211 INTEGER INFO, LDZ, LIWORK, LRWORK, LWORK, N 00212 * .. 00213 * .. Array Arguments .. 00214 INTEGER IWORK( * ) 00215 DOUBLE PRECISION RWORK( * ), W( * ) 00216 COMPLEX*16 AP( * ), WORK( * ), Z( LDZ, * ) 00217 * .. 00218 * 00219 * ===================================================================== 00220 * 00221 * .. Parameters .. 00222 DOUBLE PRECISION ZERO, ONE 00223 PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 ) 00224 COMPLEX*16 CONE 00225 PARAMETER ( CONE = ( 1.0D+0, 0.0D+0 ) ) 00226 * .. 00227 * .. Local Scalars .. 00228 LOGICAL LQUERY, WANTZ 00229 INTEGER IINFO, IMAX, INDE, INDRWK, INDTAU, INDWRK, 00230 $ ISCALE, LIWMIN, LLRWK, LLWRK, LRWMIN, LWMIN 00231 DOUBLE PRECISION ANRM, BIGNUM, EPS, RMAX, RMIN, SAFMIN, SIGMA, 00232 $ SMLNUM 00233 * .. 00234 * .. External Functions .. 00235 LOGICAL LSAME 00236 DOUBLE PRECISION DLAMCH, ZLANHP 00237 EXTERNAL LSAME, DLAMCH, ZLANHP 00238 * .. 00239 * .. External Subroutines .. 00240 EXTERNAL DSCAL, DSTERF, XERBLA, ZDSCAL, ZHPTRD, ZSTEDC, 00241 $ ZUPMTR 00242 * .. 00243 * .. Intrinsic Functions .. 00244 INTRINSIC SQRT 00245 * .. 00246 * .. Executable Statements .. 00247 * 00248 * Test the input parameters. 00249 * 00250 WANTZ = LSAME( JOBZ, 'V' ) 00251 LQUERY = ( LWORK.EQ.-1 .OR. LRWORK.EQ.-1 .OR. LIWORK.EQ.-1 ) 00252 * 00253 INFO = 0 00254 IF( .NOT.( WANTZ .OR. LSAME( JOBZ, 'N' ) ) ) THEN 00255 INFO = -1 00256 ELSE IF( .NOT.( LSAME( UPLO, 'L' ) .OR. LSAME( UPLO, 'U' ) ) ) 00257 $ THEN 00258 INFO = -2 00259 ELSE IF( N.LT.0 ) THEN 00260 INFO = -3 00261 ELSE IF( LDZ.LT.1 .OR. ( WANTZ .AND. LDZ.LT.N ) ) THEN 00262 INFO = -7 00263 END IF 00264 * 00265 IF( INFO.EQ.0 ) THEN 00266 IF( N.LE.1 ) THEN 00267 LWMIN = 1 00268 LIWMIN = 1 00269 LRWMIN = 1 00270 ELSE 00271 IF( WANTZ ) THEN 00272 LWMIN = 2*N 00273 LRWMIN = 1 + 5*N + 2*N**2 00274 LIWMIN = 3 + 5*N 00275 ELSE 00276 LWMIN = N 00277 LRWMIN = N 00278 LIWMIN = 1 00279 END IF 00280 END IF 00281 WORK( 1 ) = LWMIN 00282 RWORK( 1 ) = LRWMIN 00283 IWORK( 1 ) = LIWMIN 00284 * 00285 IF( LWORK.LT.LWMIN .AND. .NOT.LQUERY ) THEN 00286 INFO = -9 00287 ELSE IF( LRWORK.LT.LRWMIN .AND. .NOT.LQUERY ) THEN 00288 INFO = -11 00289 ELSE IF( LIWORK.LT.LIWMIN .AND. .NOT.LQUERY ) THEN 00290 INFO = -13 00291 END IF 00292 END IF 00293 * 00294 IF( INFO.NE.0 ) THEN 00295 CALL XERBLA( 'ZHPEVD', -INFO ) 00296 RETURN 00297 ELSE IF( LQUERY ) THEN 00298 RETURN 00299 END IF 00300 * 00301 * Quick return if possible 00302 * 00303 IF( N.EQ.0 ) 00304 $ RETURN 00305 * 00306 IF( N.EQ.1 ) THEN 00307 W( 1 ) = AP( 1 ) 00308 IF( WANTZ ) 00309 $ Z( 1, 1 ) = CONE 00310 RETURN 00311 END IF 00312 * 00313 * Get machine constants. 00314 * 00315 SAFMIN = DLAMCH( 'Safe minimum' ) 00316 EPS = DLAMCH( 'Precision' ) 00317 SMLNUM = SAFMIN / EPS 00318 BIGNUM = ONE / SMLNUM 00319 RMIN = SQRT( SMLNUM ) 00320 RMAX = SQRT( BIGNUM ) 00321 * 00322 * Scale matrix to allowable range, if necessary. 00323 * 00324 ANRM = ZLANHP( 'M', UPLO, N, AP, RWORK ) 00325 ISCALE = 0 00326 IF( ANRM.GT.ZERO .AND. ANRM.LT.RMIN ) THEN 00327 ISCALE = 1 00328 SIGMA = RMIN / ANRM 00329 ELSE IF( ANRM.GT.RMAX ) THEN 00330 ISCALE = 1 00331 SIGMA = RMAX / ANRM 00332 END IF 00333 IF( ISCALE.EQ.1 ) THEN 00334 CALL ZDSCAL( ( N*( N+1 ) ) / 2, SIGMA, AP, 1 ) 00335 END IF 00336 * 00337 * Call ZHPTRD to reduce Hermitian packed matrix to tridiagonal form. 00338 * 00339 INDE = 1 00340 INDTAU = 1 00341 INDRWK = INDE + N 00342 INDWRK = INDTAU + N 00343 LLWRK = LWORK - INDWRK + 1 00344 LLRWK = LRWORK - INDRWK + 1 00345 CALL ZHPTRD( UPLO, N, AP, W, RWORK( INDE ), WORK( INDTAU ), 00346 $ IINFO ) 00347 * 00348 * For eigenvalues only, call DSTERF. For eigenvectors, first call 00349 * ZUPGTR to generate the orthogonal matrix, then call ZSTEDC. 00350 * 00351 IF( .NOT.WANTZ ) THEN 00352 CALL DSTERF( N, W, RWORK( INDE ), INFO ) 00353 ELSE 00354 CALL ZSTEDC( 'I', N, W, RWORK( INDE ), Z, LDZ, WORK( INDWRK ), 00355 $ LLWRK, RWORK( INDRWK ), LLRWK, IWORK, LIWORK, 00356 $ INFO ) 00357 CALL ZUPMTR( 'L', UPLO, 'N', N, N, AP, WORK( INDTAU ), Z, LDZ, 00358 $ WORK( INDWRK ), IINFO ) 00359 END IF 00360 * 00361 * If matrix was scaled, then rescale eigenvalues appropriately. 00362 * 00363 IF( ISCALE.EQ.1 ) THEN 00364 IF( INFO.EQ.0 ) THEN 00365 IMAX = N 00366 ELSE 00367 IMAX = INFO - 1 00368 END IF 00369 CALL DSCAL( IMAX, ONE / SIGMA, W, 1 ) 00370 END IF 00371 * 00372 WORK( 1 ) = LWMIN 00373 RWORK( 1 ) = LRWMIN 00374 IWORK( 1 ) = LIWMIN 00375 RETURN 00376 * 00377 * End of ZHPEVD 00378 * 00379 END