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 doublecomplex c_b2 = {0.,0.};
00019 static integer c__1 = 1;
00020
00021 int zhetd2_(char *uplo, integer *n, doublecomplex *a,
00022 integer *lda, doublereal *d__, doublereal *e, doublecomplex *tau,
00023 integer *info)
00024 {
00025
00026 integer a_dim1, a_offset, i__1, i__2, i__3;
00027 doublereal d__1;
00028 doublecomplex z__1, z__2, z__3, z__4;
00029
00030
00031 integer i__;
00032 doublecomplex taui;
00033 extern int zher2_(char *, integer *, doublecomplex *,
00034 doublecomplex *, integer *, doublecomplex *, integer *,
00035 doublecomplex *, integer *);
00036 doublecomplex alpha;
00037 extern logical lsame_(char *, char *);
00038 extern VOID zdotc_(doublecomplex *, integer *,
00039 doublecomplex *, integer *, doublecomplex *, integer *);
00040 extern int zhemv_(char *, integer *, doublecomplex *,
00041 doublecomplex *, integer *, doublecomplex *, integer *,
00042 doublecomplex *, doublecomplex *, integer *);
00043 logical upper;
00044 extern int zaxpy_(integer *, doublecomplex *,
00045 doublecomplex *, integer *, doublecomplex *, integer *), xerbla_(
00046 char *, integer *), zlarfg_(integer *, doublecomplex *,
00047 doublecomplex *, integer *, doublecomplex *);
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
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
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 a_dim1 = *lda;
00177 a_offset = 1 + a_dim1;
00178 a -= a_offset;
00179 --d__;
00180 --e;
00181 --tau;
00182
00183
00184 *info = 0;
00185 upper = lsame_(uplo, "U");
00186 if (! upper && ! lsame_(uplo, "L")) {
00187 *info = -1;
00188 } else if (*n < 0) {
00189 *info = -2;
00190 } else if (*lda < max(1,*n)) {
00191 *info = -4;
00192 }
00193 if (*info != 0) {
00194 i__1 = -(*info);
00195 xerbla_("ZHETD2", &i__1);
00196 return 0;
00197 }
00198
00199
00200
00201 if (*n <= 0) {
00202 return 0;
00203 }
00204
00205 if (upper) {
00206
00207
00208
00209 i__1 = *n + *n * a_dim1;
00210 i__2 = *n + *n * a_dim1;
00211 d__1 = a[i__2].r;
00212 a[i__1].r = d__1, a[i__1].i = 0.;
00213 for (i__ = *n - 1; i__ >= 1; --i__) {
00214
00215
00216
00217
00218 i__1 = i__ + (i__ + 1) * a_dim1;
00219 alpha.r = a[i__1].r, alpha.i = a[i__1].i;
00220 zlarfg_(&i__, &alpha, &a[(i__ + 1) * a_dim1 + 1], &c__1, &taui);
00221 i__1 = i__;
00222 e[i__1] = alpha.r;
00223
00224 if (taui.r != 0. || taui.i != 0.) {
00225
00226
00227
00228 i__1 = i__ + (i__ + 1) * a_dim1;
00229 a[i__1].r = 1., a[i__1].i = 0.;
00230
00231
00232
00233 zhemv_(uplo, &i__, &taui, &a[a_offset], lda, &a[(i__ + 1) *
00234 a_dim1 + 1], &c__1, &c_b2, &tau[1], &c__1);
00235
00236
00237
00238 z__3.r = -.5, z__3.i = -0.;
00239 z__2.r = z__3.r * taui.r - z__3.i * taui.i, z__2.i = z__3.r *
00240 taui.i + z__3.i * taui.r;
00241 zdotc_(&z__4, &i__, &tau[1], &c__1, &a[(i__ + 1) * a_dim1 + 1]
00242 , &c__1);
00243 z__1.r = z__2.r * z__4.r - z__2.i * z__4.i, z__1.i = z__2.r *
00244 z__4.i + z__2.i * z__4.r;
00245 alpha.r = z__1.r, alpha.i = z__1.i;
00246 zaxpy_(&i__, &alpha, &a[(i__ + 1) * a_dim1 + 1], &c__1, &tau[
00247 1], &c__1);
00248
00249
00250
00251
00252 z__1.r = -1., z__1.i = -0.;
00253 zher2_(uplo, &i__, &z__1, &a[(i__ + 1) * a_dim1 + 1], &c__1, &
00254 tau[1], &c__1, &a[a_offset], lda);
00255
00256 } else {
00257 i__1 = i__ + i__ * a_dim1;
00258 i__2 = i__ + i__ * a_dim1;
00259 d__1 = a[i__2].r;
00260 a[i__1].r = d__1, a[i__1].i = 0.;
00261 }
00262 i__1 = i__ + (i__ + 1) * a_dim1;
00263 i__2 = i__;
00264 a[i__1].r = e[i__2], a[i__1].i = 0.;
00265 i__1 = i__ + 1;
00266 i__2 = i__ + 1 + (i__ + 1) * a_dim1;
00267 d__[i__1] = a[i__2].r;
00268 i__1 = i__;
00269 tau[i__1].r = taui.r, tau[i__1].i = taui.i;
00270
00271 }
00272 i__1 = a_dim1 + 1;
00273 d__[1] = a[i__1].r;
00274 } else {
00275
00276
00277
00278 i__1 = a_dim1 + 1;
00279 i__2 = a_dim1 + 1;
00280 d__1 = a[i__2].r;
00281 a[i__1].r = d__1, a[i__1].i = 0.;
00282 i__1 = *n - 1;
00283 for (i__ = 1; i__ <= i__1; ++i__) {
00284
00285
00286
00287
00288 i__2 = i__ + 1 + i__ * a_dim1;
00289 alpha.r = a[i__2].r, alpha.i = a[i__2].i;
00290 i__2 = *n - i__;
00291
00292 i__3 = i__ + 2;
00293 zlarfg_(&i__2, &alpha, &a[min(i__3, *n)+ i__ * a_dim1], &c__1, &
00294 taui);
00295 i__2 = i__;
00296 e[i__2] = alpha.r;
00297
00298 if (taui.r != 0. || taui.i != 0.) {
00299
00300
00301
00302 i__2 = i__ + 1 + i__ * a_dim1;
00303 a[i__2].r = 1., a[i__2].i = 0.;
00304
00305
00306
00307 i__2 = *n - i__;
00308 zhemv_(uplo, &i__2, &taui, &a[i__ + 1 + (i__ + 1) * a_dim1],
00309 lda, &a[i__ + 1 + i__ * a_dim1], &c__1, &c_b2, &tau[
00310 i__], &c__1);
00311
00312
00313
00314 z__3.r = -.5, z__3.i = -0.;
00315 z__2.r = z__3.r * taui.r - z__3.i * taui.i, z__2.i = z__3.r *
00316 taui.i + z__3.i * taui.r;
00317 i__2 = *n - i__;
00318 zdotc_(&z__4, &i__2, &tau[i__], &c__1, &a[i__ + 1 + i__ *
00319 a_dim1], &c__1);
00320 z__1.r = z__2.r * z__4.r - z__2.i * z__4.i, z__1.i = z__2.r *
00321 z__4.i + z__2.i * z__4.r;
00322 alpha.r = z__1.r, alpha.i = z__1.i;
00323 i__2 = *n - i__;
00324 zaxpy_(&i__2, &alpha, &a[i__ + 1 + i__ * a_dim1], &c__1, &tau[
00325 i__], &c__1);
00326
00327
00328
00329
00330 i__2 = *n - i__;
00331 z__1.r = -1., z__1.i = -0.;
00332 zher2_(uplo, &i__2, &z__1, &a[i__ + 1 + i__ * a_dim1], &c__1,
00333 &tau[i__], &c__1, &a[i__ + 1 + (i__ + 1) * a_dim1],
00334 lda);
00335
00336 } else {
00337 i__2 = i__ + 1 + (i__ + 1) * a_dim1;
00338 i__3 = i__ + 1 + (i__ + 1) * a_dim1;
00339 d__1 = a[i__3].r;
00340 a[i__2].r = d__1, a[i__2].i = 0.;
00341 }
00342 i__2 = i__ + 1 + i__ * a_dim1;
00343 i__3 = i__;
00344 a[i__2].r = e[i__3], a[i__2].i = 0.;
00345 i__2 = i__;
00346 i__3 = i__ + i__ * a_dim1;
00347 d__[i__2] = a[i__3].r;
00348 i__2 = i__;
00349 tau[i__2].r = taui.r, tau[i__2].i = taui.i;
00350
00351 }
00352 i__1 = *n;
00353 i__2 = *n + *n * a_dim1;
00354 d__[i__1] = a[i__2].r;
00355 }
00356
00357 return 0;
00358
00359
00360
00361 }