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