sstev.c
Go to the documentation of this file.
00001 /* sstev.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 sstev_(char *jobz, integer *n, real *d__, real *e, real *
00021         z__, integer *ldz, real *work, integer *info)
00022 {
00023     /* System generated locals */
00024     integer z_dim1, z_offset, i__1;
00025     real r__1;
00026 
00027     /* Builtin functions */
00028     double sqrt(doublereal);
00029 
00030     /* Local variables */
00031     real eps;
00032     integer imax;
00033     real rmin, rmax, tnrm, sigma;
00034     extern logical lsame_(char *, char *);
00035     extern /* Subroutine */ int sscal_(integer *, real *, real *, integer *);
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 doublereal slanst_(char *, integer *, real *, real *);
00043     extern /* Subroutine */ int ssterf_(integer *, real *, real *, integer *);
00044     real smlnum;
00045     extern /* Subroutine */ int ssteqr_(char *, integer *, real *, real *, 
00046             real *, integer *, real *, integer *);
00047 
00048 
00049 /*  -- LAPACK driver routine (version 3.2) -- */
00050 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00051 /*     November 2006 */
00052 
00053 /*     .. Scalar Arguments .. */
00054 /*     .. */
00055 /*     .. Array Arguments .. */
00056 /*     .. */
00057 
00058 /*  Purpose */
00059 /*  ======= */
00060 
00061 /*  SSTEV computes all eigenvalues and, optionally, eigenvectors of a */
00062 /*  real symmetric tridiagonal matrix A. */
00063 
00064 /*  Arguments */
00065 /*  ========= */
00066 
00067 /*  JOBZ    (input) CHARACTER*1 */
00068 /*          = 'N':  Compute eigenvalues only; */
00069 /*          = 'V':  Compute eigenvalues and eigenvectors. */
00070 
00071 /*  N       (input) INTEGER */
00072 /*          The order of the matrix.  N >= 0. */
00073 
00074 /*  D       (input/output) REAL array, dimension (N) */
00075 /*          On entry, the n diagonal elements of the tridiagonal matrix */
00076 /*          A. */
00077 /*          On exit, if INFO = 0, the eigenvalues in ascending order. */
00078 
00079 /*  E       (input/output) REAL array, dimension (N-1) */
00080 /*          On entry, the (n-1) subdiagonal elements of the tridiagonal */
00081 /*          matrix A, stored in elements 1 to N-1 of E. */
00082 /*          On exit, the contents of E are destroyed. */
00083 
00084 /*  Z       (output) REAL array, dimension (LDZ, N) */
00085 /*          If JOBZ = 'V', then if INFO = 0, Z contains the orthonormal */
00086 /*          eigenvectors of the matrix A, with the i-th column of Z */
00087 /*          holding the eigenvector associated with D(i). */
00088 /*          If JOBZ = 'N', then Z is not referenced. */
00089 
00090 /*  LDZ     (input) INTEGER */
00091 /*          The leading dimension of the array Z.  LDZ >= 1, and if */
00092 /*          JOBZ = 'V', LDZ >= max(1,N). */
00093 
00094 /*  WORK    (workspace) REAL array, dimension (max(1,2*N-2)) */
00095 /*          If JOBZ = 'N', WORK is not referenced. */
00096 
00097 /*  INFO    (output) INTEGER */
00098 /*          = 0:  successful exit */
00099 /*          < 0:  if INFO = -i, the i-th argument had an illegal value */
00100 /*          > 0:  if INFO = i, the algorithm failed to converge; i */
00101 /*                off-diagonal elements of E did not converge to zero. */
00102 
00103 /*  ===================================================================== */
00104 
00105 /*     .. Parameters .. */
00106 /*     .. */
00107 /*     .. Local Scalars .. */
00108 /*     .. */
00109 /*     .. External Functions .. */
00110 /*     .. */
00111 /*     .. External Subroutines .. */
00112 /*     .. */
00113 /*     .. Intrinsic Functions .. */
00114 /*     .. */
00115 /*     .. Executable Statements .. */
00116 
00117 /*     Test the input parameters. */
00118 
00119     /* Parameter adjustments */
00120     --d__;
00121     --e;
00122     z_dim1 = *ldz;
00123     z_offset = 1 + z_dim1;
00124     z__ -= z_offset;
00125     --work;
00126 
00127     /* Function Body */
00128     wantz = lsame_(jobz, "V");
00129 
00130     *info = 0;
00131     if (! (wantz || lsame_(jobz, "N"))) {
00132         *info = -1;
00133     } else if (*n < 0) {
00134         *info = -2;
00135     } else if (*ldz < 1 || wantz && *ldz < *n) {
00136         *info = -6;
00137     }
00138 
00139     if (*info != 0) {
00140         i__1 = -(*info);
00141         xerbla_("SSTEV ", &i__1);
00142         return 0;
00143     }
00144 
00145 /*     Quick return if possible */
00146 
00147     if (*n == 0) {
00148         return 0;
00149     }
00150 
00151     if (*n == 1) {
00152         if (wantz) {
00153             z__[z_dim1 + 1] = 1.f;
00154         }
00155         return 0;
00156     }
00157 
00158 /*     Get machine constants. */
00159 
00160     safmin = slamch_("Safe minimum");
00161     eps = slamch_("Precision");
00162     smlnum = safmin / eps;
00163     bignum = 1.f / smlnum;
00164     rmin = sqrt(smlnum);
00165     rmax = sqrt(bignum);
00166 
00167 /*     Scale matrix to allowable range, if necessary. */
00168 
00169     iscale = 0;
00170     tnrm = slanst_("M", n, &d__[1], &e[1]);
00171     if (tnrm > 0.f && tnrm < rmin) {
00172         iscale = 1;
00173         sigma = rmin / tnrm;
00174     } else if (tnrm > rmax) {
00175         iscale = 1;
00176         sigma = rmax / tnrm;
00177     }
00178     if (iscale == 1) {
00179         sscal_(n, &sigma, &d__[1], &c__1);
00180         i__1 = *n - 1;
00181         sscal_(&i__1, &sigma, &e[1], &c__1);
00182     }
00183 
00184 /*     For eigenvalues only, call SSTERF.  For eigenvalues and */
00185 /*     eigenvectors, call SSTEQR. */
00186 
00187     if (! wantz) {
00188         ssterf_(n, &d__[1], &e[1], info);
00189     } else {
00190         ssteqr_("I", n, &d__[1], &e[1], &z__[z_offset], ldz, &work[1], info);
00191     }
00192 
00193 /*     If matrix was scaled, then rescale eigenvalues appropriately. */
00194 
00195     if (iscale == 1) {
00196         if (*info == 0) {
00197             imax = *n;
00198         } else {
00199             imax = *info - 1;
00200         }
00201         r__1 = 1.f / sigma;
00202         sscal_(&imax, &r__1, &d__[1], &c__1);
00203     }
00204 
00205     return 0;
00206 
00207 /*     End of SSTEV */
00208 
00209 } /* sstev_ */


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