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


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