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


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:55:49