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 static real c_b25 = 1.f;
00020 static real c_b27 = 0.f;
00021
00022 int ssbgvx_(char *jobz, char *range, char *uplo, integer *n,
00023 integer *ka, integer *kb, real *ab, integer *ldab, real *bb, integer *
00024 ldbb, real *q, integer *ldq, real *vl, real *vu, integer *il, integer
00025 *iu, real *abstol, integer *m, real *w, real *z__, integer *ldz, real
00026 *work, integer *iwork, integer *ifail, integer *info)
00027 {
00028
00029 integer ab_dim1, ab_offset, bb_dim1, bb_offset, q_dim1, q_offset, z_dim1,
00030 z_offset, i__1, i__2;
00031
00032
00033 integer i__, j, jj;
00034 real tmp1;
00035 integer indd, inde;
00036 char vect[1];
00037 logical test;
00038 integer itmp1, indee;
00039 extern logical lsame_(char *, char *);
00040 integer iinfo;
00041 char order[1];
00042 extern int sgemv_(char *, integer *, integer *, real *,
00043 real *, integer *, real *, integer *, real *, real *, integer *);
00044 logical upper;
00045 extern int scopy_(integer *, real *, integer *, real *,
00046 integer *), sswap_(integer *, real *, integer *, real *, integer *
00047 );
00048 logical wantz, alleig, indeig;
00049 integer indibl;
00050 logical valeig;
00051 extern int xerbla_(char *, integer *);
00052 integer indisp, indiwo;
00053 extern int slacpy_(char *, integer *, integer *, real *,
00054 integer *, real *, integer *);
00055 integer indwrk;
00056 extern int spbstf_(char *, integer *, integer *, real *,
00057 integer *, integer *), ssbtrd_(char *, char *, integer *,
00058 integer *, real *, integer *, real *, real *, real *, integer *,
00059 real *, integer *), ssbgst_(char *, char *,
00060 integer *, integer *, integer *, real *, integer *, real *,
00061 integer *, real *, integer *, real *, integer *),
00062 sstein_(integer *, real *, real *, integer *, real *, integer *,
00063 integer *, real *, integer *, real *, integer *, integer *,
00064 integer *), ssterf_(integer *, real *, real *, integer *);
00065 integer nsplit;
00066 extern int sstebz_(char *, char *, integer *, real *,
00067 real *, integer *, integer *, real *, real *, real *, integer *,
00068 integer *, real *, integer *, integer *, real *, integer *,
00069 integer *), ssteqr_(char *, integer *, real *,
00070 real *, real *, integer *, real *, integer *);
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
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 ab_dim1 = *ldab;
00252 ab_offset = 1 + ab_dim1;
00253 ab -= ab_offset;
00254 bb_dim1 = *ldbb;
00255 bb_offset = 1 + bb_dim1;
00256 bb -= bb_offset;
00257 q_dim1 = *ldq;
00258 q_offset = 1 + q_dim1;
00259 q -= q_offset;
00260 --w;
00261 z_dim1 = *ldz;
00262 z_offset = 1 + z_dim1;
00263 z__ -= z_offset;
00264 --work;
00265 --iwork;
00266 --ifail;
00267
00268
00269 wantz = lsame_(jobz, "V");
00270 upper = lsame_(uplo, "U");
00271 alleig = lsame_(range, "A");
00272 valeig = lsame_(range, "V");
00273 indeig = lsame_(range, "I");
00274
00275 *info = 0;
00276 if (! (wantz || lsame_(jobz, "N"))) {
00277 *info = -1;
00278 } else if (! (alleig || valeig || indeig)) {
00279 *info = -2;
00280 } else if (! (upper || lsame_(uplo, "L"))) {
00281 *info = -3;
00282 } else if (*n < 0) {
00283 *info = -4;
00284 } else if (*ka < 0) {
00285 *info = -5;
00286 } else if (*kb < 0 || *kb > *ka) {
00287 *info = -6;
00288 } else if (*ldab < *ka + 1) {
00289 *info = -8;
00290 } else if (*ldbb < *kb + 1) {
00291 *info = -10;
00292 } else if (*ldq < 1 || wantz && *ldq < *n) {
00293 *info = -12;
00294 } else {
00295 if (valeig) {
00296 if (*n > 0 && *vu <= *vl) {
00297 *info = -14;
00298 }
00299 } else if (indeig) {
00300 if (*il < 1 || *il > max(1,*n)) {
00301 *info = -15;
00302 } else if (*iu < min(*n,*il) || *iu > *n) {
00303 *info = -16;
00304 }
00305 }
00306 }
00307 if (*info == 0) {
00308 if (*ldz < 1 || wantz && *ldz < *n) {
00309 *info = -21;
00310 }
00311 }
00312
00313 if (*info != 0) {
00314 i__1 = -(*info);
00315 xerbla_("SSBGVX", &i__1);
00316 return 0;
00317 }
00318
00319
00320
00321 *m = 0;
00322 if (*n == 0) {
00323 return 0;
00324 }
00325
00326
00327
00328 spbstf_(uplo, n, kb, &bb[bb_offset], ldbb, info);
00329 if (*info != 0) {
00330 *info = *n + *info;
00331 return 0;
00332 }
00333
00334
00335
00336 ssbgst_(jobz, uplo, n, ka, kb, &ab[ab_offset], ldab, &bb[bb_offset], ldbb,
00337 &q[q_offset], ldq, &work[1], &iinfo);
00338
00339
00340
00341 indd = 1;
00342 inde = indd + *n;
00343 indwrk = inde + *n;
00344 if (wantz) {
00345 *(unsigned char *)vect = 'U';
00346 } else {
00347 *(unsigned char *)vect = 'N';
00348 }
00349 ssbtrd_(vect, uplo, n, ka, &ab[ab_offset], ldab, &work[indd], &work[inde],
00350 &q[q_offset], ldq, &work[indwrk], &iinfo);
00351
00352
00353
00354
00355
00356 test = FALSE_;
00357 if (indeig) {
00358 if (*il == 1 && *iu == *n) {
00359 test = TRUE_;
00360 }
00361 }
00362 if ((alleig || test) && *abstol <= 0.f) {
00363 scopy_(n, &work[indd], &c__1, &w[1], &c__1);
00364 indee = indwrk + (*n << 1);
00365 i__1 = *n - 1;
00366 scopy_(&i__1, &work[inde], &c__1, &work[indee], &c__1);
00367 if (! wantz) {
00368 ssterf_(n, &w[1], &work[indee], info);
00369 } else {
00370 slacpy_("A", n, n, &q[q_offset], ldq, &z__[z_offset], ldz);
00371 ssteqr_(jobz, n, &w[1], &work[indee], &z__[z_offset], ldz, &work[
00372 indwrk], info);
00373 if (*info == 0) {
00374 i__1 = *n;
00375 for (i__ = 1; i__ <= i__1; ++i__) {
00376 ifail[i__] = 0;
00377
00378 }
00379 }
00380 }
00381 if (*info == 0) {
00382 *m = *n;
00383 goto L30;
00384 }
00385 *info = 0;
00386 }
00387
00388
00389
00390
00391 if (wantz) {
00392 *(unsigned char *)order = 'B';
00393 } else {
00394 *(unsigned char *)order = 'E';
00395 }
00396 indibl = 1;
00397 indisp = indibl + *n;
00398 indiwo = indisp + *n;
00399 sstebz_(range, order, n, vl, vu, il, iu, abstol, &work[indd], &work[inde],
00400 m, &nsplit, &w[1], &iwork[indibl], &iwork[indisp], &work[indwrk],
00401 &iwork[indiwo], info);
00402
00403 if (wantz) {
00404 sstein_(n, &work[indd], &work[inde], m, &w[1], &iwork[indibl], &iwork[
00405 indisp], &z__[z_offset], ldz, &work[indwrk], &iwork[indiwo], &
00406 ifail[1], info);
00407
00408
00409
00410
00411 i__1 = *m;
00412 for (j = 1; j <= i__1; ++j) {
00413 scopy_(n, &z__[j * z_dim1 + 1], &c__1, &work[1], &c__1);
00414 sgemv_("N", n, n, &c_b25, &q[q_offset], ldq, &work[1], &c__1, &
00415 c_b27, &z__[j * z_dim1 + 1], &c__1);
00416
00417 }
00418 }
00419
00420 L30:
00421
00422
00423
00424
00425 if (wantz) {
00426 i__1 = *m - 1;
00427 for (j = 1; j <= i__1; ++j) {
00428 i__ = 0;
00429 tmp1 = w[j];
00430 i__2 = *m;
00431 for (jj = j + 1; jj <= i__2; ++jj) {
00432 if (w[jj] < tmp1) {
00433 i__ = jj;
00434 tmp1 = w[jj];
00435 }
00436
00437 }
00438
00439 if (i__ != 0) {
00440 itmp1 = iwork[indibl + i__ - 1];
00441 w[i__] = w[j];
00442 iwork[indibl + i__ - 1] = iwork[indibl + j - 1];
00443 w[j] = tmp1;
00444 iwork[indibl + j - 1] = itmp1;
00445 sswap_(n, &z__[i__ * z_dim1 + 1], &c__1, &z__[j * z_dim1 + 1],
00446 &c__1);
00447 if (*info != 0) {
00448 itmp1 = ifail[i__];
00449 ifail[i__] = ifail[j];
00450 ifail[j] = itmp1;
00451 }
00452 }
00453
00454 }
00455 }
00456
00457 return 0;
00458
00459
00460
00461 }