sstevd.c
Go to the documentation of this file.
00001 /* sstevd.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 sstevd_(char *jobz, integer *n, real *d__, real *e, real 
00021         *z__, integer *ldz, real *work, integer *lwork, integer *iwork, 
00022         integer *liwork, integer *info)
00023 {
00024     /* System generated locals */
00025     integer z_dim1, z_offset, i__1;
00026     real r__1;
00027 
00028     /* Builtin functions */
00029     double sqrt(doublereal);
00030 
00031     /* Local variables */
00032     real eps, rmin, rmax, tnrm, sigma;
00033     extern logical lsame_(char *, char *);
00034     extern /* Subroutine */ int sscal_(integer *, real *, real *, integer *);
00035     integer lwmin;
00036     logical wantz;
00037     integer iscale;
00038     extern doublereal slamch_(char *);
00039     real safmin;
00040     extern /* Subroutine */ int xerbla_(char *, integer *);
00041     real bignum;
00042     extern /* Subroutine */ int sstedc_(char *, integer *, real *, real *, 
00043             real *, integer *, real *, integer *, integer *, integer *, 
00044             integer *);
00045     integer liwmin;
00046     extern doublereal slanst_(char *, integer *, real *, real *);
00047     extern /* Subroutine */ int ssterf_(integer *, real *, real *, integer *);
00048     real smlnum;
00049     logical lquery;
00050 
00051 
00052 /*  -- LAPACK driver routine (version 3.2) -- */
00053 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00054 /*     November 2006 */
00055 
00056 /*     .. Scalar Arguments .. */
00057 /*     .. */
00058 /*     .. Array Arguments .. */
00059 /*     .. */
00060 
00061 /*  Purpose */
00062 /*  ======= */
00063 
00064 /*  SSTEVD computes all eigenvalues and, optionally, eigenvectors of a */
00065 /*  real symmetric tridiagonal matrix. If eigenvectors are desired, it */
00066 /*  uses a divide and conquer algorithm. */
00067 
00068 /*  The divide and conquer algorithm makes very mild assumptions about */
00069 /*  floating point arithmetic. It will work on machines with a guard */
00070 /*  digit in add/subtract, or on those binary machines without guard */
00071 /*  digits which subtract like the Cray X-MP, Cray Y-MP, Cray C-90, or */
00072 /*  Cray-2. It could conceivably fail on hexadecimal or decimal machines */
00073 /*  without guard digits, but we know of none. */
00074 
00075 /*  Arguments */
00076 /*  ========= */
00077 
00078 /*  JOBZ    (input) CHARACTER*1 */
00079 /*          = 'N':  Compute eigenvalues only; */
00080 /*          = 'V':  Compute eigenvalues and eigenvectors. */
00081 
00082 /*  N       (input) INTEGER */
00083 /*          The order of the matrix.  N >= 0. */
00084 
00085 /*  D       (input/output) REAL array, dimension (N) */
00086 /*          On entry, the n diagonal elements of the tridiagonal matrix */
00087 /*          A. */
00088 /*          On exit, if INFO = 0, the eigenvalues in ascending order. */
00089 
00090 /*  E       (input/output) REAL array, dimension (N-1) */
00091 /*          On entry, the (n-1) subdiagonal elements of the tridiagonal */
00092 /*          matrix A, stored in elements 1 to N-1 of E. */
00093 /*          On exit, the contents of E are destroyed. */
00094 
00095 /*  Z       (output) REAL array, dimension (LDZ, N) */
00096 /*          If JOBZ = 'V', then if INFO = 0, Z contains the orthonormal */
00097 /*          eigenvectors of the matrix A, with the i-th column of Z */
00098 /*          holding the eigenvector associated with D(i). */
00099 /*          If JOBZ = 'N', then Z is not referenced. */
00100 
00101 /*  LDZ     (input) INTEGER */
00102 /*          The leading dimension of the array Z.  LDZ >= 1, and if */
00103 /*          JOBZ = 'V', LDZ >= max(1,N). */
00104 
00105 /*  WORK    (workspace/output) REAL array, */
00106 /*                                         dimension (LWORK) */
00107 /*          On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */
00108 
00109 /*  LWORK   (input) INTEGER */
00110 /*          The dimension of the array WORK. */
00111 /*          If JOBZ  = 'N' or N <= 1 then LWORK must be at least 1. */
00112 /*          If JOBZ  = 'V' and N > 1 then LWORK must be at least */
00113 /*                         ( 1 + 4*N + N**2 ). */
00114 
00115 /*          If LWORK = -1, then a workspace query is assumed; the routine */
00116 /*          only calculates the optimal sizes of the WORK and IWORK */
00117 /*          arrays, returns these values as the first entries of the WORK */
00118 /*          and IWORK arrays, and no error message related to LWORK or */
00119 /*          LIWORK is issued by XERBLA. */
00120 
00121 /*  IWORK   (workspace/output) INTEGER array, dimension (MAX(1,LIWORK)) */
00122 /*          On exit, if INFO = 0, IWORK(1) returns the optimal LIWORK. */
00123 
00124 /*  LIWORK  (input) INTEGER */
00125 /*          The dimension of the array IWORK. */
00126 /*          If JOBZ  = 'N' or N <= 1 then LIWORK must be at least 1. */
00127 /*          If JOBZ  = 'V' and N > 1 then LIWORK must be at least 3+5*N. */
00128 
00129 /*          If LIWORK = -1, then a workspace query is assumed; the */
00130 /*          routine only calculates the optimal sizes of the WORK and */
00131 /*          IWORK arrays, returns these values as the first entries of */
00132 /*          the WORK and IWORK arrays, and no error message related to */
00133 /*          LWORK or LIWORK is issued by XERBLA. */
00134 
00135 /*  INFO    (output) INTEGER */
00136 /*          = 0:  successful exit */
00137 /*          < 0:  if INFO = -i, the i-th argument had an illegal value */
00138 /*          > 0:  if INFO = i, the algorithm failed to converge; i */
00139 /*                off-diagonal elements of E did not converge to zero. */
00140 
00141 /*  ===================================================================== */
00142 
00143 /*     .. Parameters .. */
00144 /*     .. */
00145 /*     .. Local Scalars .. */
00146 /*     .. */
00147 /*     .. External Functions .. */
00148 /*     .. */
00149 /*     .. External Subroutines .. */
00150 /*     .. */
00151 /*     .. Intrinsic Functions .. */
00152 /*     .. */
00153 /*     .. Executable Statements .. */
00154 
00155 /*     Test the input parameters. */
00156 
00157     /* Parameter adjustments */
00158     --d__;
00159     --e;
00160     z_dim1 = *ldz;
00161     z_offset = 1 + z_dim1;
00162     z__ -= z_offset;
00163     --work;
00164     --iwork;
00165 
00166     /* Function Body */
00167     wantz = lsame_(jobz, "V");
00168     lquery = *lwork == -1 || *liwork == -1;
00169 
00170     *info = 0;
00171     liwmin = 1;
00172     lwmin = 1;
00173     if (*n > 1 && wantz) {
00174 /* Computing 2nd power */
00175         i__1 = *n;
00176         lwmin = (*n << 2) + 1 + i__1 * i__1;
00177         liwmin = *n * 5 + 3;
00178     }
00179 
00180     if (! (wantz || lsame_(jobz, "N"))) {
00181         *info = -1;
00182     } else if (*n < 0) {
00183         *info = -2;
00184     } else if (*ldz < 1 || wantz && *ldz < *n) {
00185         *info = -6;
00186     }
00187 
00188     if (*info == 0) {
00189         work[1] = (real) lwmin;
00190         iwork[1] = liwmin;
00191 
00192         if (*lwork < lwmin && ! lquery) {
00193             *info = -8;
00194         } else if (*liwork < liwmin && ! lquery) {
00195             *info = -10;
00196         }
00197     }
00198 
00199     if (*info != 0) {
00200         i__1 = -(*info);
00201         xerbla_("SSTEVD", &i__1);
00202         return 0;
00203     } else if (lquery) {
00204         return 0;
00205     }
00206 
00207 /*     Quick return if possible */
00208 
00209     if (*n == 0) {
00210         return 0;
00211     }
00212 
00213     if (*n == 1) {
00214         if (wantz) {
00215             z__[z_dim1 + 1] = 1.f;
00216         }
00217         return 0;
00218     }
00219 
00220 /*     Get machine constants. */
00221 
00222     safmin = slamch_("Safe minimum");
00223     eps = slamch_("Precision");
00224     smlnum = safmin / eps;
00225     bignum = 1.f / smlnum;
00226     rmin = sqrt(smlnum);
00227     rmax = sqrt(bignum);
00228 
00229 /*     Scale matrix to allowable range, if necessary. */
00230 
00231     iscale = 0;
00232     tnrm = slanst_("M", n, &d__[1], &e[1]);
00233     if (tnrm > 0.f && tnrm < rmin) {
00234         iscale = 1;
00235         sigma = rmin / tnrm;
00236     } else if (tnrm > rmax) {
00237         iscale = 1;
00238         sigma = rmax / tnrm;
00239     }
00240     if (iscale == 1) {
00241         sscal_(n, &sigma, &d__[1], &c__1);
00242         i__1 = *n - 1;
00243         sscal_(&i__1, &sigma, &e[1], &c__1);
00244     }
00245 
00246 /*     For eigenvalues only, call SSTERF.  For eigenvalues and */
00247 /*     eigenvectors, call SSTEDC. */
00248 
00249     if (! wantz) {
00250         ssterf_(n, &d__[1], &e[1], info);
00251     } else {
00252         sstedc_("I", n, &d__[1], &e[1], &z__[z_offset], ldz, &work[1], lwork, 
00253                 &iwork[1], liwork, info);
00254     }
00255 
00256 /*     If matrix was scaled, then rescale eigenvalues appropriately. */
00257 
00258     if (iscale == 1) {
00259         r__1 = 1.f / sigma;
00260         sscal_(n, &r__1, &d__[1], &c__1);
00261     }
00262 
00263     work[1] = (real) lwmin;
00264     iwork[1] = liwmin;
00265 
00266     return 0;
00267 
00268 /*     End of SSTEVD */
00269 
00270 } /* sstevd_ */


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