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 real c_b18 = 0.f;
00020 static integer c__1 = 1;
00021
00022 int ssbevd_(char *jobz, char *uplo, integer *n, integer *kd,
00023 real *ab, integer *ldab, real *w, real *z__, integer *ldz, real *work,
00024 integer *lwork, integer *iwork, integer *liwork, integer *info)
00025 {
00026
00027 integer ab_dim1, ab_offset, z_dim1, z_offset, i__1;
00028 real r__1;
00029
00030
00031 double sqrt(doublereal);
00032
00033
00034 real eps;
00035 integer inde;
00036 real anrm, rmin, rmax, sigma;
00037 extern logical lsame_(char *, char *);
00038 integer iinfo;
00039 extern int sscal_(integer *, real *, real *, integer *),
00040 sgemm_(char *, char *, integer *, integer *, integer *, real *,
00041 real *, integer *, real *, integer *, real *, real *, integer *);
00042 integer lwmin;
00043 logical lower, wantz;
00044 integer indwk2, llwrk2, iscale;
00045 extern doublereal slamch_(char *);
00046 real safmin;
00047 extern int xerbla_(char *, integer *);
00048 real bignum;
00049 extern doublereal slansb_(char *, char *, integer *, integer *, real *,
00050 integer *, real *);
00051 extern int slascl_(char *, integer *, integer *, real *,
00052 real *, integer *, integer *, real *, integer *, integer *), sstedc_(char *, integer *, real *, real *, real *,
00053 integer *, real *, integer *, integer *, integer *, integer *), slacpy_(char *, integer *, integer *, real *, integer *,
00054 real *, integer *);
00055 integer indwrk, liwmin;
00056 extern int ssbtrd_(char *, char *, integer *, integer *,
00057 real *, integer *, real *, real *, real *, integer *, real *,
00058 integer *), ssterf_(integer *, real *, real *,
00059 integer *);
00060 real smlnum;
00061 logical lquery;
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
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 ab_dim1 = *ldab;
00192 ab_offset = 1 + ab_dim1;
00193 ab -= ab_offset;
00194 --w;
00195 z_dim1 = *ldz;
00196 z_offset = 1 + z_dim1;
00197 z__ -= z_offset;
00198 --work;
00199 --iwork;
00200
00201
00202 wantz = lsame_(jobz, "V");
00203 lower = lsame_(uplo, "L");
00204 lquery = *lwork == -1 || *liwork == -1;
00205
00206 *info = 0;
00207 if (*n <= 1) {
00208 liwmin = 1;
00209 lwmin = 1;
00210 } else {
00211 if (wantz) {
00212 liwmin = *n * 5 + 3;
00213
00214 i__1 = *n;
00215 lwmin = *n * 5 + 1 + (i__1 * i__1 << 1);
00216 } else {
00217 liwmin = 1;
00218 lwmin = *n << 1;
00219 }
00220 }
00221 if (! (wantz || lsame_(jobz, "N"))) {
00222 *info = -1;
00223 } else if (! (lower || lsame_(uplo, "U"))) {
00224 *info = -2;
00225 } else if (*n < 0) {
00226 *info = -3;
00227 } else if (*kd < 0) {
00228 *info = -4;
00229 } else if (*ldab < *kd + 1) {
00230 *info = -6;
00231 } else if (*ldz < 1 || wantz && *ldz < *n) {
00232 *info = -9;
00233 }
00234
00235 if (*info == 0) {
00236 work[1] = (real) lwmin;
00237 iwork[1] = liwmin;
00238
00239 if (*lwork < lwmin && ! lquery) {
00240 *info = -11;
00241 } else if (*liwork < liwmin && ! lquery) {
00242 *info = -13;
00243 }
00244 }
00245
00246 if (*info != 0) {
00247 i__1 = -(*info);
00248 xerbla_("SSBEVD", &i__1);
00249 return 0;
00250 } else if (lquery) {
00251 return 0;
00252 }
00253
00254
00255
00256 if (*n == 0) {
00257 return 0;
00258 }
00259
00260 if (*n == 1) {
00261 w[1] = ab[ab_dim1 + 1];
00262 if (wantz) {
00263 z__[z_dim1 + 1] = 1.f;
00264 }
00265 return 0;
00266 }
00267
00268
00269
00270 safmin = slamch_("Safe minimum");
00271 eps = slamch_("Precision");
00272 smlnum = safmin / eps;
00273 bignum = 1.f / smlnum;
00274 rmin = sqrt(smlnum);
00275 rmax = sqrt(bignum);
00276
00277
00278
00279 anrm = slansb_("M", uplo, n, kd, &ab[ab_offset], ldab, &work[1]);
00280 iscale = 0;
00281 if (anrm > 0.f && anrm < rmin) {
00282 iscale = 1;
00283 sigma = rmin / anrm;
00284 } else if (anrm > rmax) {
00285 iscale = 1;
00286 sigma = rmax / anrm;
00287 }
00288 if (iscale == 1) {
00289 if (lower) {
00290 slascl_("B", kd, kd, &c_b11, &sigma, n, n, &ab[ab_offset], ldab,
00291 info);
00292 } else {
00293 slascl_("Q", kd, kd, &c_b11, &sigma, n, n, &ab[ab_offset], ldab,
00294 info);
00295 }
00296 }
00297
00298
00299
00300 inde = 1;
00301 indwrk = inde + *n;
00302 indwk2 = indwrk + *n * *n;
00303 llwrk2 = *lwork - indwk2 + 1;
00304 ssbtrd_(jobz, uplo, n, kd, &ab[ab_offset], ldab, &w[1], &work[inde], &z__[
00305 z_offset], ldz, &work[indwrk], &iinfo);
00306
00307
00308
00309 if (! wantz) {
00310 ssterf_(n, &w[1], &work[inde], info);
00311 } else {
00312 sstedc_("I", n, &w[1], &work[inde], &work[indwrk], n, &work[indwk2], &
00313 llwrk2, &iwork[1], liwork, info);
00314 sgemm_("N", "N", n, n, n, &c_b11, &z__[z_offset], ldz, &work[indwrk],
00315 n, &c_b18, &work[indwk2], n);
00316 slacpy_("A", n, n, &work[indwk2], n, &z__[z_offset], ldz);
00317 }
00318
00319
00320
00321 if (iscale == 1) {
00322 r__1 = 1.f / sigma;
00323 sscal_(n, &r__1, &w[1], &c__1);
00324 }
00325
00326 work[1] = (real) lwmin;
00327 iwork[1] = liwmin;
00328 return 0;
00329
00330
00331
00332 }