![]() |
LAPACK
3.4.1
LAPACK: Linear Algebra PACKage
|
00001 *> \brief <b> ZHPEV 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 ZHPEV + dependencies 00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zhpev.f"> 00011 *> [TGZ]</a> 00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zhpev.f"> 00013 *> [ZIP]</a> 00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zhpev.f"> 00015 *> [TXT]</a> 00016 *> \endhtmlonly 00017 * 00018 * Definition: 00019 * =========== 00020 * 00021 * SUBROUTINE ZHPEV( JOBZ, UPLO, N, AP, W, Z, LDZ, WORK, RWORK, 00022 * INFO ) 00023 * 00024 * .. Scalar Arguments .. 00025 * CHARACTER JOBZ, UPLO 00026 * INTEGER INFO, LDZ, N 00027 * .. 00028 * .. Array Arguments .. 00029 * DOUBLE PRECISION RWORK( * ), W( * ) 00030 * COMPLEX*16 AP( * ), WORK( * ), Z( LDZ, * ) 00031 * .. 00032 * 00033 * 00034 *> \par Purpose: 00035 * ============= 00036 *> 00037 *> \verbatim 00038 *> 00039 *> ZHPEV computes all the eigenvalues and, optionally, eigenvectors of a 00040 *> complex Hermitian matrix in packed storage. 00041 *> \endverbatim 00042 * 00043 * Arguments: 00044 * ========== 00045 * 00046 *> \param[in] JOBZ 00047 *> \verbatim 00048 *> JOBZ is CHARACTER*1 00049 *> = 'N': Compute eigenvalues only; 00050 *> = 'V': Compute eigenvalues and eigenvectors. 00051 *> \endverbatim 00052 *> 00053 *> \param[in] UPLO 00054 *> \verbatim 00055 *> UPLO is CHARACTER*1 00056 *> = 'U': Upper triangle of A is stored; 00057 *> = 'L': Lower triangle of A is stored. 00058 *> \endverbatim 00059 *> 00060 *> \param[in] N 00061 *> \verbatim 00062 *> N is INTEGER 00063 *> The order of the matrix A. N >= 0. 00064 *> \endverbatim 00065 *> 00066 *> \param[in,out] AP 00067 *> \verbatim 00068 *> AP is COMPLEX*16 array, dimension (N*(N+1)/2) 00069 *> On entry, the upper or lower triangle of the Hermitian matrix 00070 *> A, packed columnwise in a linear array. The j-th column of A 00071 *> is stored in the array AP as follows: 00072 *> if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; 00073 *> if UPLO = 'L', AP(i + (j-1)*(2*n-j)/2) = A(i,j) for j<=i<=n. 00074 *> 00075 *> On exit, AP is overwritten by values generated during the 00076 *> reduction to tridiagonal form. If UPLO = 'U', the diagonal 00077 *> and first superdiagonal of the tridiagonal matrix T overwrite 00078 *> the corresponding elements of A, and if UPLO = 'L', the 00079 *> diagonal and first subdiagonal of T overwrite the 00080 *> corresponding elements of A. 00081 *> \endverbatim 00082 *> 00083 *> \param[out] W 00084 *> \verbatim 00085 *> W is DOUBLE PRECISION array, dimension (N) 00086 *> If INFO = 0, the eigenvalues in ascending order. 00087 *> \endverbatim 00088 *> 00089 *> \param[out] Z 00090 *> \verbatim 00091 *> Z is COMPLEX*16 array, dimension (LDZ, N) 00092 *> If JOBZ = 'V', then if INFO = 0, Z contains the orthonormal 00093 *> eigenvectors of the matrix A, with the i-th column of Z 00094 *> holding the eigenvector associated with W(i). 00095 *> If JOBZ = 'N', then Z is not referenced. 00096 *> \endverbatim 00097 *> 00098 *> \param[in] LDZ 00099 *> \verbatim 00100 *> LDZ is INTEGER 00101 *> The leading dimension of the array Z. LDZ >= 1, and if 00102 *> JOBZ = 'V', LDZ >= max(1,N). 00103 *> \endverbatim 00104 *> 00105 *> \param[out] WORK 00106 *> \verbatim 00107 *> WORK is COMPLEX*16 array, dimension (max(1, 2*N-1)) 00108 *> \endverbatim 00109 *> 00110 *> \param[out] RWORK 00111 *> \verbatim 00112 *> RWORK is DOUBLE PRECISION array, dimension (max(1, 3*N-2)) 00113 *> \endverbatim 00114 *> 00115 *> \param[out] INFO 00116 *> \verbatim 00117 *> INFO is INTEGER 00118 *> = 0: successful exit. 00119 *> < 0: if INFO = -i, the i-th argument had an illegal value. 00120 *> > 0: if INFO = i, the algorithm failed to converge; i 00121 *> off-diagonal elements of an intermediate tridiagonal 00122 *> form did not converge to zero. 00123 *> \endverbatim 00124 * 00125 * Authors: 00126 * ======== 00127 * 00128 *> \author Univ. of Tennessee 00129 *> \author Univ. of California Berkeley 00130 *> \author Univ. of Colorado Denver 00131 *> \author NAG Ltd. 00132 * 00133 *> \date November 2011 00134 * 00135 *> \ingroup complex16OTHEReigen 00136 * 00137 * ===================================================================== 00138 SUBROUTINE ZHPEV( JOBZ, UPLO, N, AP, W, Z, LDZ, WORK, RWORK, 00139 $ INFO ) 00140 * 00141 * -- LAPACK driver routine (version 3.4.0) -- 00142 * -- LAPACK is a software package provided by Univ. of Tennessee, -- 00143 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- 00144 * November 2011 00145 * 00146 * .. Scalar Arguments .. 00147 CHARACTER JOBZ, UPLO 00148 INTEGER INFO, LDZ, N 00149 * .. 00150 * .. Array Arguments .. 00151 DOUBLE PRECISION RWORK( * ), W( * ) 00152 COMPLEX*16 AP( * ), WORK( * ), Z( LDZ, * ) 00153 * .. 00154 * 00155 * ===================================================================== 00156 * 00157 * .. Parameters .. 00158 DOUBLE PRECISION ZERO, ONE 00159 PARAMETER ( ZERO = 0.0D0, ONE = 1.0D0 ) 00160 * .. 00161 * .. Local Scalars .. 00162 LOGICAL WANTZ 00163 INTEGER IINFO, IMAX, INDE, INDRWK, INDTAU, INDWRK, 00164 $ ISCALE 00165 DOUBLE PRECISION ANRM, BIGNUM, EPS, RMAX, RMIN, SAFMIN, SIGMA, 00166 $ SMLNUM 00167 * .. 00168 * .. External Functions .. 00169 LOGICAL LSAME 00170 DOUBLE PRECISION DLAMCH, ZLANHP 00171 EXTERNAL LSAME, DLAMCH, ZLANHP 00172 * .. 00173 * .. External Subroutines .. 00174 EXTERNAL DSCAL, DSTERF, XERBLA, ZDSCAL, ZHPTRD, ZSTEQR, 00175 $ ZUPGTR 00176 * .. 00177 * .. Intrinsic Functions .. 00178 INTRINSIC SQRT 00179 * .. 00180 * .. Executable Statements .. 00181 * 00182 * Test the input parameters. 00183 * 00184 WANTZ = LSAME( JOBZ, 'V' ) 00185 * 00186 INFO = 0 00187 IF( .NOT.( WANTZ .OR. LSAME( JOBZ, 'N' ) ) ) THEN 00188 INFO = -1 00189 ELSE IF( .NOT.( LSAME( UPLO, 'L' ) .OR. LSAME( UPLO, 'U' ) ) ) 00190 $ THEN 00191 INFO = -2 00192 ELSE IF( N.LT.0 ) THEN 00193 INFO = -3 00194 ELSE IF( LDZ.LT.1 .OR. ( WANTZ .AND. LDZ.LT.N ) ) THEN 00195 INFO = -7 00196 END IF 00197 * 00198 IF( INFO.NE.0 ) THEN 00199 CALL XERBLA( 'ZHPEV ', -INFO ) 00200 RETURN 00201 END IF 00202 * 00203 * Quick return if possible 00204 * 00205 IF( N.EQ.0 ) 00206 $ RETURN 00207 * 00208 IF( N.EQ.1 ) THEN 00209 W( 1 ) = AP( 1 ) 00210 RWORK( 1 ) = 1 00211 IF( WANTZ ) 00212 $ Z( 1, 1 ) = ONE 00213 RETURN 00214 END IF 00215 * 00216 * Get machine constants. 00217 * 00218 SAFMIN = DLAMCH( 'Safe minimum' ) 00219 EPS = DLAMCH( 'Precision' ) 00220 SMLNUM = SAFMIN / EPS 00221 BIGNUM = ONE / SMLNUM 00222 RMIN = SQRT( SMLNUM ) 00223 RMAX = SQRT( BIGNUM ) 00224 * 00225 * Scale matrix to allowable range, if necessary. 00226 * 00227 ANRM = ZLANHP( 'M', UPLO, N, AP, RWORK ) 00228 ISCALE = 0 00229 IF( ANRM.GT.ZERO .AND. ANRM.LT.RMIN ) THEN 00230 ISCALE = 1 00231 SIGMA = RMIN / ANRM 00232 ELSE IF( ANRM.GT.RMAX ) THEN 00233 ISCALE = 1 00234 SIGMA = RMAX / ANRM 00235 END IF 00236 IF( ISCALE.EQ.1 ) THEN 00237 CALL ZDSCAL( ( N*( N+1 ) ) / 2, SIGMA, AP, 1 ) 00238 END IF 00239 * 00240 * Call ZHPTRD to reduce Hermitian packed matrix to tridiagonal form. 00241 * 00242 INDE = 1 00243 INDTAU = 1 00244 CALL ZHPTRD( UPLO, N, AP, W, RWORK( INDE ), WORK( INDTAU ), 00245 $ IINFO ) 00246 * 00247 * For eigenvalues only, call DSTERF. For eigenvectors, first call 00248 * ZUPGTR to generate the orthogonal matrix, then call ZSTEQR. 00249 * 00250 IF( .NOT.WANTZ ) THEN 00251 CALL DSTERF( N, W, RWORK( INDE ), INFO ) 00252 ELSE 00253 INDWRK = INDTAU + N 00254 CALL ZUPGTR( UPLO, N, AP, WORK( INDTAU ), Z, LDZ, 00255 $ WORK( INDWRK ), IINFO ) 00256 INDRWK = INDE + N 00257 CALL ZSTEQR( JOBZ, N, W, RWORK( INDE ), Z, LDZ, 00258 $ RWORK( INDRWK ), INFO ) 00259 END IF 00260 * 00261 * If matrix was scaled, then rescale eigenvalues appropriately. 00262 * 00263 IF( ISCALE.EQ.1 ) THEN 00264 IF( INFO.EQ.0 ) THEN 00265 IMAX = N 00266 ELSE 00267 IMAX = INFO - 1 00268 END IF 00269 CALL DSCAL( IMAX, ONE / SIGMA, W, 1 ) 00270 END IF 00271 * 00272 RETURN 00273 * 00274 * End of ZHPEV 00275 * 00276 END