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 real c_b11 = 1.f;
00019 static integer c__1 = 1;
00020
00021 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
00026 integer ab_dim1, ab_offset, z_dim1, z_offset, i__1;
00027 real r__1;
00028
00029
00030 double sqrt(doublereal);
00031
00032
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 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 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 int xerbla_(char *, integer *);
00052 real bignum;
00053 integer indrwk;
00054 extern int csteqr_(char *, integer *, real *, real *,
00055 complex *, integer *, real *, integer *), ssterf_(integer
00056 *, real *, real *, integer *);
00057 real smlnum;
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
00144
00145
00146
00147
00148
00149
00150
00151
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
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
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
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
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
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
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
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
00269
00270 }