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


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