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 integer c_n1 = -1;
00020 static integer c__0 = 0;
00021 static real c_b17 = 1.f;
00022
00023 int ssyev_(char *jobz, char *uplo, integer *n, real *a,
00024 integer *lda, real *w, real *work, integer *lwork, integer *info)
00025 {
00026
00027 integer a_dim1, a_offset, i__1, i__2;
00028 real r__1;
00029
00030
00031 double sqrt(doublereal);
00032
00033
00034 integer nb;
00035 real eps;
00036 integer inde;
00037 real anrm;
00038 integer imax;
00039 real rmin, rmax, sigma;
00040 extern logical lsame_(char *, char *);
00041 integer iinfo;
00042 extern int sscal_(integer *, real *, real *, integer *);
00043 logical lower, wantz;
00044 integer iscale;
00045 extern doublereal slamch_(char *);
00046 real safmin;
00047 extern integer ilaenv_(integer *, char *, char *, integer *, integer *,
00048 integer *, integer *);
00049 extern int xerbla_(char *, integer *);
00050 real bignum;
00051 extern int slascl_(char *, integer *, integer *, real *,
00052 real *, integer *, integer *, real *, integer *, integer *);
00053 integer indtau, indwrk;
00054 extern int ssterf_(integer *, real *, real *, integer *);
00055 extern doublereal slansy_(char *, char *, integer *, real *, integer *,
00056 real *);
00057 integer llwork;
00058 real smlnum;
00059 integer lwkopt;
00060 logical lquery;
00061 extern int sorgtr_(char *, integer *, real *, integer *,
00062 real *, real *, integer *, integer *), ssteqr_(char *,
00063 integer *, real *, real *, real *, integer *, real *, integer *), ssytrd_(char *, integer *, real *, integer *, real *,
00064 real *, real *, real *, integer *, integer *);
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 a_dim1 = *lda;
00152 a_offset = 1 + a_dim1;
00153 a -= a_offset;
00154 --w;
00155 --work;
00156
00157
00158 wantz = lsame_(jobz, "V");
00159 lower = lsame_(uplo, "L");
00160 lquery = *lwork == -1;
00161
00162 *info = 0;
00163 if (! (wantz || lsame_(jobz, "N"))) {
00164 *info = -1;
00165 } else if (! (lower || lsame_(uplo, "U"))) {
00166 *info = -2;
00167 } else if (*n < 0) {
00168 *info = -3;
00169 } else if (*lda < max(1,*n)) {
00170 *info = -5;
00171 }
00172
00173 if (*info == 0) {
00174 nb = ilaenv_(&c__1, "SSYTRD", uplo, n, &c_n1, &c_n1, &c_n1);
00175
00176 i__1 = 1, i__2 = (nb + 2) * *n;
00177 lwkopt = max(i__1,i__2);
00178 work[1] = (real) lwkopt;
00179
00180
00181 i__1 = 1, i__2 = *n * 3 - 1;
00182 if (*lwork < max(i__1,i__2) && ! lquery) {
00183 *info = -8;
00184 }
00185 }
00186
00187 if (*info != 0) {
00188 i__1 = -(*info);
00189 xerbla_("SSYEV ", &i__1);
00190 return 0;
00191 } else if (lquery) {
00192 return 0;
00193 }
00194
00195
00196
00197 if (*n == 0) {
00198 return 0;
00199 }
00200
00201 if (*n == 1) {
00202 w[1] = a[a_dim1 + 1];
00203 work[1] = 2.f;
00204 if (wantz) {
00205 a[a_dim1 + 1] = 1.f;
00206 }
00207 return 0;
00208 }
00209
00210
00211
00212 safmin = slamch_("Safe minimum");
00213 eps = slamch_("Precision");
00214 smlnum = safmin / eps;
00215 bignum = 1.f / smlnum;
00216 rmin = sqrt(smlnum);
00217 rmax = sqrt(bignum);
00218
00219
00220
00221 anrm = slansy_("M", uplo, n, &a[a_offset], lda, &work[1]);
00222 iscale = 0;
00223 if (anrm > 0.f && anrm < rmin) {
00224 iscale = 1;
00225 sigma = rmin / anrm;
00226 } else if (anrm > rmax) {
00227 iscale = 1;
00228 sigma = rmax / anrm;
00229 }
00230 if (iscale == 1) {
00231 slascl_(uplo, &c__0, &c__0, &c_b17, &sigma, n, n, &a[a_offset], lda,
00232 info);
00233 }
00234
00235
00236
00237 inde = 1;
00238 indtau = inde + *n;
00239 indwrk = indtau + *n;
00240 llwork = *lwork - indwrk + 1;
00241 ssytrd_(uplo, n, &a[a_offset], lda, &w[1], &work[inde], &work[indtau], &
00242 work[indwrk], &llwork, &iinfo);
00243
00244
00245
00246
00247 if (! wantz) {
00248 ssterf_(n, &w[1], &work[inde], info);
00249 } else {
00250 sorgtr_(uplo, n, &a[a_offset], lda, &work[indtau], &work[indwrk], &
00251 llwork, &iinfo);
00252 ssteqr_(jobz, n, &w[1], &work[inde], &a[a_offset], lda, &work[indtau],
00253 info);
00254 }
00255
00256
00257
00258 if (iscale == 1) {
00259 if (*info == 0) {
00260 imax = *n;
00261 } else {
00262 imax = *info - 1;
00263 }
00264 r__1 = 1.f / sigma;
00265 sscal_(&imax, &r__1, &w[1], &c__1);
00266 }
00267
00268
00269
00270 work[1] = (real) lwkopt;
00271
00272 return 0;
00273
00274
00275
00276 }