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 clagsy_(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, i__4, i__5, i__6, i__7, i__8,
00028 i__9;
00029 real r__1;
00030 complex q__1, q__2, q__3, q__4;
00031
00032
00033 double c_abs(complex *);
00034 void c_div(complex *, complex *, complex *);
00035
00036
00037 integer i__, j, ii, jj;
00038 complex wa, wb;
00039 real wn;
00040 complex tau;
00041 extern int cgerc_(integer *, integer *, complex *,
00042 complex *, integer *, complex *, integer *, complex *, integer *);
00043 complex alpha;
00044 extern int cscal_(integer *, complex *, complex *,
00045 integer *);
00046 extern VOID cdotc_(complex *, integer *, complex *, integer
00047 *, complex *, integer *);
00048 extern int cgemv_(char *, integer *, integer *, complex *
00049 , complex *, integer *, complex *, integer *, complex *, complex *
00050 , integer *), caxpy_(integer *, complex *, complex *,
00051 integer *, complex *, integer *), csymv_(char *, integer *,
00052 complex *, complex *, integer *, complex *, integer *, complex *,
00053 complex *, integer *);
00054 extern doublereal scnrm2_(integer *, complex *, integer *);
00055 extern int clacgv_(integer *, complex *, integer *),
00056 xerbla_(char *, integer *), clarnv_(integer *, integer *,
00057 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_("CLAGSY", &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 clacgv_(&i__1, &work[1], &c__1);
00202 i__1 = *n - i__ + 1;
00203 csymv_("Lower", &i__1, &tau, &a[i__ + i__ * a_dim1], lda, &work[1], &
00204 c__1, &c_b1, &work[*n + 1], &c__1);
00205 i__1 = *n - i__ + 1;
00206 clacgv_(&i__1, &work[1], &c__1);
00207
00208
00209
00210 q__3.r = -.5f, q__3.i = -0.f;
00211 q__2.r = q__3.r * tau.r - q__3.i * tau.i, q__2.i = q__3.r * tau.i +
00212 q__3.i * tau.r;
00213 i__1 = *n - i__ + 1;
00214 cdotc_(&q__4, &i__1, &work[1], &c__1, &work[*n + 1], &c__1);
00215 q__1.r = q__2.r * q__4.r - q__2.i * q__4.i, q__1.i = q__2.r * q__4.i
00216 + q__2.i * q__4.r;
00217 alpha.r = q__1.r, alpha.i = q__1.i;
00218 i__1 = *n - i__ + 1;
00219 caxpy_(&i__1, &alpha, &work[1], &c__1, &work[*n + 1], &c__1);
00220
00221
00222
00223
00224
00225
00226 i__1 = *n;
00227 for (jj = i__; jj <= i__1; ++jj) {
00228 i__2 = *n;
00229 for (ii = jj; ii <= i__2; ++ii) {
00230 i__3 = ii + jj * a_dim1;
00231 i__4 = ii + jj * a_dim1;
00232 i__5 = ii - i__ + 1;
00233 i__6 = *n + jj - i__ + 1;
00234 q__3.r = work[i__5].r * work[i__6].r - work[i__5].i * work[
00235 i__6].i, q__3.i = work[i__5].r * work[i__6].i + work[
00236 i__5].i * work[i__6].r;
00237 q__2.r = a[i__4].r - q__3.r, q__2.i = a[i__4].i - q__3.i;
00238 i__7 = *n + ii - i__ + 1;
00239 i__8 = jj - i__ + 1;
00240 q__4.r = work[i__7].r * work[i__8].r - work[i__7].i * work[
00241 i__8].i, q__4.i = work[i__7].r * work[i__8].i + work[
00242 i__7].i * work[i__8].r;
00243 q__1.r = q__2.r - q__4.r, q__1.i = q__2.i - q__4.i;
00244 a[i__3].r = q__1.r, a[i__3].i = q__1.i;
00245
00246 }
00247
00248 }
00249
00250 }
00251
00252
00253
00254 i__1 = *n - 1 - *k;
00255 for (i__ = 1; i__ <= i__1; ++i__) {
00256
00257
00258
00259 i__2 = *n - *k - i__ + 1;
00260 wn = scnrm2_(&i__2, &a[*k + i__ + i__ * a_dim1], &c__1);
00261 r__1 = wn / c_abs(&a[*k + i__ + i__ * a_dim1]);
00262 i__2 = *k + i__ + i__ * a_dim1;
00263 q__1.r = r__1 * a[i__2].r, q__1.i = r__1 * a[i__2].i;
00264 wa.r = q__1.r, wa.i = q__1.i;
00265 if (wn == 0.f) {
00266 tau.r = 0.f, tau.i = 0.f;
00267 } else {
00268 i__2 = *k + i__ + i__ * a_dim1;
00269 q__1.r = a[i__2].r + wa.r, q__1.i = a[i__2].i + wa.i;
00270 wb.r = q__1.r, wb.i = q__1.i;
00271 i__2 = *n - *k - i__;
00272 c_div(&q__1, &c_b2, &wb);
00273 cscal_(&i__2, &q__1, &a[*k + i__ + 1 + i__ * a_dim1], &c__1);
00274 i__2 = *k + i__ + i__ * a_dim1;
00275 a[i__2].r = 1.f, a[i__2].i = 0.f;
00276 c_div(&q__1, &wb, &wa);
00277 r__1 = q__1.r;
00278 tau.r = r__1, tau.i = 0.f;
00279 }
00280
00281
00282
00283 i__2 = *n - *k - i__ + 1;
00284 i__3 = *k - 1;
00285 cgemv_("Conjugate transpose", &i__2, &i__3, &c_b2, &a[*k + i__ + (i__
00286 + 1) * a_dim1], lda, &a[*k + i__ + i__ * a_dim1], &c__1, &
00287 c_b1, &work[1], &c__1);
00288 i__2 = *n - *k - i__ + 1;
00289 i__3 = *k - 1;
00290 q__1.r = -tau.r, q__1.i = -tau.i;
00291 cgerc_(&i__2, &i__3, &q__1, &a[*k + i__ + i__ * a_dim1], &c__1, &work[
00292 1], &c__1, &a[*k + i__ + (i__ + 1) * a_dim1], lda);
00293
00294
00295
00296
00297
00298 i__2 = *n - *k - i__ + 1;
00299 clacgv_(&i__2, &a[*k + i__ + i__ * a_dim1], &c__1);
00300 i__2 = *n - *k - i__ + 1;
00301 csymv_("Lower", &i__2, &tau, &a[*k + i__ + (*k + i__) * a_dim1], lda,
00302 &a[*k + i__ + i__ * a_dim1], &c__1, &c_b1, &work[1], &c__1);
00303 i__2 = *n - *k - i__ + 1;
00304 clacgv_(&i__2, &a[*k + i__ + i__ * a_dim1], &c__1);
00305
00306
00307
00308 q__3.r = -.5f, q__3.i = -0.f;
00309 q__2.r = q__3.r * tau.r - q__3.i * tau.i, q__2.i = q__3.r * tau.i +
00310 q__3.i * tau.r;
00311 i__2 = *n - *k - i__ + 1;
00312 cdotc_(&q__4, &i__2, &a[*k + i__ + i__ * a_dim1], &c__1, &work[1], &
00313 c__1);
00314 q__1.r = q__2.r * q__4.r - q__2.i * q__4.i, q__1.i = q__2.r * q__4.i
00315 + q__2.i * q__4.r;
00316 alpha.r = q__1.r, alpha.i = q__1.i;
00317 i__2 = *n - *k - i__ + 1;
00318 caxpy_(&i__2, &alpha, &a[*k + i__ + i__ * a_dim1], &c__1, &work[1], &
00319 c__1);
00320
00321
00322
00323
00324
00325
00326 i__2 = *n;
00327 for (jj = *k + i__; jj <= i__2; ++jj) {
00328 i__3 = *n;
00329 for (ii = jj; ii <= i__3; ++ii) {
00330 i__4 = ii + jj * a_dim1;
00331 i__5 = ii + jj * a_dim1;
00332 i__6 = ii + i__ * a_dim1;
00333 i__7 = jj - *k - i__ + 1;
00334 q__3.r = a[i__6].r * work[i__7].r - a[i__6].i * work[i__7].i,
00335 q__3.i = a[i__6].r * work[i__7].i + a[i__6].i * work[
00336 i__7].r;
00337 q__2.r = a[i__5].r - q__3.r, q__2.i = a[i__5].i - q__3.i;
00338 i__8 = ii - *k - i__ + 1;
00339 i__9 = jj + i__ * a_dim1;
00340 q__4.r = work[i__8].r * a[i__9].r - work[i__8].i * a[i__9].i,
00341 q__4.i = work[i__8].r * a[i__9].i + work[i__8].i * a[
00342 i__9].r;
00343 q__1.r = q__2.r - q__4.r, q__1.i = q__2.i - q__4.i;
00344 a[i__4].r = q__1.r, a[i__4].i = q__1.i;
00345
00346 }
00347
00348 }
00349
00350 i__2 = *k + i__ + i__ * a_dim1;
00351 q__1.r = -wa.r, q__1.i = -wa.i;
00352 a[i__2].r = q__1.r, a[i__2].i = q__1.i;
00353 i__2 = *n;
00354 for (j = *k + i__ + 1; j <= i__2; ++j) {
00355 i__3 = j + i__ * a_dim1;
00356 a[i__3].r = 0.f, a[i__3].i = 0.f;
00357
00358 }
00359
00360 }
00361
00362
00363
00364 i__1 = *n;
00365 for (j = 1; j <= i__1; ++j) {
00366 i__2 = *n;
00367 for (i__ = j + 1; i__ <= i__2; ++i__) {
00368 i__3 = j + i__ * a_dim1;
00369 i__4 = i__ + j * a_dim1;
00370 a[i__3].r = a[i__4].r, a[i__3].i = a[i__4].i;
00371
00372 }
00373
00374 }
00375 return 0;
00376
00377
00378
00379 }