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