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


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