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 doublereal c_b18 = 1.;
00022
00023 int zheev_(char *jobz, char *uplo, integer *n, doublecomplex
00024 *a, integer *lda, doublereal *w, doublecomplex *work, integer *lwork,
00025 doublereal *rwork, integer *info)
00026 {
00027
00028 integer a_dim1, a_offset, i__1, i__2;
00029 doublereal d__1;
00030
00031
00032 double sqrt(doublereal);
00033
00034
00035 integer nb;
00036 doublereal eps;
00037 integer inde;
00038 doublereal anrm;
00039 integer imax;
00040 doublereal rmin, rmax;
00041 extern int dscal_(integer *, doublereal *, doublereal *,
00042 integer *);
00043 doublereal sigma;
00044 extern logical lsame_(char *, char *);
00045 integer iinfo;
00046 logical lower, wantz;
00047 extern doublereal dlamch_(char *);
00048 integer iscale;
00049 doublereal safmin;
00050 extern integer ilaenv_(integer *, char *, char *, integer *, integer *,
00051 integer *, integer *);
00052 extern int xerbla_(char *, integer *);
00053 doublereal bignum;
00054 extern doublereal zlanhe_(char *, char *, integer *, doublecomplex *,
00055 integer *, doublereal *);
00056 integer indtau;
00057 extern int dsterf_(integer *, doublereal *, doublereal *,
00058 integer *), zlascl_(char *, integer *, integer *, doublereal *,
00059 doublereal *, integer *, integer *, doublecomplex *, integer *,
00060 integer *);
00061 integer indwrk;
00062 extern int zhetrd_(char *, integer *, doublecomplex *,
00063 integer *, doublereal *, doublereal *, doublecomplex *,
00064 doublecomplex *, integer *, integer *);
00065 integer llwork;
00066 doublereal smlnum;
00067 integer lwkopt;
00068 logical lquery;
00069 extern int zsteqr_(char *, integer *, doublereal *,
00070 doublereal *, doublecomplex *, integer *, doublereal *, integer *), zungtr_(char *, integer *, doublecomplex *, integer *,
00071 doublecomplex *, doublecomplex *, integer *, integer *);
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 a_dim1 = *lda;
00161 a_offset = 1 + a_dim1;
00162 a -= a_offset;
00163 --w;
00164 --work;
00165 --rwork;
00166
00167
00168 wantz = lsame_(jobz, "V");
00169 lower = lsame_(uplo, "L");
00170 lquery = *lwork == -1;
00171
00172 *info = 0;
00173 if (! (wantz || lsame_(jobz, "N"))) {
00174 *info = -1;
00175 } else if (! (lower || lsame_(uplo, "U"))) {
00176 *info = -2;
00177 } else if (*n < 0) {
00178 *info = -3;
00179 } else if (*lda < max(1,*n)) {
00180 *info = -5;
00181 }
00182
00183 if (*info == 0) {
00184 nb = ilaenv_(&c__1, "ZHETRD", uplo, n, &c_n1, &c_n1, &c_n1);
00185
00186 i__1 = 1, i__2 = (nb + 1) * *n;
00187 lwkopt = max(i__1,i__2);
00188 work[1].r = (doublereal) lwkopt, work[1].i = 0.;
00189
00190
00191 i__1 = 1, i__2 = (*n << 1) - 1;
00192 if (*lwork < max(i__1,i__2) && ! lquery) {
00193 *info = -8;
00194 }
00195 }
00196
00197 if (*info != 0) {
00198 i__1 = -(*info);
00199 xerbla_("ZHEEV ", &i__1);
00200 return 0;
00201 } else if (lquery) {
00202 return 0;
00203 }
00204
00205
00206
00207 if (*n == 0) {
00208 return 0;
00209 }
00210
00211 if (*n == 1) {
00212 i__1 = a_dim1 + 1;
00213 w[1] = a[i__1].r;
00214 work[1].r = 1., work[1].i = 0.;
00215 if (wantz) {
00216 i__1 = a_dim1 + 1;
00217 a[i__1].r = 1., a[i__1].i = 0.;
00218 }
00219 return 0;
00220 }
00221
00222
00223
00224 safmin = dlamch_("Safe minimum");
00225 eps = dlamch_("Precision");
00226 smlnum = safmin / eps;
00227 bignum = 1. / smlnum;
00228 rmin = sqrt(smlnum);
00229 rmax = sqrt(bignum);
00230
00231
00232
00233 anrm = zlanhe_("M", uplo, n, &a[a_offset], lda, &rwork[1]);
00234 iscale = 0;
00235 if (anrm > 0. && anrm < rmin) {
00236 iscale = 1;
00237 sigma = rmin / anrm;
00238 } else if (anrm > rmax) {
00239 iscale = 1;
00240 sigma = rmax / anrm;
00241 }
00242 if (iscale == 1) {
00243 zlascl_(uplo, &c__0, &c__0, &c_b18, &sigma, n, n, &a[a_offset], lda,
00244 info);
00245 }
00246
00247
00248
00249 inde = 1;
00250 indtau = 1;
00251 indwrk = indtau + *n;
00252 llwork = *lwork - indwrk + 1;
00253 zhetrd_(uplo, n, &a[a_offset], lda, &w[1], &rwork[inde], &work[indtau], &
00254 work[indwrk], &llwork, &iinfo);
00255
00256
00257
00258
00259 if (! wantz) {
00260 dsterf_(n, &w[1], &rwork[inde], info);
00261 } else {
00262 zungtr_(uplo, n, &a[a_offset], lda, &work[indtau], &work[indwrk], &
00263 llwork, &iinfo);
00264 indwrk = inde + *n;
00265 zsteqr_(jobz, n, &w[1], &rwork[inde], &a[a_offset], lda, &rwork[
00266 indwrk], info);
00267 }
00268
00269
00270
00271 if (iscale == 1) {
00272 if (*info == 0) {
00273 imax = *n;
00274 } else {
00275 imax = *info - 1;
00276 }
00277 d__1 = 1. / sigma;
00278 dscal_(&imax, &d__1, &w[1], &c__1);
00279 }
00280
00281
00282
00283 work[1].r = (doublereal) lwkopt, work[1].i = 0.;
00284
00285 return 0;
00286
00287
00288
00289 }