00001 /* dsyevr.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__10 = 10; 00019 static integer c__1 = 1; 00020 static integer c__2 = 2; 00021 static integer c__3 = 3; 00022 static integer c__4 = 4; 00023 static integer c_n1 = -1; 00024 00025 /* Subroutine */ int dsyevr_(char *jobz, char *range, char *uplo, integer *n, 00026 doublereal *a, integer *lda, doublereal *vl, doublereal *vu, integer * 00027 il, integer *iu, doublereal *abstol, integer *m, doublereal *w, 00028 doublereal *z__, integer *ldz, integer *isuppz, doublereal *work, 00029 integer *lwork, integer *iwork, integer *liwork, integer *info) 00030 { 00031 /* System generated locals */ 00032 integer a_dim1, a_offset, z_dim1, z_offset, i__1, i__2; 00033 doublereal d__1, d__2; 00034 00035 /* Builtin functions */ 00036 double sqrt(doublereal); 00037 00038 /* Local variables */ 00039 integer i__, j, nb, jj; 00040 doublereal eps, vll, vuu, tmp1; 00041 integer indd, inde; 00042 doublereal anrm; 00043 integer imax; 00044 doublereal rmin, rmax; 00045 integer inddd, indee; 00046 extern /* Subroutine */ int dscal_(integer *, doublereal *, doublereal *, 00047 integer *); 00048 doublereal sigma; 00049 extern logical lsame_(char *, char *); 00050 integer iinfo; 00051 char order[1]; 00052 integer indwk; 00053 extern /* Subroutine */ int dcopy_(integer *, doublereal *, integer *, 00054 doublereal *, integer *), dswap_(integer *, doublereal *, integer 00055 *, doublereal *, integer *); 00056 integer lwmin; 00057 logical lower, wantz; 00058 extern doublereal dlamch_(char *); 00059 logical alleig, indeig; 00060 integer iscale, ieeeok, indibl, indifl; 00061 logical valeig; 00062 doublereal safmin; 00063 extern integer ilaenv_(integer *, char *, char *, integer *, integer *, 00064 integer *, integer *); 00065 extern /* Subroutine */ int xerbla_(char *, integer *); 00066 doublereal abstll, bignum; 00067 integer indtau, indisp; 00068 extern /* Subroutine */ int dstein_(integer *, doublereal *, doublereal *, 00069 integer *, doublereal *, integer *, integer *, doublereal *, 00070 integer *, doublereal *, integer *, integer *, integer *), 00071 dsterf_(integer *, doublereal *, doublereal *, integer *); 00072 integer indiwo, indwkn; 00073 extern doublereal dlansy_(char *, char *, integer *, doublereal *, 00074 integer *, doublereal *); 00075 extern /* Subroutine */ int dstebz_(char *, char *, integer *, doublereal 00076 *, doublereal *, integer *, integer *, doublereal *, doublereal *, 00077 doublereal *, integer *, integer *, doublereal *, integer *, 00078 integer *, doublereal *, integer *, integer *), 00079 dstemr_(char *, char *, integer *, doublereal *, doublereal *, 00080 doublereal *, doublereal *, integer *, integer *, integer *, 00081 doublereal *, doublereal *, integer *, integer *, integer *, 00082 logical *, doublereal *, integer *, integer *, integer *, integer 00083 *); 00084 integer liwmin; 00085 logical tryrac; 00086 extern /* Subroutine */ int dormtr_(char *, char *, char *, integer *, 00087 integer *, doublereal *, integer *, doublereal *, doublereal *, 00088 integer *, doublereal *, integer *, integer *); 00089 integer llwrkn, llwork, nsplit; 00090 doublereal smlnum; 00091 extern /* Subroutine */ int dsytrd_(char *, integer *, doublereal *, 00092 integer *, doublereal *, doublereal *, doublereal *, doublereal *, 00093 integer *, integer *); 00094 integer lwkopt; 00095 logical lquery; 00096 00097 00098 /* -- LAPACK driver routine (version 3.2) -- */ 00099 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ 00100 /* November 2006 */ 00101 00102 /* .. Scalar Arguments .. */ 00103 /* .. */ 00104 /* .. Array Arguments .. */ 00105 /* .. */ 00106 00107 /* Purpose */ 00108 /* ======= */ 00109 00110 /* DSYEVR computes selected eigenvalues and, optionally, eigenvectors */ 00111 /* of a real symmetric matrix A. Eigenvalues and eigenvectors can be */ 00112 /* selected by specifying either a range of values or a range of */ 00113 /* indices for the desired eigenvalues. */ 00114 00115 /* DSYEVR first reduces the matrix A to tridiagonal form T with a call */ 00116 /* to DSYTRD. Then, whenever possible, DSYEVR calls DSTEMR to compute */ 00117 /* the eigenspectrum using Relatively Robust Representations. DSTEMR */ 00118 /* computes eigenvalues by the dqds algorithm, while orthogonal */ 00119 /* eigenvectors are computed from various "good" L D L^T representations */ 00120 /* (also known as Relatively Robust Representations). Gram-Schmidt */ 00121 /* orthogonalization is avoided as far as possible. More specifically, */ 00122 /* the various steps of the algorithm are as follows. */ 00123 00124 /* For each unreduced block (submatrix) of T, */ 00125 /* (a) Compute T - sigma I = L D L^T, so that L and D */ 00126 /* define all the wanted eigenvalues to high relative accuracy. */ 00127 /* This means that small relative changes in the entries of D and L */ 00128 /* cause only small relative changes in the eigenvalues and */ 00129 /* eigenvectors. The standard (unfactored) representation of the */ 00130 /* tridiagonal matrix T does not have this property in general. */ 00131 /* (b) Compute the eigenvalues to suitable accuracy. */ 00132 /* If the eigenvectors are desired, the algorithm attains full */ 00133 /* accuracy of the computed eigenvalues only right before */ 00134 /* the corresponding vectors have to be computed, see steps c) and d). */ 00135 /* (c) For each cluster of close eigenvalues, select a new */ 00136 /* shift close to the cluster, find a new factorization, and refine */ 00137 /* the shifted eigenvalues to suitable accuracy. */ 00138 /* (d) For each eigenvalue with a large enough relative separation compute */ 00139 /* the corresponding eigenvector by forming a rank revealing twisted */ 00140 /* factorization. Go back to (c) for any clusters that remain. */ 00141 00142 /* The desired accuracy of the output can be specified by the input */ 00143 /* parameter ABSTOL. */ 00144 00145 /* For more details, see DSTEMR's documentation and: */ 00146 /* - Inderjit S. Dhillon and Beresford N. Parlett: "Multiple representations */ 00147 /* to compute orthogonal eigenvectors of symmetric tridiagonal matrices," */ 00148 /* Linear Algebra and its Applications, 387(1), pp. 1-28, August 2004. */ 00149 /* - Inderjit Dhillon and Beresford Parlett: "Orthogonal Eigenvectors and */ 00150 /* Relative Gaps," SIAM Journal on Matrix Analysis and Applications, Vol. 25, */ 00151 /* 2004. Also LAPACK Working Note 154. */ 00152 /* - Inderjit Dhillon: "A new O(n^2) algorithm for the symmetric */ 00153 /* tridiagonal eigenvalue/eigenvector problem", */ 00154 /* Computer Science Division Technical Report No. UCB/CSD-97-971, */ 00155 /* UC Berkeley, May 1997. */ 00156 00157 00158 /* Note 1 : DSYEVR calls DSTEMR when the full spectrum is requested */ 00159 /* on machines which conform to the ieee-754 floating point standard. */ 00160 /* DSYEVR calls DSTEBZ and SSTEIN on non-ieee machines and */ 00161 /* when partial spectrum requests are made. */ 00162 00163 /* Normal execution of DSTEMR may create NaNs and infinities and */ 00164 /* hence may abort due to a floating point exception in environments */ 00165 /* which do not handle NaNs and infinities in the ieee standard default */ 00166 /* manner. */ 00167 00168 /* Arguments */ 00169 /* ========= */ 00170 00171 /* JOBZ (input) CHARACTER*1 */ 00172 /* = 'N': Compute eigenvalues only; */ 00173 /* = 'V': Compute eigenvalues and eigenvectors. */ 00174 00175 /* RANGE (input) CHARACTER*1 */ 00176 /* = 'A': all eigenvalues will be found. */ 00177 /* = 'V': all eigenvalues in the half-open interval (VL,VU] */ 00178 /* will be found. */ 00179 /* = 'I': the IL-th through IU-th eigenvalues will be found. */ 00180 /* ********* For RANGE = 'V' or 'I' and IU - IL < N - 1, DSTEBZ and */ 00181 /* ********* DSTEIN are called */ 00182 00183 /* UPLO (input) CHARACTER*1 */ 00184 /* = 'U': Upper triangle of A is stored; */ 00185 /* = 'L': Lower triangle of A is stored. */ 00186 00187 /* N (input) INTEGER */ 00188 /* The order of the matrix A. N >= 0. */ 00189 00190 /* A (input/output) DOUBLE PRECISION array, dimension (LDA, N) */ 00191 /* On entry, the symmetric matrix A. If UPLO = 'U', the */ 00192 /* leading N-by-N upper triangular part of A contains the */ 00193 /* upper triangular part of the matrix A. If UPLO = 'L', */ 00194 /* the leading N-by-N lower triangular part of A contains */ 00195 /* the lower triangular part of the matrix A. */ 00196 /* On exit, the lower triangle (if UPLO='L') or the upper */ 00197 /* triangle (if UPLO='U') of A, including the diagonal, is */ 00198 /* destroyed. */ 00199 00200 /* LDA (input) INTEGER */ 00201 /* The leading dimension of the array A. LDA >= max(1,N). */ 00202 00203 /* VL (input) DOUBLE PRECISION */ 00204 /* VU (input) DOUBLE PRECISION */ 00205 /* If RANGE='V', the lower and upper bounds of the interval to */ 00206 /* be searched for eigenvalues. VL < VU. */ 00207 /* Not referenced if RANGE = 'A' or 'I'. */ 00208 00209 /* IL (input) INTEGER */ 00210 /* IU (input) INTEGER */ 00211 /* If RANGE='I', the indices (in ascending order) of the */ 00212 /* smallest and largest eigenvalues to be returned. */ 00213 /* 1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0. */ 00214 /* Not referenced if RANGE = 'A' or 'V'. */ 00215 00216 /* ABSTOL (input) DOUBLE PRECISION */ 00217 /* The absolute error tolerance for the eigenvalues. */ 00218 /* An approximate eigenvalue is accepted as converged */ 00219 /* when it is determined to lie in an interval [a,b] */ 00220 /* of width less than or equal to */ 00221 00222 /* ABSTOL + EPS * max( |a|,|b| ) , */ 00223 00224 /* where EPS is the machine precision. If ABSTOL is less than */ 00225 /* or equal to zero, then EPS*|T| will be used in its place, */ 00226 /* where |T| is the 1-norm of the tridiagonal matrix obtained */ 00227 /* by reducing A to tridiagonal form. */ 00228 00229 /* See "Computing Small Singular Values of Bidiagonal Matrices */ 00230 /* with Guaranteed High Relative Accuracy," by Demmel and */ 00231 /* Kahan, LAPACK Working Note #3. */ 00232 00233 /* If high relative accuracy is important, set ABSTOL to */ 00234 /* DLAMCH( 'Safe minimum' ). Doing so will guarantee that */ 00235 /* eigenvalues are computed to high relative accuracy when */ 00236 /* possible in future releases. The current code does not */ 00237 /* make any guarantees about high relative accuracy, but */ 00238 /* future releases will. See J. Barlow and J. Demmel, */ 00239 /* "Computing Accurate Eigensystems of Scaled Diagonally */ 00240 /* Dominant Matrices", LAPACK Working Note #7, for a discussion */ 00241 /* of which matrices define their eigenvalues to high relative */ 00242 /* accuracy. */ 00243 00244 /* M (output) INTEGER */ 00245 /* The total number of eigenvalues found. 0 <= M <= N. */ 00246 /* If RANGE = 'A', M = N, and if RANGE = 'I', M = IU-IL+1. */ 00247 00248 /* W (output) DOUBLE PRECISION array, dimension (N) */ 00249 /* The first M elements contain the selected eigenvalues in */ 00250 /* ascending order. */ 00251 00252 /* Z (output) DOUBLE PRECISION array, dimension (LDZ, max(1,M)) */ 00253 /* If JOBZ = 'V', then if INFO = 0, the first M columns of Z */ 00254 /* contain the orthonormal eigenvectors of the matrix A */ 00255 /* corresponding to the selected eigenvalues, with the i-th */ 00256 /* column of Z holding the eigenvector associated with W(i). */ 00257 /* If JOBZ = 'N', then Z is not referenced. */ 00258 /* Note: the user must ensure that at least max(1,M) columns are */ 00259 /* supplied in the array Z; if RANGE = 'V', the exact value of M */ 00260 /* is not known in advance and an upper bound must be used. */ 00261 /* Supplying N columns is always safe. */ 00262 00263 /* LDZ (input) INTEGER */ 00264 /* The leading dimension of the array Z. LDZ >= 1, and if */ 00265 /* JOBZ = 'V', LDZ >= max(1,N). */ 00266 00267 /* ISUPPZ (output) INTEGER array, dimension ( 2*max(1,M) ) */ 00268 /* The support of the eigenvectors in Z, i.e., the indices */ 00269 /* indicating the nonzero elements in Z. The i-th eigenvector */ 00270 /* is nonzero only in elements ISUPPZ( 2*i-1 ) through */ 00271 /* ISUPPZ( 2*i ). */ 00272 /* ********* Implemented only for RANGE = 'A' or 'I' and IU - IL = N - 1 */ 00273 00274 /* WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK)) */ 00275 /* On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ 00276 00277 /* LWORK (input) INTEGER */ 00278 /* The dimension of the array WORK. LWORK >= max(1,26*N). */ 00279 /* For optimal efficiency, LWORK >= (NB+6)*N, */ 00280 /* where NB is the max of the blocksize for DSYTRD and DORMTR */ 00281 /* returned by ILAENV. */ 00282 00283 /* If LWORK = -1, then a workspace query is assumed; the routine */ 00284 /* only calculates the optimal size of the WORK array, returns */ 00285 /* this value as the first entry of the WORK array, and no error */ 00286 /* message related to LWORK is issued by XERBLA. */ 00287 00288 /* IWORK (workspace/output) INTEGER array, dimension (MAX(1,LIWORK)) */ 00289 /* On exit, if INFO = 0, IWORK(1) returns the optimal LWORK. */ 00290 00291 /* LIWORK (input) INTEGER */ 00292 /* The dimension of the array IWORK. LIWORK >= max(1,10*N). */ 00293 00294 /* If LIWORK = -1, then a workspace query is assumed; the */ 00295 /* routine only calculates the optimal size of the IWORK array, */ 00296 /* returns this value as the first entry of the IWORK array, and */ 00297 /* no error message related to LIWORK is issued by XERBLA. */ 00298 00299 /* INFO (output) INTEGER */ 00300 /* = 0: successful exit */ 00301 /* < 0: if INFO = -i, the i-th argument had an illegal value */ 00302 /* > 0: Internal error */ 00303 00304 /* Further Details */ 00305 /* =============== */ 00306 00307 /* Based on contributions by */ 00308 /* Inderjit Dhillon, IBM Almaden, USA */ 00309 /* Osni Marques, LBNL/NERSC, USA */ 00310 /* Ken Stanley, Computer Science Division, University of */ 00311 /* California at Berkeley, USA */ 00312 /* Jason Riedy, Computer Science Division, University of */ 00313 /* California at Berkeley, USA */ 00314 00315 /* ===================================================================== */ 00316 00317 /* .. Parameters .. */ 00318 /* .. */ 00319 /* .. Local Scalars .. */ 00320 /* .. */ 00321 /* .. External Functions .. */ 00322 /* .. */ 00323 /* .. External Subroutines .. */ 00324 /* .. */ 00325 /* .. Intrinsic Functions .. */ 00326 /* .. */ 00327 /* .. Executable Statements .. */ 00328 00329 /* Test the input parameters. */ 00330 00331 /* Parameter adjustments */ 00332 a_dim1 = *lda; 00333 a_offset = 1 + a_dim1; 00334 a -= a_offset; 00335 --w; 00336 z_dim1 = *ldz; 00337 z_offset = 1 + z_dim1; 00338 z__ -= z_offset; 00339 --isuppz; 00340 --work; 00341 --iwork; 00342 00343 /* Function Body */ 00344 ieeeok = ilaenv_(&c__10, "DSYEVR", "N", &c__1, &c__2, &c__3, &c__4); 00345 00346 lower = lsame_(uplo, "L"); 00347 wantz = lsame_(jobz, "V"); 00348 alleig = lsame_(range, "A"); 00349 valeig = lsame_(range, "V"); 00350 indeig = lsame_(range, "I"); 00351 00352 lquery = *lwork == -1 || *liwork == -1; 00353 00354 /* Computing MAX */ 00355 i__1 = 1, i__2 = *n * 26; 00356 lwmin = max(i__1,i__2); 00357 /* Computing MAX */ 00358 i__1 = 1, i__2 = *n * 10; 00359 liwmin = max(i__1,i__2); 00360 00361 *info = 0; 00362 if (! (wantz || lsame_(jobz, "N"))) { 00363 *info = -1; 00364 } else if (! (alleig || valeig || indeig)) { 00365 *info = -2; 00366 } else if (! (lower || lsame_(uplo, "U"))) { 00367 *info = -3; 00368 } else if (*n < 0) { 00369 *info = -4; 00370 } else if (*lda < max(1,*n)) { 00371 *info = -6; 00372 } else { 00373 if (valeig) { 00374 if (*n > 0 && *vu <= *vl) { 00375 *info = -8; 00376 } 00377 } else if (indeig) { 00378 if (*il < 1 || *il > max(1,*n)) { 00379 *info = -9; 00380 } else if (*iu < min(*n,*il) || *iu > *n) { 00381 *info = -10; 00382 } 00383 } 00384 } 00385 if (*info == 0) { 00386 if (*ldz < 1 || wantz && *ldz < *n) { 00387 *info = -15; 00388 } else if (*lwork < lwmin && ! lquery) { 00389 *info = -18; 00390 } else if (*liwork < liwmin && ! lquery) { 00391 *info = -20; 00392 } 00393 } 00394 00395 if (*info == 0) { 00396 nb = ilaenv_(&c__1, "DSYTRD", uplo, n, &c_n1, &c_n1, &c_n1); 00397 /* Computing MAX */ 00398 i__1 = nb, i__2 = ilaenv_(&c__1, "DORMTR", uplo, n, &c_n1, &c_n1, & 00399 c_n1); 00400 nb = max(i__1,i__2); 00401 /* Computing MAX */ 00402 i__1 = (nb + 1) * *n; 00403 lwkopt = max(i__1,lwmin); 00404 work[1] = (doublereal) lwkopt; 00405 iwork[1] = liwmin; 00406 } 00407 00408 if (*info != 0) { 00409 i__1 = -(*info); 00410 xerbla_("DSYEVR", &i__1); 00411 return 0; 00412 } else if (lquery) { 00413 return 0; 00414 } 00415 00416 /* Quick return if possible */ 00417 00418 *m = 0; 00419 if (*n == 0) { 00420 work[1] = 1.; 00421 return 0; 00422 } 00423 00424 if (*n == 1) { 00425 work[1] = 7.; 00426 if (alleig || indeig) { 00427 *m = 1; 00428 w[1] = a[a_dim1 + 1]; 00429 } else { 00430 if (*vl < a[a_dim1 + 1] && *vu >= a[a_dim1 + 1]) { 00431 *m = 1; 00432 w[1] = a[a_dim1 + 1]; 00433 } 00434 } 00435 if (wantz) { 00436 z__[z_dim1 + 1] = 1.; 00437 } 00438 return 0; 00439 } 00440 00441 /* Get machine constants. */ 00442 00443 safmin = dlamch_("Safe minimum"); 00444 eps = dlamch_("Precision"); 00445 smlnum = safmin / eps; 00446 bignum = 1. / smlnum; 00447 rmin = sqrt(smlnum); 00448 /* Computing MIN */ 00449 d__1 = sqrt(bignum), d__2 = 1. / sqrt(sqrt(safmin)); 00450 rmax = min(d__1,d__2); 00451 00452 /* Scale matrix to allowable range, if necessary. */ 00453 00454 iscale = 0; 00455 abstll = *abstol; 00456 vll = *vl; 00457 vuu = *vu; 00458 anrm = dlansy_("M", uplo, n, &a[a_offset], lda, &work[1]); 00459 if (anrm > 0. && anrm < rmin) { 00460 iscale = 1; 00461 sigma = rmin / anrm; 00462 } else if (anrm > rmax) { 00463 iscale = 1; 00464 sigma = rmax / anrm; 00465 } 00466 if (iscale == 1) { 00467 if (lower) { 00468 i__1 = *n; 00469 for (j = 1; j <= i__1; ++j) { 00470 i__2 = *n - j + 1; 00471 dscal_(&i__2, &sigma, &a[j + j * a_dim1], &c__1); 00472 /* L10: */ 00473 } 00474 } else { 00475 i__1 = *n; 00476 for (j = 1; j <= i__1; ++j) { 00477 dscal_(&j, &sigma, &a[j * a_dim1 + 1], &c__1); 00478 /* L20: */ 00479 } 00480 } 00481 if (*abstol > 0.) { 00482 abstll = *abstol * sigma; 00483 } 00484 if (valeig) { 00485 vll = *vl * sigma; 00486 vuu = *vu * sigma; 00487 } 00488 } 00489 /* Initialize indices into workspaces. Note: The IWORK indices are */ 00490 /* used only if DSTERF or DSTEMR fail. */ 00491 /* WORK(INDTAU:INDTAU+N-1) stores the scalar factors of the */ 00492 /* elementary reflectors used in DSYTRD. */ 00493 indtau = 1; 00494 /* WORK(INDD:INDD+N-1) stores the tridiagonal's diagonal entries. */ 00495 indd = indtau + *n; 00496 /* WORK(INDE:INDE+N-1) stores the off-diagonal entries of the */ 00497 /* tridiagonal matrix from DSYTRD. */ 00498 inde = indd + *n; 00499 /* WORK(INDDD:INDDD+N-1) is a copy of the diagonal entries over */ 00500 /* -written by DSTEMR (the DSTERF path copies the diagonal to W). */ 00501 inddd = inde + *n; 00502 /* WORK(INDEE:INDEE+N-1) is a copy of the off-diagonal entries over */ 00503 /* -written while computing the eigenvalues in DSTERF and DSTEMR. */ 00504 indee = inddd + *n; 00505 /* INDWK is the starting offset of the left-over workspace, and */ 00506 /* LLWORK is the remaining workspace size. */ 00507 indwk = indee + *n; 00508 llwork = *lwork - indwk + 1; 00509 /* IWORK(INDIBL:INDIBL+M-1) corresponds to IBLOCK in DSTEBZ and */ 00510 /* stores the block indices of each of the M<=N eigenvalues. */ 00511 indibl = 1; 00512 /* IWORK(INDISP:INDISP+NSPLIT-1) corresponds to ISPLIT in DSTEBZ and */ 00513 /* stores the starting and finishing indices of each block. */ 00514 indisp = indibl + *n; 00515 /* IWORK(INDIFL:INDIFL+N-1) stores the indices of eigenvectors */ 00516 /* that corresponding to eigenvectors that fail to converge in */ 00517 /* DSTEIN. This information is discarded; if any fail, the driver */ 00518 /* returns INFO > 0. */ 00519 indifl = indisp + *n; 00520 /* INDIWO is the offset of the remaining integer workspace. */ 00521 indiwo = indisp + *n; 00522 00523 /* Call DSYTRD to reduce symmetric matrix to tridiagonal form. */ 00524 00525 dsytrd_(uplo, n, &a[a_offset], lda, &work[indd], &work[inde], &work[ 00526 indtau], &work[indwk], &llwork, &iinfo); 00527 00528 /* If all eigenvalues are desired */ 00529 /* then call DSTERF or DSTEMR and DORMTR. */ 00530 00531 if ((alleig || indeig && *il == 1 && *iu == *n) && ieeeok == 1) { 00532 if (! wantz) { 00533 dcopy_(n, &work[indd], &c__1, &w[1], &c__1); 00534 i__1 = *n - 1; 00535 dcopy_(&i__1, &work[inde], &c__1, &work[indee], &c__1); 00536 dsterf_(n, &w[1], &work[indee], info); 00537 } else { 00538 i__1 = *n - 1; 00539 dcopy_(&i__1, &work[inde], &c__1, &work[indee], &c__1); 00540 dcopy_(n, &work[indd], &c__1, &work[inddd], &c__1); 00541 00542 if (*abstol <= *n * 2. * eps) { 00543 tryrac = TRUE_; 00544 } else { 00545 tryrac = FALSE_; 00546 } 00547 dstemr_(jobz, "A", n, &work[inddd], &work[indee], vl, vu, il, iu, 00548 m, &w[1], &z__[z_offset], ldz, n, &isuppz[1], &tryrac, & 00549 work[indwk], lwork, &iwork[1], liwork, info); 00550 00551 00552 00553 /* Apply orthogonal matrix used in reduction to tridiagonal */ 00554 /* form to eigenvectors returned by DSTEIN. */ 00555 00556 if (wantz && *info == 0) { 00557 indwkn = inde; 00558 llwrkn = *lwork - indwkn + 1; 00559 dormtr_("L", uplo, "N", n, m, &a[a_offset], lda, &work[indtau] 00560 , &z__[z_offset], ldz, &work[indwkn], &llwrkn, &iinfo); 00561 } 00562 } 00563 00564 00565 if (*info == 0) { 00566 /* Everything worked. Skip DSTEBZ/DSTEIN. IWORK(:) are */ 00567 /* undefined. */ 00568 *m = *n; 00569 goto L30; 00570 } 00571 *info = 0; 00572 } 00573 00574 /* Otherwise, call DSTEBZ and, if eigenvectors are desired, DSTEIN. */ 00575 /* Also call DSTEBZ and DSTEIN if DSTEMR fails. */ 00576 00577 if (wantz) { 00578 *(unsigned char *)order = 'B'; 00579 } else { 00580 *(unsigned char *)order = 'E'; 00581 } 00582 dstebz_(range, order, n, &vll, &vuu, il, iu, &abstll, &work[indd], &work[ 00583 inde], m, &nsplit, &w[1], &iwork[indibl], &iwork[indisp], &work[ 00584 indwk], &iwork[indiwo], info); 00585 00586 if (wantz) { 00587 dstein_(n, &work[indd], &work[inde], m, &w[1], &iwork[indibl], &iwork[ 00588 indisp], &z__[z_offset], ldz, &work[indwk], &iwork[indiwo], & 00589 iwork[indifl], info); 00590 00591 /* Apply orthogonal matrix used in reduction to tridiagonal */ 00592 /* form to eigenvectors returned by DSTEIN. */ 00593 00594 indwkn = inde; 00595 llwrkn = *lwork - indwkn + 1; 00596 dormtr_("L", uplo, "N", n, m, &a[a_offset], lda, &work[indtau], &z__[ 00597 z_offset], ldz, &work[indwkn], &llwrkn, &iinfo); 00598 } 00599 00600 /* If matrix was scaled, then rescale eigenvalues appropriately. */ 00601 00602 /* Jump here if DSTEMR/DSTEIN succeeded. */ 00603 L30: 00604 if (iscale == 1) { 00605 if (*info == 0) { 00606 imax = *m; 00607 } else { 00608 imax = *info - 1; 00609 } 00610 d__1 = 1. / sigma; 00611 dscal_(&imax, &d__1, &w[1], &c__1); 00612 } 00613 00614 /* If eigenvalues are not in order, then sort them, along with */ 00615 /* eigenvectors. Note: We do not sort the IFAIL portion of IWORK. */ 00616 /* It may not be initialized (if DSTEMR/DSTEIN succeeded), and we do */ 00617 /* not return this detailed information to the user. */ 00618 00619 if (wantz) { 00620 i__1 = *m - 1; 00621 for (j = 1; j <= i__1; ++j) { 00622 i__ = 0; 00623 tmp1 = w[j]; 00624 i__2 = *m; 00625 for (jj = j + 1; jj <= i__2; ++jj) { 00626 if (w[jj] < tmp1) { 00627 i__ = jj; 00628 tmp1 = w[jj]; 00629 } 00630 /* L40: */ 00631 } 00632 00633 if (i__ != 0) { 00634 w[i__] = w[j]; 00635 w[j] = tmp1; 00636 dswap_(n, &z__[i__ * z_dim1 + 1], &c__1, &z__[j * z_dim1 + 1], 00637 &c__1); 00638 } 00639 /* L50: */ 00640 } 00641 } 00642 00643 /* Set WORK(1) to optimal workspace size. */ 00644 00645 work[1] = (doublereal) lwkopt; 00646 iwork[1] = liwmin; 00647 00648 return 0; 00649 00650 /* End of DSYEVR */ 00651 00652 } /* dsyevr_ */