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_b1 = {0.,0.};
00019 static doublecomplex c_b2 = {1.,0.};
00020 static integer c__3 = 3;
00021 static integer c__1 = 1;
00022
00023 int zlaghe_(integer *n, integer *k, doublereal *d__,
00024 doublecomplex *a, integer *lda, integer *iseed, doublecomplex *work,
00025 integer *info)
00026 {
00027
00028 integer a_dim1, a_offset, i__1, i__2, i__3;
00029 doublereal d__1;
00030 doublecomplex z__1, z__2, z__3, z__4;
00031
00032
00033 double z_abs(doublecomplex *);
00034 void z_div(doublecomplex *, doublecomplex *, doublecomplex *), d_cnjg(
00035 doublecomplex *, doublecomplex *);
00036
00037
00038 integer i__, j;
00039 doublecomplex wa, wb;
00040 doublereal wn;
00041 doublecomplex tau;
00042 extern int zher2_(char *, integer *, doublecomplex *,
00043 doublecomplex *, integer *, doublecomplex *, integer *,
00044 doublecomplex *, integer *);
00045 doublecomplex alpha;
00046 extern int zgerc_(integer *, integer *, doublecomplex *,
00047 doublecomplex *, integer *, doublecomplex *, integer *,
00048 doublecomplex *, integer *), zscal_(integer *, doublecomplex *,
00049 doublecomplex *, integer *);
00050 extern VOID zdotc_(doublecomplex *, integer *,
00051 doublecomplex *, integer *, doublecomplex *, integer *);
00052 extern int zgemv_(char *, integer *, integer *,
00053 doublecomplex *, doublecomplex *, integer *, doublecomplex *,
00054 integer *, doublecomplex *, doublecomplex *, integer *),
00055 zhemv_(char *, integer *, doublecomplex *, doublecomplex *,
00056 integer *, doublecomplex *, integer *, doublecomplex *,
00057 doublecomplex *, integer *), zaxpy_(integer *,
00058 doublecomplex *, doublecomplex *, integer *, doublecomplex *,
00059 integer *);
00060 extern doublereal dznrm2_(integer *, doublecomplex *, integer *);
00061 extern int xerbla_(char *, integer *), zlarnv_(
00062 integer *, integer *, integer *, doublecomplex *);
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 --d__;
00132 a_dim1 = *lda;
00133 a_offset = 1 + a_dim1;
00134 a -= a_offset;
00135 --iseed;
00136 --work;
00137
00138
00139 *info = 0;
00140 if (*n < 0) {
00141 *info = -1;
00142 } else if (*k < 0 || *k > *n - 1) {
00143 *info = -2;
00144 } else if (*lda < max(1,*n)) {
00145 *info = -5;
00146 }
00147 if (*info < 0) {
00148 i__1 = -(*info);
00149 xerbla_("ZLAGHE", &i__1);
00150 return 0;
00151 }
00152
00153
00154
00155 i__1 = *n;
00156 for (j = 1; j <= i__1; ++j) {
00157 i__2 = *n;
00158 for (i__ = j + 1; i__ <= i__2; ++i__) {
00159 i__3 = i__ + j * a_dim1;
00160 a[i__3].r = 0., a[i__3].i = 0.;
00161
00162 }
00163
00164 }
00165 i__1 = *n;
00166 for (i__ = 1; i__ <= i__1; ++i__) {
00167 i__2 = i__ + i__ * a_dim1;
00168 i__3 = i__;
00169 a[i__2].r = d__[i__3], a[i__2].i = 0.;
00170
00171 }
00172
00173
00174
00175 for (i__ = *n - 1; i__ >= 1; --i__) {
00176
00177
00178
00179 i__1 = *n - i__ + 1;
00180 zlarnv_(&c__3, &iseed[1], &i__1, &work[1]);
00181 i__1 = *n - i__ + 1;
00182 wn = dznrm2_(&i__1, &work[1], &c__1);
00183 d__1 = wn / z_abs(&work[1]);
00184 z__1.r = d__1 * work[1].r, z__1.i = d__1 * work[1].i;
00185 wa.r = z__1.r, wa.i = z__1.i;
00186 if (wn == 0.) {
00187 tau.r = 0., tau.i = 0.;
00188 } else {
00189 z__1.r = work[1].r + wa.r, z__1.i = work[1].i + wa.i;
00190 wb.r = z__1.r, wb.i = z__1.i;
00191 i__1 = *n - i__;
00192 z_div(&z__1, &c_b2, &wb);
00193 zscal_(&i__1, &z__1, &work[2], &c__1);
00194 work[1].r = 1., work[1].i = 0.;
00195 z_div(&z__1, &wb, &wa);
00196 d__1 = z__1.r;
00197 tau.r = d__1, tau.i = 0.;
00198 }
00199
00200
00201
00202
00203
00204
00205 i__1 = *n - i__ + 1;
00206 zhemv_("Lower", &i__1, &tau, &a[i__ + i__ * a_dim1], lda, &work[1], &
00207 c__1, &c_b1, &work[*n + 1], &c__1);
00208
00209
00210
00211 z__3.r = -.5, z__3.i = -0.;
00212 z__2.r = z__3.r * tau.r - z__3.i * tau.i, z__2.i = z__3.r * tau.i +
00213 z__3.i * tau.r;
00214 i__1 = *n - i__ + 1;
00215 zdotc_(&z__4, &i__1, &work[*n + 1], &c__1, &work[1], &c__1);
00216 z__1.r = z__2.r * z__4.r - z__2.i * z__4.i, z__1.i = z__2.r * z__4.i
00217 + z__2.i * z__4.r;
00218 alpha.r = z__1.r, alpha.i = z__1.i;
00219 i__1 = *n - i__ + 1;
00220 zaxpy_(&i__1, &alpha, &work[1], &c__1, &work[*n + 1], &c__1);
00221
00222
00223
00224 i__1 = *n - i__ + 1;
00225 z__1.r = -1., z__1.i = -0.;
00226 zher2_("Lower", &i__1, &z__1, &work[1], &c__1, &work[*n + 1], &c__1, &
00227 a[i__ + i__ * a_dim1], lda);
00228
00229 }
00230
00231
00232
00233 i__1 = *n - 1 - *k;
00234 for (i__ = 1; i__ <= i__1; ++i__) {
00235
00236
00237
00238 i__2 = *n - *k - i__ + 1;
00239 wn = dznrm2_(&i__2, &a[*k + i__ + i__ * a_dim1], &c__1);
00240 d__1 = wn / z_abs(&a[*k + i__ + i__ * a_dim1]);
00241 i__2 = *k + i__ + i__ * a_dim1;
00242 z__1.r = d__1 * a[i__2].r, z__1.i = d__1 * a[i__2].i;
00243 wa.r = z__1.r, wa.i = z__1.i;
00244 if (wn == 0.) {
00245 tau.r = 0., tau.i = 0.;
00246 } else {
00247 i__2 = *k + i__ + i__ * a_dim1;
00248 z__1.r = a[i__2].r + wa.r, z__1.i = a[i__2].i + wa.i;
00249 wb.r = z__1.r, wb.i = z__1.i;
00250 i__2 = *n - *k - i__;
00251 z_div(&z__1, &c_b2, &wb);
00252 zscal_(&i__2, &z__1, &a[*k + i__ + 1 + i__ * a_dim1], &c__1);
00253 i__2 = *k + i__ + i__ * a_dim1;
00254 a[i__2].r = 1., a[i__2].i = 0.;
00255 z_div(&z__1, &wb, &wa);
00256 d__1 = z__1.r;
00257 tau.r = d__1, tau.i = 0.;
00258 }
00259
00260
00261
00262 i__2 = *n - *k - i__ + 1;
00263 i__3 = *k - 1;
00264 zgemv_("Conjugate transpose", &i__2, &i__3, &c_b2, &a[*k + i__ + (i__
00265 + 1) * a_dim1], lda, &a[*k + i__ + i__ * a_dim1], &c__1, &
00266 c_b1, &work[1], &c__1);
00267 i__2 = *n - *k - i__ + 1;
00268 i__3 = *k - 1;
00269 z__1.r = -tau.r, z__1.i = -tau.i;
00270 zgerc_(&i__2, &i__3, &z__1, &a[*k + i__ + i__ * a_dim1], &c__1, &work[
00271 1], &c__1, &a[*k + i__ + (i__ + 1) * a_dim1], lda);
00272
00273
00274
00275
00276
00277 i__2 = *n - *k - i__ + 1;
00278 zhemv_("Lower", &i__2, &tau, &a[*k + i__ + (*k + i__) * a_dim1], lda,
00279 &a[*k + i__ + i__ * a_dim1], &c__1, &c_b1, &work[1], &c__1);
00280
00281
00282
00283 z__3.r = -.5, z__3.i = -0.;
00284 z__2.r = z__3.r * tau.r - z__3.i * tau.i, z__2.i = z__3.r * tau.i +
00285 z__3.i * tau.r;
00286 i__2 = *n - *k - i__ + 1;
00287 zdotc_(&z__4, &i__2, &work[1], &c__1, &a[*k + i__ + i__ * a_dim1], &
00288 c__1);
00289 z__1.r = z__2.r * z__4.r - z__2.i * z__4.i, z__1.i = z__2.r * z__4.i
00290 + z__2.i * z__4.r;
00291 alpha.r = z__1.r, alpha.i = z__1.i;
00292 i__2 = *n - *k - i__ + 1;
00293 zaxpy_(&i__2, &alpha, &a[*k + i__ + i__ * a_dim1], &c__1, &work[1], &
00294 c__1);
00295
00296
00297
00298 i__2 = *n - *k - i__ + 1;
00299 z__1.r = -1., z__1.i = -0.;
00300 zher2_("Lower", &i__2, &z__1, &a[*k + i__ + i__ * a_dim1], &c__1, &
00301 work[1], &c__1, &a[*k + i__ + (*k + i__) * a_dim1], lda);
00302
00303 i__2 = *k + i__ + i__ * a_dim1;
00304 z__1.r = -wa.r, z__1.i = -wa.i;
00305 a[i__2].r = z__1.r, a[i__2].i = z__1.i;
00306 i__2 = *n;
00307 for (j = *k + i__ + 1; j <= i__2; ++j) {
00308 i__3 = j + i__ * a_dim1;
00309 a[i__3].r = 0., a[i__3].i = 0.;
00310
00311 }
00312
00313 }
00314
00315
00316
00317 i__1 = *n;
00318 for (j = 1; j <= i__1; ++j) {
00319 i__2 = *n;
00320 for (i__ = j + 1; i__ <= i__2; ++i__) {
00321 i__3 = j + i__ * a_dim1;
00322 d_cnjg(&z__1, &a[i__ + j * a_dim1]);
00323 a[i__3].r = z__1.r, a[i__3].i = z__1.i;
00324
00325 }
00326
00327 }
00328 return 0;
00329
00330
00331
00332 }