00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015
00016
00017
00018 static integer c__1 = 1;
00019
00020 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
00025 integer z_dim1, z_offset, i__1;
00026 doublereal d__1;
00027
00028
00029 double sqrt(doublereal);
00030
00031
00032 doublereal eps;
00033 integer inde;
00034 doublereal anrm;
00035 integer imax;
00036 doublereal rmin, rmax;
00037 extern 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 int xerbla_(char *, integer *), zdscal_(
00047 integer *, doublereal *, doublecomplex *, integer *);
00048 doublereal bignum;
00049 integer indtau;
00050 extern 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 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
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148 --ap;
00149 --w;
00150 z_dim1 = *ldz;
00151 z_offset = 1 + z_dim1;
00152 z__ -= z_offset;
00153 --work;
00154 --rwork;
00155
00156
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
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
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
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
00219
00220 inde = 1;
00221 indtau = 1;
00222 zhptrd_(uplo, n, &ap[1], &w[1], &rwork[inde], &work[indtau], &iinfo);
00223
00224
00225
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
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
00253
00254 }