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
00020 int dspev_(char *jobz, char *uplo, integer *n, doublereal *
00021 ap, doublereal *w, doublereal *z__, integer *ldz, doublereal *work,
00022 integer *info)
00023 {
00024
00025 integer z_dim1, z_offset, i__1;
00026 doublereal d__1;
00027
00028
00029 double sqrt(doublereal);
00030
00031
00032 doublereal eps;
00033 integer inde;
00034 doublereal anrm;
00035 integer imax;
00036 doublereal rmin, rmax;
00037 extern int dscal_(integer *, doublereal *, doublereal *,
00038 integer *);
00039 doublereal sigma;
00040 extern logical lsame_(char *, char *);
00041 integer iinfo;
00042 logical wantz;
00043 extern doublereal dlamch_(char *);
00044 integer iscale;
00045 doublereal safmin;
00046 extern int xerbla_(char *, integer *);
00047 doublereal bignum;
00048 extern doublereal dlansp_(char *, char *, integer *, doublereal *,
00049 doublereal *);
00050 integer indtau;
00051 extern int dsterf_(integer *, doublereal *, doublereal *,
00052 integer *);
00053 integer indwrk;
00054 extern int dopgtr_(char *, integer *, doublereal *,
00055 doublereal *, doublereal *, integer *, doublereal *, integer *), dsptrd_(char *, integer *, doublereal *, doublereal *,
00056 doublereal *, doublereal *, integer *), dsteqr_(char *,
00057 integer *, doublereal *, doublereal *, doublereal *, integer *,
00058 doublereal *, integer *);
00059 doublereal smlnum;
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 --ap;
00145 --w;
00146 z_dim1 = *ldz;
00147 z_offset = 1 + z_dim1;
00148 z__ -= z_offset;
00149 --work;
00150
00151
00152 wantz = lsame_(jobz, "V");
00153
00154 *info = 0;
00155 if (! (wantz || lsame_(jobz, "N"))) {
00156 *info = -1;
00157 } else if (! (lsame_(uplo, "U") || lsame_(uplo,
00158 "L"))) {
00159 *info = -2;
00160 } else if (*n < 0) {
00161 *info = -3;
00162 } else if (*ldz < 1 || wantz && *ldz < *n) {
00163 *info = -7;
00164 }
00165
00166 if (*info != 0) {
00167 i__1 = -(*info);
00168 xerbla_("DSPEV ", &i__1);
00169 return 0;
00170 }
00171
00172
00173
00174 if (*n == 0) {
00175 return 0;
00176 }
00177
00178 if (*n == 1) {
00179 w[1] = ap[1];
00180 if (wantz) {
00181 z__[z_dim1 + 1] = 1.;
00182 }
00183 return 0;
00184 }
00185
00186
00187
00188 safmin = dlamch_("Safe minimum");
00189 eps = dlamch_("Precision");
00190 smlnum = safmin / eps;
00191 bignum = 1. / smlnum;
00192 rmin = sqrt(smlnum);
00193 rmax = sqrt(bignum);
00194
00195
00196
00197 anrm = dlansp_("M", uplo, n, &ap[1], &work[1]);
00198 iscale = 0;
00199 if (anrm > 0. && anrm < rmin) {
00200 iscale = 1;
00201 sigma = rmin / anrm;
00202 } else if (anrm > rmax) {
00203 iscale = 1;
00204 sigma = rmax / anrm;
00205 }
00206 if (iscale == 1) {
00207 i__1 = *n * (*n + 1) / 2;
00208 dscal_(&i__1, &sigma, &ap[1], &c__1);
00209 }
00210
00211
00212
00213 inde = 1;
00214 indtau = inde + *n;
00215 dsptrd_(uplo, n, &ap[1], &w[1], &work[inde], &work[indtau], &iinfo);
00216
00217
00218
00219
00220 if (! wantz) {
00221 dsterf_(n, &w[1], &work[inde], info);
00222 } else {
00223 indwrk = indtau + *n;
00224 dopgtr_(uplo, n, &ap[1], &work[indtau], &z__[z_offset], ldz, &work[
00225 indwrk], &iinfo);
00226 dsteqr_(jobz, n, &w[1], &work[inde], &z__[z_offset], ldz, &work[
00227 indtau], info);
00228 }
00229
00230
00231
00232 if (iscale == 1) {
00233 if (*info == 0) {
00234 imax = *n;
00235 } else {
00236 imax = *info - 1;
00237 }
00238 d__1 = 1. / sigma;
00239 dscal_(&imax, &d__1, &w[1], &c__1);
00240 }
00241
00242 return 0;
00243
00244
00245
00246 }