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 doublecomplex c_b1 = {0.,0.};
00019 static doublecomplex c_b2 = {1.,0.};
00020 static integer c__1 = 1;
00021
00022 int zhbgvx_(char *jobz, char *range, char *uplo, integer *n,
00023 integer *ka, integer *kb, doublecomplex *ab, integer *ldab,
00024 doublecomplex *bb, integer *ldbb, doublecomplex *q, integer *ldq,
00025 doublereal *vl, doublereal *vu, integer *il, integer *iu, doublereal *
00026 abstol, integer *m, doublereal *w, doublecomplex *z__, integer *ldz,
00027 doublecomplex *work, doublereal *rwork, integer *iwork, integer *
00028 ifail, integer *info)
00029 {
00030
00031 integer ab_dim1, ab_offset, bb_dim1, bb_offset, q_dim1, q_offset, z_dim1,
00032 z_offset, i__1, i__2;
00033
00034
00035 integer i__, j, jj;
00036 doublereal tmp1;
00037 integer indd, inde;
00038 char vect[1];
00039 logical test;
00040 integer itmp1, indee;
00041 extern logical lsame_(char *, char *);
00042 integer iinfo;
00043 char order[1];
00044 extern int dcopy_(integer *, doublereal *, integer *,
00045 doublereal *, integer *), zgemv_(char *, integer *, integer *,
00046 doublecomplex *, doublecomplex *, integer *, doublecomplex *,
00047 integer *, doublecomplex *, doublecomplex *, integer *);
00048 logical upper, wantz;
00049 extern int zcopy_(integer *, doublecomplex *, integer *,
00050 doublecomplex *, integer *), zswap_(integer *, doublecomplex *,
00051 integer *, doublecomplex *, integer *);
00052 logical alleig, indeig;
00053 integer indibl;
00054 logical valeig;
00055 extern int xerbla_(char *, integer *);
00056 integer indiwk, indisp;
00057 extern int dsterf_(integer *, doublereal *, doublereal *,
00058 integer *), dstebz_(char *, char *, integer *, doublereal *,
00059 doublereal *, integer *, integer *, doublereal *, doublereal *,
00060 doublereal *, integer *, integer *, doublereal *, integer *,
00061 integer *, doublereal *, integer *, integer *),
00062 zhbtrd_(char *, char *, integer *, integer *, doublecomplex *,
00063 integer *, doublereal *, doublereal *, doublecomplex *, integer *,
00064 doublecomplex *, integer *);
00065 integer indrwk, indwrk;
00066 extern int zhbgst_(char *, char *, integer *, integer *,
00067 integer *, doublecomplex *, integer *, doublecomplex *, integer *,
00068 doublecomplex *, integer *, doublecomplex *, doublereal *,
00069 integer *), zlacpy_(char *, integer *, integer *,
00070 doublecomplex *, integer *, doublecomplex *, integer *);
00071 integer nsplit;
00072 extern int zpbstf_(char *, integer *, integer *,
00073 doublecomplex *, integer *, integer *), zstein_(integer *,
00074 doublereal *, doublereal *, integer *, doublereal *, integer *,
00075 integer *, doublecomplex *, integer *, doublereal *, integer *,
00076 integer *, integer *), zsteqr_(char *, integer *, doublereal *,
00077 doublereal *, doublecomplex *, integer *, doublereal *, integer *);
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
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260 ab_dim1 = *ldab;
00261 ab_offset = 1 + ab_dim1;
00262 ab -= ab_offset;
00263 bb_dim1 = *ldbb;
00264 bb_offset = 1 + bb_dim1;
00265 bb -= bb_offset;
00266 q_dim1 = *ldq;
00267 q_offset = 1 + q_dim1;
00268 q -= q_offset;
00269 --w;
00270 z_dim1 = *ldz;
00271 z_offset = 1 + z_dim1;
00272 z__ -= z_offset;
00273 --work;
00274 --rwork;
00275 --iwork;
00276 --ifail;
00277
00278
00279 wantz = lsame_(jobz, "V");
00280 upper = lsame_(uplo, "U");
00281 alleig = lsame_(range, "A");
00282 valeig = lsame_(range, "V");
00283 indeig = lsame_(range, "I");
00284
00285 *info = 0;
00286 if (! (wantz || lsame_(jobz, "N"))) {
00287 *info = -1;
00288 } else if (! (alleig || valeig || indeig)) {
00289 *info = -2;
00290 } else if (! (upper || lsame_(uplo, "L"))) {
00291 *info = -3;
00292 } else if (*n < 0) {
00293 *info = -4;
00294 } else if (*ka < 0) {
00295 *info = -5;
00296 } else if (*kb < 0 || *kb > *ka) {
00297 *info = -6;
00298 } else if (*ldab < *ka + 1) {
00299 *info = -8;
00300 } else if (*ldbb < *kb + 1) {
00301 *info = -10;
00302 } else if (*ldq < 1 || wantz && *ldq < *n) {
00303 *info = -12;
00304 } else {
00305 if (valeig) {
00306 if (*n > 0 && *vu <= *vl) {
00307 *info = -14;
00308 }
00309 } else if (indeig) {
00310 if (*il < 1 || *il > max(1,*n)) {
00311 *info = -15;
00312 } else if (*iu < min(*n,*il) || *iu > *n) {
00313 *info = -16;
00314 }
00315 }
00316 }
00317 if (*info == 0) {
00318 if (*ldz < 1 || wantz && *ldz < *n) {
00319 *info = -21;
00320 }
00321 }
00322
00323 if (*info != 0) {
00324 i__1 = -(*info);
00325 xerbla_("ZHBGVX", &i__1);
00326 return 0;
00327 }
00328
00329
00330
00331 *m = 0;
00332 if (*n == 0) {
00333 return 0;
00334 }
00335
00336
00337
00338 zpbstf_(uplo, n, kb, &bb[bb_offset], ldbb, info);
00339 if (*info != 0) {
00340 *info = *n + *info;
00341 return 0;
00342 }
00343
00344
00345
00346 zhbgst_(jobz, uplo, n, ka, kb, &ab[ab_offset], ldab, &bb[bb_offset], ldbb,
00347 &q[q_offset], ldq, &work[1], &rwork[1], &iinfo);
00348
00349
00350
00351
00352 indd = 1;
00353 inde = indd + *n;
00354 indrwk = inde + *n;
00355 indwrk = 1;
00356 if (wantz) {
00357 *(unsigned char *)vect = 'U';
00358 } else {
00359 *(unsigned char *)vect = 'N';
00360 }
00361 zhbtrd_(vect, uplo, n, ka, &ab[ab_offset], ldab, &rwork[indd], &rwork[
00362 inde], &q[q_offset], ldq, &work[indwrk], &iinfo);
00363
00364
00365
00366
00367
00368 test = FALSE_;
00369 if (indeig) {
00370 if (*il == 1 && *iu == *n) {
00371 test = TRUE_;
00372 }
00373 }
00374 if ((alleig || test) && *abstol <= 0.) {
00375 dcopy_(n, &rwork[indd], &c__1, &w[1], &c__1);
00376 indee = indrwk + (*n << 1);
00377 i__1 = *n - 1;
00378 dcopy_(&i__1, &rwork[inde], &c__1, &rwork[indee], &c__1);
00379 if (! wantz) {
00380 dsterf_(n, &w[1], &rwork[indee], info);
00381 } else {
00382 zlacpy_("A", n, n, &q[q_offset], ldq, &z__[z_offset], ldz);
00383 zsteqr_(jobz, n, &w[1], &rwork[indee], &z__[z_offset], ldz, &
00384 rwork[indrwk], info);
00385 if (*info == 0) {
00386 i__1 = *n;
00387 for (i__ = 1; i__ <= i__1; ++i__) {
00388 ifail[i__] = 0;
00389
00390 }
00391 }
00392 }
00393 if (*info == 0) {
00394 *m = *n;
00395 goto L30;
00396 }
00397 *info = 0;
00398 }
00399
00400
00401
00402
00403 if (wantz) {
00404 *(unsigned char *)order = 'B';
00405 } else {
00406 *(unsigned char *)order = 'E';
00407 }
00408 indibl = 1;
00409 indisp = indibl + *n;
00410 indiwk = indisp + *n;
00411 dstebz_(range, order, n, vl, vu, il, iu, abstol, &rwork[indd], &rwork[
00412 inde], m, &nsplit, &w[1], &iwork[indibl], &iwork[indisp], &rwork[
00413 indrwk], &iwork[indiwk], info);
00414
00415 if (wantz) {
00416 zstein_(n, &rwork[indd], &rwork[inde], m, &w[1], &iwork[indibl], &
00417 iwork[indisp], &z__[z_offset], ldz, &rwork[indrwk], &iwork[
00418 indiwk], &ifail[1], info);
00419
00420
00421
00422
00423 i__1 = *m;
00424 for (j = 1; j <= i__1; ++j) {
00425 zcopy_(n, &z__[j * z_dim1 + 1], &c__1, &work[1], &c__1);
00426 zgemv_("N", n, n, &c_b2, &q[q_offset], ldq, &work[1], &c__1, &
00427 c_b1, &z__[j * z_dim1 + 1], &c__1);
00428
00429 }
00430 }
00431
00432 L30:
00433
00434
00435
00436
00437 if (wantz) {
00438 i__1 = *m - 1;
00439 for (j = 1; j <= i__1; ++j) {
00440 i__ = 0;
00441 tmp1 = w[j];
00442 i__2 = *m;
00443 for (jj = j + 1; jj <= i__2; ++jj) {
00444 if (w[jj] < tmp1) {
00445 i__ = jj;
00446 tmp1 = w[jj];
00447 }
00448
00449 }
00450
00451 if (i__ != 0) {
00452 itmp1 = iwork[indibl + i__ - 1];
00453 w[i__] = w[j];
00454 iwork[indibl + i__ - 1] = iwork[indibl + j - 1];
00455 w[j] = tmp1;
00456 iwork[indibl + j - 1] = itmp1;
00457 zswap_(n, &z__[i__ * z_dim1 + 1], &c__1, &z__[j * z_dim1 + 1],
00458 &c__1);
00459 if (*info != 0) {
00460 itmp1 = ifail[i__];
00461 ifail[i__] = ifail[j];
00462 ifail[j] = itmp1;
00463 }
00464 }
00465
00466 }
00467 }
00468
00469 return 0;
00470
00471
00472
00473 }