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


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:56:37