dspev.c
Go to the documentation of this file.
00001 /* dspev.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 dspev_(char *jobz, char *uplo, integer *n, doublereal *
00021         ap, doublereal *w, 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 inde;
00034     doublereal anrm;
00035     integer imax;
00036     doublereal rmin, rmax;
00037     extern /* Subroutine */ int dscal_(integer *, doublereal *, doublereal *, 
00038             integer *);
00039     doublereal sigma;
00040     extern logical lsame_(char *, char *);
00041     integer iinfo;
00042     logical wantz;
00043     extern doublereal dlamch_(char *);
00044     integer iscale;
00045     doublereal safmin;
00046     extern /* Subroutine */ int xerbla_(char *, integer *);
00047     doublereal bignum;
00048     extern doublereal dlansp_(char *, char *, integer *, doublereal *, 
00049             doublereal *);
00050     integer indtau;
00051     extern /* Subroutine */ int dsterf_(integer *, doublereal *, doublereal *, 
00052              integer *);
00053     integer indwrk;
00054     extern /* Subroutine */ int dopgtr_(char *, integer *, doublereal *, 
00055             doublereal *, doublereal *, integer *, doublereal *, integer *), dsptrd_(char *, integer *, doublereal *, doublereal *, 
00056             doublereal *, doublereal *, integer *), dsteqr_(char *, 
00057             integer *, doublereal *, doublereal *, doublereal *, integer *, 
00058             doublereal *, integer *);
00059     doublereal smlnum;
00060 
00061 
00062 /*  -- LAPACK driver routine (version 3.2) -- */
00063 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00064 /*     November 2006 */
00065 
00066 /*     .. Scalar Arguments .. */
00067 /*     .. */
00068 /*     .. Array Arguments .. */
00069 /*     .. */
00070 
00071 /*  Purpose */
00072 /*  ======= */
00073 
00074 /*  DSPEV computes all the eigenvalues and, optionally, eigenvectors of a */
00075 /*  real symmetric matrix A in packed storage. */
00076 
00077 /*  Arguments */
00078 /*  ========= */
00079 
00080 /*  JOBZ    (input) CHARACTER*1 */
00081 /*          = 'N':  Compute eigenvalues only; */
00082 /*          = 'V':  Compute eigenvalues and eigenvectors. */
00083 
00084 /*  UPLO    (input) CHARACTER*1 */
00085 /*          = 'U':  Upper triangle of A is stored; */
00086 /*          = 'L':  Lower triangle of A is stored. */
00087 
00088 /*  N       (input) INTEGER */
00089 /*          The order of the matrix A.  N >= 0. */
00090 
00091 /*  AP      (input/output) DOUBLE PRECISION array, dimension (N*(N+1)/2) */
00092 /*          On entry, the upper or lower triangle of the symmetric matrix */
00093 /*          A, packed columnwise in a linear array.  The j-th column of A */
00094 /*          is stored in the array AP as follows: */
00095 /*          if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; */
00096 /*          if UPLO = 'L', AP(i + (j-1)*(2*n-j)/2) = A(i,j) for j<=i<=n. */
00097 
00098 /*          On exit, AP is overwritten by values generated during the */
00099 /*          reduction to tridiagonal form.  If UPLO = 'U', the diagonal */
00100 /*          and first superdiagonal of the tridiagonal matrix T overwrite */
00101 /*          the corresponding elements of A, and if UPLO = 'L', the */
00102 /*          diagonal and first subdiagonal of T overwrite the */
00103 /*          corresponding elements of A. */
00104 
00105 /*  W       (output) DOUBLE PRECISION array, dimension (N) */
00106 /*          If INFO = 0, the eigenvalues in ascending order. */
00107 
00108 /*  Z       (output) DOUBLE PRECISION array, dimension (LDZ, N) */
00109 /*          If JOBZ = 'V', then if INFO = 0, Z contains the orthonormal */
00110 /*          eigenvectors of the matrix A, with the i-th column of Z */
00111 /*          holding the eigenvector associated with W(i). */
00112 /*          If JOBZ = 'N', then Z is not referenced. */
00113 
00114 /*  LDZ     (input) INTEGER */
00115 /*          The leading dimension of the array Z.  LDZ >= 1, and if */
00116 /*          JOBZ = 'V', LDZ >= max(1,N). */
00117 
00118 /*  WORK    (workspace) DOUBLE PRECISION array, dimension (3*N) */
00119 
00120 /*  INFO    (output) INTEGER */
00121 /*          = 0:  successful exit. */
00122 /*          < 0:  if INFO = -i, the i-th argument had an illegal value. */
00123 /*          > 0:  if INFO = i, the algorithm failed to converge; i */
00124 /*                off-diagonal elements of an intermediate tridiagonal */
00125 /*                form did not converge to zero. */
00126 
00127 /*  ===================================================================== */
00128 
00129 /*     .. Parameters .. */
00130 /*     .. */
00131 /*     .. Local Scalars .. */
00132 /*     .. */
00133 /*     .. External Functions .. */
00134 /*     .. */
00135 /*     .. External Subroutines .. */
00136 /*     .. */
00137 /*     .. Intrinsic Functions .. */
00138 /*     .. */
00139 /*     .. Executable Statements .. */
00140 
00141 /*     Test the input parameters. */
00142 
00143     /* Parameter adjustments */
00144     --ap;
00145     --w;
00146     z_dim1 = *ldz;
00147     z_offset = 1 + z_dim1;
00148     z__ -= z_offset;
00149     --work;
00150 
00151     /* Function Body */
00152     wantz = lsame_(jobz, "V");
00153 
00154     *info = 0;
00155     if (! (wantz || lsame_(jobz, "N"))) {
00156         *info = -1;
00157     } else if (! (lsame_(uplo, "U") || lsame_(uplo, 
00158             "L"))) {
00159         *info = -2;
00160     } else if (*n < 0) {
00161         *info = -3;
00162     } else if (*ldz < 1 || wantz && *ldz < *n) {
00163         *info = -7;
00164     }
00165 
00166     if (*info != 0) {
00167         i__1 = -(*info);
00168         xerbla_("DSPEV ", &i__1);
00169         return 0;
00170     }
00171 
00172 /*     Quick return if possible */
00173 
00174     if (*n == 0) {
00175         return 0;
00176     }
00177 
00178     if (*n == 1) {
00179         w[1] = ap[1];
00180         if (wantz) {
00181             z__[z_dim1 + 1] = 1.;
00182         }
00183         return 0;
00184     }
00185 
00186 /*     Get machine constants. */
00187 
00188     safmin = dlamch_("Safe minimum");
00189     eps = dlamch_("Precision");
00190     smlnum = safmin / eps;
00191     bignum = 1. / smlnum;
00192     rmin = sqrt(smlnum);
00193     rmax = sqrt(bignum);
00194 
00195 /*     Scale matrix to allowable range, if necessary. */
00196 
00197     anrm = dlansp_("M", uplo, n, &ap[1], &work[1]);
00198     iscale = 0;
00199     if (anrm > 0. && anrm < rmin) {
00200         iscale = 1;
00201         sigma = rmin / anrm;
00202     } else if (anrm > rmax) {
00203         iscale = 1;
00204         sigma = rmax / anrm;
00205     }
00206     if (iscale == 1) {
00207         i__1 = *n * (*n + 1) / 2;
00208         dscal_(&i__1, &sigma, &ap[1], &c__1);
00209     }
00210 
00211 /*     Call DSPTRD to reduce symmetric packed matrix to tridiagonal form. */
00212 
00213     inde = 1;
00214     indtau = inde + *n;
00215     dsptrd_(uplo, n, &ap[1], &w[1], &work[inde], &work[indtau], &iinfo);
00216 
00217 /*     For eigenvalues only, call DSTERF.  For eigenvectors, first call */
00218 /*     DOPGTR to generate the orthogonal matrix, then call DSTEQR. */
00219 
00220     if (! wantz) {
00221         dsterf_(n, &w[1], &work[inde], info);
00222     } else {
00223         indwrk = indtau + *n;
00224         dopgtr_(uplo, n, &ap[1], &work[indtau], &z__[z_offset], ldz, &work[
00225                 indwrk], &iinfo);
00226         dsteqr_(jobz, n, &w[1], &work[inde], &z__[z_offset], ldz, &work[
00227                 indtau], info);
00228     }
00229 
00230 /*     If matrix was scaled, then rescale eigenvalues appropriately. */
00231 
00232     if (iscale == 1) {
00233         if (*info == 0) {
00234             imax = *n;
00235         } else {
00236             imax = *info - 1;
00237         }
00238         d__1 = 1. / sigma;
00239         dscal_(&imax, &d__1, &w[1], &c__1);
00240     }
00241 
00242     return 0;
00243 
00244 /*     End of DSPEV */
00245 
00246 } /* dspev_ */


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