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 chpev_(char *jobz, char *uplo, integer *n, complex *ap,
00021 real *w, complex *z__, integer *ldz, complex *work, real *rwork,
00022 integer *info)
00023 {
00024
00025 integer z_dim1, z_offset, i__1;
00026 real r__1;
00027
00028
00029 double sqrt(doublereal);
00030
00031
00032 real eps;
00033 integer inde;
00034 real anrm;
00035 integer imax;
00036 real rmin, rmax, sigma;
00037 extern logical lsame_(char *, char *);
00038 integer iinfo;
00039 extern int sscal_(integer *, real *, real *, integer *);
00040 logical wantz;
00041 integer iscale;
00042 extern doublereal clanhp_(char *, char *, integer *, complex *, real *), slamch_(char *);
00043 extern int csscal_(integer *, real *, complex *, integer
00044 *);
00045 real safmin;
00046 extern int xerbla_(char *, integer *);
00047 real bignum;
00048 integer indtau;
00049 extern int chptrd_(char *, integer *, complex *, real *,
00050 real *, complex *, integer *);
00051 integer indrwk, indwrk;
00052 extern int csteqr_(char *, integer *, real *, real *,
00053 complex *, integer *, real *, integer *), cupgtr_(char *,
00054 integer *, complex *, complex *, complex *, integer *, complex *,
00055 integer *), ssterf_(integer *, real *, real *, integer *);
00056 real smlnum;
00057
00058
00059
00060
00061
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 --ap;
00144 --w;
00145 z_dim1 = *ldz;
00146 z_offset = 1 + z_dim1;
00147 z__ -= z_offset;
00148 --work;
00149 --rwork;
00150
00151
00152 wantz = lsame_(jobz, "V");
00153
00154 *info = 0;
00155 if (! (wantz || lsame_(jobz, "N"))) {
00156 *info = -1;
00157 } else if (! (lsame_(uplo, "L") || lsame_(uplo,
00158 "U"))) {
00159 *info = -2;
00160 } else if (*n < 0) {
00161 *info = -3;
00162 } else if (*ldz < 1 || wantz && *ldz < *n) {
00163 *info = -7;
00164 }
00165
00166 if (*info != 0) {
00167 i__1 = -(*info);
00168 xerbla_("CHPEV ", &i__1);
00169 return 0;
00170 }
00171
00172
00173
00174 if (*n == 0) {
00175 return 0;
00176 }
00177
00178 if (*n == 1) {
00179 w[1] = ap[1].r;
00180 rwork[1] = 1.f;
00181 if (wantz) {
00182 i__1 = z_dim1 + 1;
00183 z__[i__1].r = 1.f, z__[i__1].i = 0.f;
00184 }
00185 return 0;
00186 }
00187
00188
00189
00190 safmin = slamch_("Safe minimum");
00191 eps = slamch_("Precision");
00192 smlnum = safmin / eps;
00193 bignum = 1.f / smlnum;
00194 rmin = sqrt(smlnum);
00195 rmax = sqrt(bignum);
00196
00197
00198
00199 anrm = clanhp_("M", uplo, n, &ap[1], &rwork[1]);
00200 iscale = 0;
00201 if (anrm > 0.f && anrm < rmin) {
00202 iscale = 1;
00203 sigma = rmin / anrm;
00204 } else if (anrm > rmax) {
00205 iscale = 1;
00206 sigma = rmax / anrm;
00207 }
00208 if (iscale == 1) {
00209 i__1 = *n * (*n + 1) / 2;
00210 csscal_(&i__1, &sigma, &ap[1], &c__1);
00211 }
00212
00213
00214
00215 inde = 1;
00216 indtau = 1;
00217 chptrd_(uplo, n, &ap[1], &w[1], &rwork[inde], &work[indtau], &iinfo);
00218
00219
00220
00221
00222 if (! wantz) {
00223 ssterf_(n, &w[1], &rwork[inde], info);
00224 } else {
00225 indwrk = indtau + *n;
00226 cupgtr_(uplo, n, &ap[1], &work[indtau], &z__[z_offset], ldz, &work[
00227 indwrk], &iinfo);
00228 indrwk = inde + *n;
00229 csteqr_(jobz, n, &w[1], &rwork[inde], &z__[z_offset], ldz, &rwork[
00230 indrwk], info);
00231 }
00232
00233
00234
00235 if (iscale == 1) {
00236 if (*info == 0) {
00237 imax = *n;
00238 } else {
00239 imax = *info - 1;
00240 }
00241 r__1 = 1.f / sigma;
00242 sscal_(&imax, &r__1, &w[1], &c__1);
00243 }
00244
00245 return 0;
00246
00247
00248
00249 }