zhpev.c
Go to the documentation of this file.
00001 /* zhpev.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 zhpev_(char *jobz, char *uplo, integer *n, doublecomplex 
00021         *ap, doublereal *w, doublecomplex *z__, integer *ldz, doublecomplex *
00022         work, doublereal *rwork, 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 *), zdscal_(
00047             integer *, doublereal *, doublecomplex *, integer *);
00048     doublereal bignum;
00049     integer indtau;
00050     extern /* Subroutine */ int dsterf_(integer *, doublereal *, doublereal *, 
00051              integer *);
00052     extern doublereal zlanhp_(char *, char *, integer *, doublecomplex *, 
00053             doublereal *);
00054     integer indrwk, indwrk;
00055     doublereal smlnum;
00056     extern /* Subroutine */ int zhptrd_(char *, integer *, doublecomplex *, 
00057             doublereal *, doublereal *, doublecomplex *, integer *), 
00058             zsteqr_(char *, integer *, doublereal *, doublereal *, 
00059             doublecomplex *, integer *, doublereal *, integer *), 
00060             zupgtr_(char *, integer *, doublecomplex *, doublecomplex *, 
00061             doublecomplex *, integer *, doublecomplex *, integer *);
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 /*  ZHPEV computes all the eigenvalues and, optionally, eigenvectors of a */
00077 /*  complex Hermitian matrix in packed storage. */
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 /*  AP      (input/output) COMPLEX*16 array, dimension (N*(N+1)/2) */
00094 /*          On entry, the upper or lower triangle of the Hermitian matrix */
00095 /*          A, packed columnwise in a linear array.  The j-th column of A */
00096 /*          is stored in the array AP as follows: */
00097 /*          if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; */
00098 /*          if UPLO = 'L', AP(i + (j-1)*(2*n-j)/2) = A(i,j) for j<=i<=n. */
00099 
00100 /*          On exit, AP is overwritten by values generated during the */
00101 /*          reduction to tridiagonal form.  If UPLO = 'U', the diagonal */
00102 /*          and first superdiagonal of the tridiagonal matrix T overwrite */
00103 /*          the corresponding elements of A, and if UPLO = 'L', the */
00104 /*          diagonal and first subdiagonal of T overwrite the */
00105 /*          corresponding elements of A. */
00106 
00107 /*  W       (output) DOUBLE PRECISION array, dimension (N) */
00108 /*          If INFO = 0, the eigenvalues in ascending order. */
00109 
00110 /*  Z       (output) COMPLEX*16 array, dimension (LDZ, N) */
00111 /*          If JOBZ = 'V', then if INFO = 0, Z contains the orthonormal */
00112 /*          eigenvectors of the matrix A, with the i-th column of Z */
00113 /*          holding the eigenvector associated with W(i). */
00114 /*          If JOBZ = 'N', then Z is not referenced. */
00115 
00116 /*  LDZ     (input) INTEGER */
00117 /*          The leading dimension of the array Z.  LDZ >= 1, and if */
00118 /*          JOBZ = 'V', LDZ >= max(1,N). */
00119 
00120 /*  WORK    (workspace) COMPLEX*16 array, dimension (max(1, 2*N-1)) */
00121 
00122 /*  RWORK   (workspace) DOUBLE PRECISION array, dimension (max(1, 3*N-2)) */
00123 
00124 /*  INFO    (output) INTEGER */
00125 /*          = 0:  successful exit. */
00126 /*          < 0:  if INFO = -i, the i-th argument had an illegal value. */
00127 /*          > 0:  if INFO = i, the algorithm failed to converge; i */
00128 /*                off-diagonal elements of an intermediate tridiagonal */
00129 /*                form did not converge to zero. */
00130 
00131 /*  ===================================================================== */
00132 
00133 /*     .. Parameters .. */
00134 /*     .. */
00135 /*     .. Local Scalars .. */
00136 /*     .. */
00137 /*     .. External Functions .. */
00138 /*     .. */
00139 /*     .. External Subroutines .. */
00140 /*     .. */
00141 /*     .. Intrinsic Functions .. */
00142 /*     .. */
00143 /*     .. Executable Statements .. */
00144 
00145 /*     Test the input parameters. */
00146 
00147     /* Parameter adjustments */
00148     --ap;
00149     --w;
00150     z_dim1 = *ldz;
00151     z_offset = 1 + z_dim1;
00152     z__ -= z_offset;
00153     --work;
00154     --rwork;
00155 
00156     /* Function Body */
00157     wantz = lsame_(jobz, "V");
00158 
00159     *info = 0;
00160     if (! (wantz || lsame_(jobz, "N"))) {
00161         *info = -1;
00162     } else if (! (lsame_(uplo, "L") || lsame_(uplo, 
00163             "U"))) {
00164         *info = -2;
00165     } else if (*n < 0) {
00166         *info = -3;
00167     } else if (*ldz < 1 || wantz && *ldz < *n) {
00168         *info = -7;
00169     }
00170 
00171     if (*info != 0) {
00172         i__1 = -(*info);
00173         xerbla_("ZHPEV ", &i__1);
00174         return 0;
00175     }
00176 
00177 /*     Quick return if possible */
00178 
00179     if (*n == 0) {
00180         return 0;
00181     }
00182 
00183     if (*n == 1) {
00184         w[1] = ap[1].r;
00185         rwork[1] = 1.;
00186         if (wantz) {
00187             i__1 = z_dim1 + 1;
00188             z__[i__1].r = 1., z__[i__1].i = 0.;
00189         }
00190         return 0;
00191     }
00192 
00193 /*     Get machine constants. */
00194 
00195     safmin = dlamch_("Safe minimum");
00196     eps = dlamch_("Precision");
00197     smlnum = safmin / eps;
00198     bignum = 1. / smlnum;
00199     rmin = sqrt(smlnum);
00200     rmax = sqrt(bignum);
00201 
00202 /*     Scale matrix to allowable range, if necessary. */
00203 
00204     anrm = zlanhp_("M", uplo, n, &ap[1], &rwork[1]);
00205     iscale = 0;
00206     if (anrm > 0. && anrm < rmin) {
00207         iscale = 1;
00208         sigma = rmin / anrm;
00209     } else if (anrm > rmax) {
00210         iscale = 1;
00211         sigma = rmax / anrm;
00212     }
00213     if (iscale == 1) {
00214         i__1 = *n * (*n + 1) / 2;
00215         zdscal_(&i__1, &sigma, &ap[1], &c__1);
00216     }
00217 
00218 /*     Call ZHPTRD to reduce Hermitian packed matrix to tridiagonal form. */
00219 
00220     inde = 1;
00221     indtau = 1;
00222     zhptrd_(uplo, n, &ap[1], &w[1], &rwork[inde], &work[indtau], &iinfo);
00223 
00224 /*     For eigenvalues only, call DSTERF.  For eigenvectors, first call */
00225 /*     ZUPGTR to generate the orthogonal matrix, then call ZSTEQR. */
00226 
00227     if (! wantz) {
00228         dsterf_(n, &w[1], &rwork[inde], info);
00229     } else {
00230         indwrk = indtau + *n;
00231         zupgtr_(uplo, n, &ap[1], &work[indtau], &z__[z_offset], ldz, &work[
00232                 indwrk], &iinfo);
00233         indrwk = inde + *n;
00234         zsteqr_(jobz, n, &w[1], &rwork[inde], &z__[z_offset], ldz, &rwork[
00235                 indrwk], info);
00236     }
00237 
00238 /*     If matrix was scaled, then rescale eigenvalues appropriately. */
00239 
00240     if (iscale == 1) {
00241         if (*info == 0) {
00242             imax = *n;
00243         } else {
00244             imax = *info - 1;
00245         }
00246         d__1 = 1. / sigma;
00247         dscal_(&imax, &d__1, &w[1], &c__1);
00248     }
00249 
00250     return 0;
00251 
00252 /*     End of ZHPEV */
00253 
00254 } /* zhpev_ */


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