00001 /* zhpgvx.f -- translated by f2c (version 20061008). 00002 You must link the resulting object file with libf2c: 00003 on Microsoft Windows system, link with libf2c.lib; 00004 on Linux or Unix systems, link with .../path/to/libf2c.a -lm 00005 or, if you install libf2c.a in a standard place, with -lf2c -lm 00006 -- in that order, at the end of the command line, as in 00007 cc *.o -lf2c -lm 00008 Source for libf2c is in /netlib/f2c/libf2c.zip, e.g., 00009 00010 http://www.netlib.org/f2c/libf2c.zip 00011 */ 00012 00013 #include "f2c.h" 00014 #include "blaswrap.h" 00015 00016 /* Table of constant values */ 00017 00018 static integer c__1 = 1; 00019 00020 /* Subroutine */ int zhpgvx_(integer *itype, char *jobz, char *range, char * 00021 uplo, integer *n, doublecomplex *ap, doublecomplex *bp, doublereal * 00022 vl, doublereal *vu, integer *il, integer *iu, doublereal *abstol, 00023 integer *m, doublereal *w, doublecomplex *z__, integer *ldz, 00024 doublecomplex *work, doublereal *rwork, integer *iwork, integer * 00025 ifail, integer *info) 00026 { 00027 /* System generated locals */ 00028 integer z_dim1, z_offset, i__1; 00029 00030 /* Local variables */ 00031 integer j; 00032 extern logical lsame_(char *, char *); 00033 char trans[1]; 00034 logical upper, wantz; 00035 extern /* Subroutine */ int ztpmv_(char *, char *, char *, integer *, 00036 doublecomplex *, doublecomplex *, integer *), ztpsv_(char *, char *, char *, integer *, doublecomplex * 00037 , doublecomplex *, integer *); 00038 logical alleig, indeig, valeig; 00039 extern /* Subroutine */ int xerbla_(char *, integer *), zhpgst_( 00040 integer *, char *, integer *, doublecomplex *, doublecomplex *, 00041 integer *), zhpevx_(char *, char *, char *, integer *, 00042 doublecomplex *, doublereal *, doublereal *, integer *, integer *, 00043 doublereal *, integer *, doublereal *, doublecomplex *, integer * 00044 , doublecomplex *, doublereal *, integer *, integer *, integer *), zpptrf_(char *, integer *, doublecomplex 00045 *, integer *); 00046 00047 00048 /* -- LAPACK driver routine (version 3.2) -- */ 00049 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ 00050 /* November 2006 */ 00051 00052 /* .. Scalar Arguments .. */ 00053 /* .. */ 00054 /* .. Array Arguments .. */ 00055 /* .. */ 00056 00057 /* Purpose */ 00058 /* ======= */ 00059 00060 /* ZHPGVX computes selected eigenvalues and, optionally, eigenvectors */ 00061 /* of a complex generalized Hermitian-definite eigenproblem, of the form */ 00062 /* A*x=(lambda)*B*x, A*Bx=(lambda)*x, or B*A*x=(lambda)*x. Here A and */ 00063 /* B are assumed to be Hermitian, stored in packed format, and B is also */ 00064 /* positive definite. Eigenvalues and eigenvectors can be selected by */ 00065 /* specifying either a range of values or a range of indices for the */ 00066 /* desired eigenvalues. */ 00067 00068 /* Arguments */ 00069 /* ========= */ 00070 00071 /* ITYPE (input) INTEGER */ 00072 /* Specifies the problem type to be solved: */ 00073 /* = 1: A*x = (lambda)*B*x */ 00074 /* = 2: A*B*x = (lambda)*x */ 00075 /* = 3: B*A*x = (lambda)*x */ 00076 00077 /* JOBZ (input) CHARACTER*1 */ 00078 /* = 'N': Compute eigenvalues only; */ 00079 /* = 'V': Compute eigenvalues and eigenvectors. */ 00080 00081 /* RANGE (input) CHARACTER*1 */ 00082 /* = 'A': all eigenvalues will be found; */ 00083 /* = 'V': all eigenvalues in the half-open interval (VL,VU] */ 00084 /* will be found; */ 00085 /* = 'I': the IL-th through IU-th eigenvalues will be found. */ 00086 00087 /* UPLO (input) CHARACTER*1 */ 00088 /* = 'U': Upper triangles of A and B are stored; */ 00089 /* = 'L': Lower triangles of A and B are stored. */ 00090 00091 /* N (input) INTEGER */ 00092 /* The order of the matrices A and B. N >= 0. */ 00093 00094 /* AP (input/output) COMPLEX*16 array, dimension (N*(N+1)/2) */ 00095 /* On entry, the upper or lower triangle of the Hermitian matrix */ 00096 /* A, packed columnwise in a linear array. The j-th column of A */ 00097 /* is stored in the array AP as follows: */ 00098 /* if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; */ 00099 /* if UPLO = 'L', AP(i + (j-1)*(2*n-j)/2) = A(i,j) for j<=i<=n. */ 00100 00101 /* On exit, the contents of AP are destroyed. */ 00102 00103 /* BP (input/output) COMPLEX*16 array, dimension (N*(N+1)/2) */ 00104 /* On entry, the upper or lower triangle of the Hermitian matrix */ 00105 /* B, packed columnwise in a linear array. The j-th column of B */ 00106 /* is stored in the array BP as follows: */ 00107 /* if UPLO = 'U', BP(i + (j-1)*j/2) = B(i,j) for 1<=i<=j; */ 00108 /* if UPLO = 'L', BP(i + (j-1)*(2*n-j)/2) = B(i,j) for j<=i<=n. */ 00109 00110 /* On exit, the triangular factor U or L from the Cholesky */ 00111 /* factorization B = U**H*U or B = L*L**H, in the same storage */ 00112 /* format as B. */ 00113 00114 /* VL (input) DOUBLE PRECISION */ 00115 /* VU (input) DOUBLE PRECISION */ 00116 /* If RANGE='V', the lower and upper bounds of the interval to */ 00117 /* be searched for eigenvalues. VL < VU. */ 00118 /* Not referenced if RANGE = 'A' or 'I'. */ 00119 00120 /* IL (input) INTEGER */ 00121 /* IU (input) INTEGER */ 00122 /* If RANGE='I', the indices (in ascending order) of the */ 00123 /* smallest and largest eigenvalues to be returned. */ 00124 /* 1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0. */ 00125 /* Not referenced if RANGE = 'A' or 'V'. */ 00126 00127 /* ABSTOL (input) DOUBLE PRECISION */ 00128 /* The absolute error tolerance for the eigenvalues. */ 00129 /* An approximate eigenvalue is accepted as converged */ 00130 /* when it is determined to lie in an interval [a,b] */ 00131 /* of width less than or equal to */ 00132 00133 /* ABSTOL + EPS * max( |a|,|b| ) , */ 00134 00135 /* where EPS is the machine precision. If ABSTOL is less than */ 00136 /* or equal to zero, then EPS*|T| will be used in its place, */ 00137 /* where |T| is the 1-norm of the tridiagonal matrix obtained */ 00138 /* by reducing AP to tridiagonal form. */ 00139 00140 /* Eigenvalues will be computed most accurately when ABSTOL is */ 00141 /* set to twice the underflow threshold 2*DLAMCH('S'), not zero. */ 00142 /* If this routine returns with INFO>0, indicating that some */ 00143 /* eigenvectors did not converge, try setting ABSTOL to */ 00144 /* 2*DLAMCH('S'). */ 00145 00146 /* M (output) INTEGER */ 00147 /* The total number of eigenvalues found. 0 <= M <= N. */ 00148 /* If RANGE = 'A', M = N, and if RANGE = 'I', M = IU-IL+1. */ 00149 00150 /* W (output) DOUBLE PRECISION array, dimension (N) */ 00151 /* On normal exit, the first M elements contain the selected */ 00152 /* eigenvalues in ascending order. */ 00153 00154 /* Z (output) COMPLEX*16 array, dimension (LDZ, N) */ 00155 /* If JOBZ = 'N', then Z is not referenced. */ 00156 /* If JOBZ = 'V', then if INFO = 0, the first M columns of Z */ 00157 /* contain the orthonormal eigenvectors of the matrix A */ 00158 /* corresponding to the selected eigenvalues, with the i-th */ 00159 /* column of Z holding the eigenvector associated with W(i). */ 00160 /* The eigenvectors are normalized as follows: */ 00161 /* if ITYPE = 1 or 2, Z**H*B*Z = I; */ 00162 /* if ITYPE = 3, Z**H*inv(B)*Z = I. */ 00163 00164 /* If an eigenvector fails to converge, then that column of Z */ 00165 /* contains the latest approximation to the eigenvector, and the */ 00166 /* index of the eigenvector is returned in IFAIL. */ 00167 /* Note: the user must ensure that at least max(1,M) columns are */ 00168 /* supplied in the array Z; if RANGE = 'V', the exact value of M */ 00169 /* is not known in advance and an upper bound must be used. */ 00170 00171 /* LDZ (input) INTEGER */ 00172 /* The leading dimension of the array Z. LDZ >= 1, and if */ 00173 /* JOBZ = 'V', LDZ >= max(1,N). */ 00174 00175 /* WORK (workspace) COMPLEX*16 array, dimension (2*N) */ 00176 00177 /* RWORK (workspace) DOUBLE PRECISION array, dimension (7*N) */ 00178 00179 /* IWORK (workspace) INTEGER array, dimension (5*N) */ 00180 00181 /* IFAIL (output) INTEGER array, dimension (N) */ 00182 /* If JOBZ = 'V', then if INFO = 0, the first M elements of */ 00183 /* IFAIL are zero. If INFO > 0, then IFAIL contains the */ 00184 /* indices of the eigenvectors that failed to converge. */ 00185 /* If JOBZ = 'N', then IFAIL is not referenced. */ 00186 00187 /* INFO (output) INTEGER */ 00188 /* = 0: successful exit */ 00189 /* < 0: if INFO = -i, the i-th argument had an illegal value */ 00190 /* > 0: ZPPTRF or ZHPEVX returned an error code: */ 00191 /* <= N: if INFO = i, ZHPEVX failed to converge; */ 00192 /* i eigenvectors failed to converge. Their indices */ 00193 /* are stored in array IFAIL. */ 00194 /* > N: if INFO = N + i, for 1 <= i <= n, then the leading */ 00195 /* minor of order i of B is not positive definite. */ 00196 /* The factorization of B could not be completed and */ 00197 /* no eigenvalues or eigenvectors were computed. */ 00198 00199 /* Further Details */ 00200 /* =============== */ 00201 00202 /* Based on contributions by */ 00203 /* Mark Fahey, Department of Mathematics, Univ. of Kentucky, USA */ 00204 00205 /* ===================================================================== */ 00206 00207 /* .. Local Scalars .. */ 00208 /* .. */ 00209 /* .. External Functions .. */ 00210 /* .. */ 00211 /* .. External Subroutines .. */ 00212 /* .. */ 00213 /* .. Intrinsic Functions .. */ 00214 /* .. */ 00215 /* .. Executable Statements .. */ 00216 00217 /* Test the input parameters. */ 00218 00219 /* Parameter adjustments */ 00220 --ap; 00221 --bp; 00222 --w; 00223 z_dim1 = *ldz; 00224 z_offset = 1 + z_dim1; 00225 z__ -= z_offset; 00226 --work; 00227 --rwork; 00228 --iwork; 00229 --ifail; 00230 00231 /* Function Body */ 00232 wantz = lsame_(jobz, "V"); 00233 upper = lsame_(uplo, "U"); 00234 alleig = lsame_(range, "A"); 00235 valeig = lsame_(range, "V"); 00236 indeig = lsame_(range, "I"); 00237 00238 *info = 0; 00239 if (*itype < 1 || *itype > 3) { 00240 *info = -1; 00241 } else if (! (wantz || lsame_(jobz, "N"))) { 00242 *info = -2; 00243 } else if (! (alleig || valeig || indeig)) { 00244 *info = -3; 00245 } else if (! (upper || lsame_(uplo, "L"))) { 00246 *info = -4; 00247 } else if (*n < 0) { 00248 *info = -5; 00249 } else { 00250 if (valeig) { 00251 if (*n > 0 && *vu <= *vl) { 00252 *info = -9; 00253 } 00254 } else if (indeig) { 00255 if (*il < 1) { 00256 *info = -10; 00257 } else if (*iu < min(*n,*il) || *iu > *n) { 00258 *info = -11; 00259 } 00260 } 00261 } 00262 if (*info == 0) { 00263 if (*ldz < 1 || wantz && *ldz < *n) { 00264 *info = -16; 00265 } 00266 } 00267 00268 if (*info != 0) { 00269 i__1 = -(*info); 00270 xerbla_("ZHPGVX", &i__1); 00271 return 0; 00272 } 00273 00274 /* Quick return if possible */ 00275 00276 if (*n == 0) { 00277 return 0; 00278 } 00279 00280 /* Form a Cholesky factorization of B. */ 00281 00282 zpptrf_(uplo, n, &bp[1], info); 00283 if (*info != 0) { 00284 *info = *n + *info; 00285 return 0; 00286 } 00287 00288 /* Transform problem to standard eigenvalue problem and solve. */ 00289 00290 zhpgst_(itype, uplo, n, &ap[1], &bp[1], info); 00291 zhpevx_(jobz, range, uplo, n, &ap[1], vl, vu, il, iu, abstol, m, &w[1], & 00292 z__[z_offset], ldz, &work[1], &rwork[1], &iwork[1], &ifail[1], 00293 info); 00294 00295 if (wantz) { 00296 00297 /* Backtransform eigenvectors to the original problem. */ 00298 00299 if (*info > 0) { 00300 *m = *info - 1; 00301 } 00302 if (*itype == 1 || *itype == 2) { 00303 00304 /* For A*x=(lambda)*B*x and A*B*x=(lambda)*x; */ 00305 /* backtransform eigenvectors: x = inv(L)'*y or inv(U)*y */ 00306 00307 if (upper) { 00308 *(unsigned char *)trans = 'N'; 00309 } else { 00310 *(unsigned char *)trans = 'C'; 00311 } 00312 00313 i__1 = *m; 00314 for (j = 1; j <= i__1; ++j) { 00315 ztpsv_(uplo, trans, "Non-unit", n, &bp[1], &z__[j * z_dim1 + 00316 1], &c__1); 00317 /* L10: */ 00318 } 00319 00320 } else if (*itype == 3) { 00321 00322 /* For B*A*x=(lambda)*x; */ 00323 /* backtransform eigenvectors: x = L*y or U'*y */ 00324 00325 if (upper) { 00326 *(unsigned char *)trans = 'C'; 00327 } else { 00328 *(unsigned char *)trans = 'N'; 00329 } 00330 00331 i__1 = *m; 00332 for (j = 1; j <= i__1; ++j) { 00333 ztpmv_(uplo, trans, "Non-unit", n, &bp[1], &z__[j * z_dim1 + 00334 1], &c__1); 00335 /* L20: */ 00336 } 00337 } 00338 } 00339 00340 return 0; 00341 00342 /* End of ZHPGVX */ 00343 00344 } /* zhpgvx_ */