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 doublereal c_b11 = 1.;
00019 static integer c__1 = 1;
00020
00021 int zhbev_(char *jobz, char *uplo, integer *n, integer *kd,
00022 doublecomplex *ab, integer *ldab, doublereal *w, doublecomplex *z__,
00023 integer *ldz, doublecomplex *work, doublereal *rwork, integer *info)
00024 {
00025
00026 integer ab_dim1, ab_offset, z_dim1, z_offset, i__1;
00027 doublereal d__1;
00028
00029
00030 double sqrt(doublereal);
00031
00032
00033 doublereal eps;
00034 integer inde;
00035 doublereal anrm;
00036 integer imax;
00037 doublereal rmin, rmax;
00038 extern int dscal_(integer *, doublereal *, doublereal *,
00039 integer *);
00040 doublereal sigma;
00041 extern logical lsame_(char *, char *);
00042 integer iinfo;
00043 logical lower, wantz;
00044 extern doublereal dlamch_(char *);
00045 integer iscale;
00046 doublereal safmin;
00047 extern doublereal zlanhb_(char *, char *, integer *, integer *,
00048 doublecomplex *, integer *, doublereal *);
00049 extern int xerbla_(char *, integer *);
00050 doublereal bignum;
00051 extern int dsterf_(integer *, doublereal *, doublereal *,
00052 integer *), zlascl_(char *, integer *, integer *, doublereal *,
00053 doublereal *, integer *, integer *, doublecomplex *, integer *,
00054 integer *), zhbtrd_(char *, char *, integer *, integer *,
00055 doublecomplex *, integer *, doublereal *, doublereal *,
00056 doublecomplex *, integer *, doublecomplex *, integer *);
00057 integer indrwk;
00058 doublereal smlnum;
00059 extern int zsteqr_(char *, integer *, doublereal *,
00060 doublereal *, doublecomplex *, integer *, doublereal *, integer *);
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
00153
00154
00155 ab_dim1 = *ldab;
00156 ab_offset = 1 + ab_dim1;
00157 ab -= ab_offset;
00158 --w;
00159 z_dim1 = *ldz;
00160 z_offset = 1 + z_dim1;
00161 z__ -= z_offset;
00162 --work;
00163 --rwork;
00164
00165
00166 wantz = lsame_(jobz, "V");
00167 lower = lsame_(uplo, "L");
00168
00169 *info = 0;
00170 if (! (wantz || lsame_(jobz, "N"))) {
00171 *info = -1;
00172 } else if (! (lower || lsame_(uplo, "U"))) {
00173 *info = -2;
00174 } else if (*n < 0) {
00175 *info = -3;
00176 } else if (*kd < 0) {
00177 *info = -4;
00178 } else if (*ldab < *kd + 1) {
00179 *info = -6;
00180 } else if (*ldz < 1 || wantz && *ldz < *n) {
00181 *info = -9;
00182 }
00183
00184 if (*info != 0) {
00185 i__1 = -(*info);
00186 xerbla_("ZHBEV ", &i__1);
00187 return 0;
00188 }
00189
00190
00191
00192 if (*n == 0) {
00193 return 0;
00194 }
00195
00196 if (*n == 1) {
00197 if (lower) {
00198 i__1 = ab_dim1 + 1;
00199 w[1] = ab[i__1].r;
00200 } else {
00201 i__1 = *kd + 1 + ab_dim1;
00202 w[1] = ab[i__1].r;
00203 }
00204 if (wantz) {
00205 i__1 = z_dim1 + 1;
00206 z__[i__1].r = 1., z__[i__1].i = 0.;
00207 }
00208 return 0;
00209 }
00210
00211
00212
00213 safmin = dlamch_("Safe minimum");
00214 eps = dlamch_("Precision");
00215 smlnum = safmin / eps;
00216 bignum = 1. / smlnum;
00217 rmin = sqrt(smlnum);
00218 rmax = sqrt(bignum);
00219
00220
00221
00222 anrm = zlanhb_("M", uplo, n, kd, &ab[ab_offset], ldab, &rwork[1]);
00223 iscale = 0;
00224 if (anrm > 0. && anrm < rmin) {
00225 iscale = 1;
00226 sigma = rmin / anrm;
00227 } else if (anrm > rmax) {
00228 iscale = 1;
00229 sigma = rmax / anrm;
00230 }
00231 if (iscale == 1) {
00232 if (lower) {
00233 zlascl_("B", kd, kd, &c_b11, &sigma, n, n, &ab[ab_offset], ldab,
00234 info);
00235 } else {
00236 zlascl_("Q", kd, kd, &c_b11, &sigma, n, n, &ab[ab_offset], ldab,
00237 info);
00238 }
00239 }
00240
00241
00242
00243 inde = 1;
00244 zhbtrd_(jobz, uplo, n, kd, &ab[ab_offset], ldab, &w[1], &rwork[inde], &
00245 z__[z_offset], ldz, &work[1], &iinfo);
00246
00247
00248
00249 if (! wantz) {
00250 dsterf_(n, &w[1], &rwork[inde], info);
00251 } else {
00252 indrwk = inde + *n;
00253 zsteqr_(jobz, n, &w[1], &rwork[inde], &z__[z_offset], ldz, &rwork[
00254 indrwk], info);
00255 }
00256
00257
00258
00259 if (iscale == 1) {
00260 if (*info == 0) {
00261 imax = *n;
00262 } else {
00263 imax = *info - 1;
00264 }
00265 d__1 = 1. / sigma;
00266 dscal_(&imax, &d__1, &w[1], &c__1);
00267 }
00268
00269 return 0;
00270
00271
00272
00273 }