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


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