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