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


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