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 zlagsy_(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, i__4, i__5, i__6, i__7, i__8,
00029 i__9;
00030 doublereal d__1;
00031 doublecomplex z__1, z__2, z__3, z__4;
00032
00033
00034 double z_abs(doublecomplex *);
00035 void z_div(doublecomplex *, doublecomplex *, doublecomplex *);
00036
00037
00038 integer i__, j, ii, jj;
00039 doublecomplex wa, wb;
00040 doublereal wn;
00041 doublecomplex tau, alpha;
00042 extern int zgerc_(integer *, integer *, doublecomplex *,
00043 doublecomplex *, integer *, doublecomplex *, integer *,
00044 doublecomplex *, integer *), zscal_(integer *, doublecomplex *,
00045 doublecomplex *, integer *);
00046 extern VOID zdotc_(doublecomplex *, integer *,
00047 doublecomplex *, integer *, doublecomplex *, integer *);
00048 extern int zgemv_(char *, integer *, integer *,
00049 doublecomplex *, doublecomplex *, integer *, doublecomplex *,
00050 integer *, doublecomplex *, doublecomplex *, integer *),
00051 zaxpy_(integer *, doublecomplex *, doublecomplex *, integer *,
00052 doublecomplex *, integer *), zsymv_(char *, integer *,
00053 doublecomplex *, doublecomplex *, integer *, doublecomplex *,
00054 integer *, doublecomplex *, doublecomplex *, integer *);
00055 extern doublereal dznrm2_(integer *, doublecomplex *, integer *);
00056 extern int xerbla_(char *, integer *), zlacgv_(
00057 integer *, doublecomplex *, integer *), zlarnv_(integer *,
00058 integer *, integer *, doublecomplex *);
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 --d__;
00128 a_dim1 = *lda;
00129 a_offset = 1 + a_dim1;
00130 a -= a_offset;
00131 --iseed;
00132 --work;
00133
00134
00135 *info = 0;
00136 if (*n < 0) {
00137 *info = -1;
00138 } else if (*k < 0 || *k > *n - 1) {
00139 *info = -2;
00140 } else if (*lda < max(1,*n)) {
00141 *info = -5;
00142 }
00143 if (*info < 0) {
00144 i__1 = -(*info);
00145 xerbla_("ZLAGSY", &i__1);
00146 return 0;
00147 }
00148
00149
00150
00151 i__1 = *n;
00152 for (j = 1; j <= i__1; ++j) {
00153 i__2 = *n;
00154 for (i__ = j + 1; i__ <= i__2; ++i__) {
00155 i__3 = i__ + j * a_dim1;
00156 a[i__3].r = 0., a[i__3].i = 0.;
00157
00158 }
00159
00160 }
00161 i__1 = *n;
00162 for (i__ = 1; i__ <= i__1; ++i__) {
00163 i__2 = i__ + i__ * a_dim1;
00164 i__3 = i__;
00165 a[i__2].r = d__[i__3], a[i__2].i = 0.;
00166
00167 }
00168
00169
00170
00171 for (i__ = *n - 1; i__ >= 1; --i__) {
00172
00173
00174
00175 i__1 = *n - i__ + 1;
00176 zlarnv_(&c__3, &iseed[1], &i__1, &work[1]);
00177 i__1 = *n - i__ + 1;
00178 wn = dznrm2_(&i__1, &work[1], &c__1);
00179 d__1 = wn / z_abs(&work[1]);
00180 z__1.r = d__1 * work[1].r, z__1.i = d__1 * work[1].i;
00181 wa.r = z__1.r, wa.i = z__1.i;
00182 if (wn == 0.) {
00183 tau.r = 0., tau.i = 0.;
00184 } else {
00185 z__1.r = work[1].r + wa.r, z__1.i = work[1].i + wa.i;
00186 wb.r = z__1.r, wb.i = z__1.i;
00187 i__1 = *n - i__;
00188 z_div(&z__1, &c_b2, &wb);
00189 zscal_(&i__1, &z__1, &work[2], &c__1);
00190 work[1].r = 1., work[1].i = 0.;
00191 z_div(&z__1, &wb, &wa);
00192 d__1 = z__1.r;
00193 tau.r = d__1, tau.i = 0.;
00194 }
00195
00196
00197
00198
00199
00200
00201 i__1 = *n - i__ + 1;
00202 zlacgv_(&i__1, &work[1], &c__1);
00203 i__1 = *n - i__ + 1;
00204 zsymv_("Lower", &i__1, &tau, &a[i__ + i__ * a_dim1], lda, &work[1], &
00205 c__1, &c_b1, &work[*n + 1], &c__1);
00206 i__1 = *n - i__ + 1;
00207 zlacgv_(&i__1, &work[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[1], &c__1, &work[*n + 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
00225
00226
00227 i__1 = *n;
00228 for (jj = i__; jj <= i__1; ++jj) {
00229 i__2 = *n;
00230 for (ii = jj; ii <= i__2; ++ii) {
00231 i__3 = ii + jj * a_dim1;
00232 i__4 = ii + jj * a_dim1;
00233 i__5 = ii - i__ + 1;
00234 i__6 = *n + jj - i__ + 1;
00235 z__3.r = work[i__5].r * work[i__6].r - work[i__5].i * work[
00236 i__6].i, z__3.i = work[i__5].r * work[i__6].i + work[
00237 i__5].i * work[i__6].r;
00238 z__2.r = a[i__4].r - z__3.r, z__2.i = a[i__4].i - z__3.i;
00239 i__7 = *n + ii - i__ + 1;
00240 i__8 = jj - i__ + 1;
00241 z__4.r = work[i__7].r * work[i__8].r - work[i__7].i * work[
00242 i__8].i, z__4.i = work[i__7].r * work[i__8].i + work[
00243 i__7].i * work[i__8].r;
00244 z__1.r = z__2.r - z__4.r, z__1.i = z__2.i - z__4.i;
00245 a[i__3].r = z__1.r, a[i__3].i = z__1.i;
00246
00247 }
00248
00249 }
00250
00251 }
00252
00253
00254
00255 i__1 = *n - 1 - *k;
00256 for (i__ = 1; i__ <= i__1; ++i__) {
00257
00258
00259
00260 i__2 = *n - *k - i__ + 1;
00261 wn = dznrm2_(&i__2, &a[*k + i__ + i__ * a_dim1], &c__1);
00262 d__1 = wn / z_abs(&a[*k + i__ + i__ * a_dim1]);
00263 i__2 = *k + i__ + i__ * a_dim1;
00264 z__1.r = d__1 * a[i__2].r, z__1.i = d__1 * a[i__2].i;
00265 wa.r = z__1.r, wa.i = z__1.i;
00266 if (wn == 0.) {
00267 tau.r = 0., tau.i = 0.;
00268 } else {
00269 i__2 = *k + i__ + i__ * a_dim1;
00270 z__1.r = a[i__2].r + wa.r, z__1.i = a[i__2].i + wa.i;
00271 wb.r = z__1.r, wb.i = z__1.i;
00272 i__2 = *n - *k - i__;
00273 z_div(&z__1, &c_b2, &wb);
00274 zscal_(&i__2, &z__1, &a[*k + i__ + 1 + i__ * a_dim1], &c__1);
00275 i__2 = *k + i__ + i__ * a_dim1;
00276 a[i__2].r = 1., a[i__2].i = 0.;
00277 z_div(&z__1, &wb, &wa);
00278 d__1 = z__1.r;
00279 tau.r = d__1, tau.i = 0.;
00280 }
00281
00282
00283
00284 i__2 = *n - *k - i__ + 1;
00285 i__3 = *k - 1;
00286 zgemv_("Conjugate transpose", &i__2, &i__3, &c_b2, &a[*k + i__ + (i__
00287 + 1) * a_dim1], lda, &a[*k + i__ + i__ * a_dim1], &c__1, &
00288 c_b1, &work[1], &c__1);
00289 i__2 = *n - *k - i__ + 1;
00290 i__3 = *k - 1;
00291 z__1.r = -tau.r, z__1.i = -tau.i;
00292 zgerc_(&i__2, &i__3, &z__1, &a[*k + i__ + i__ * a_dim1], &c__1, &work[
00293 1], &c__1, &a[*k + i__ + (i__ + 1) * a_dim1], lda);
00294
00295
00296
00297
00298
00299 i__2 = *n - *k - i__ + 1;
00300 zlacgv_(&i__2, &a[*k + i__ + i__ * a_dim1], &c__1);
00301 i__2 = *n - *k - i__ + 1;
00302 zsymv_("Lower", &i__2, &tau, &a[*k + i__ + (*k + i__) * a_dim1], lda,
00303 &a[*k + i__ + i__ * a_dim1], &c__1, &c_b1, &work[1], &c__1);
00304 i__2 = *n - *k - i__ + 1;
00305 zlacgv_(&i__2, &a[*k + i__ + i__ * a_dim1], &c__1);
00306
00307
00308
00309 z__3.r = -.5, z__3.i = -0.;
00310 z__2.r = z__3.r * tau.r - z__3.i * tau.i, z__2.i = z__3.r * tau.i +
00311 z__3.i * tau.r;
00312 i__2 = *n - *k - i__ + 1;
00313 zdotc_(&z__4, &i__2, &a[*k + i__ + i__ * a_dim1], &c__1, &work[1], &
00314 c__1);
00315 z__1.r = z__2.r * z__4.r - z__2.i * z__4.i, z__1.i = z__2.r * z__4.i
00316 + z__2.i * z__4.r;
00317 alpha.r = z__1.r, alpha.i = z__1.i;
00318 i__2 = *n - *k - i__ + 1;
00319 zaxpy_(&i__2, &alpha, &a[*k + i__ + i__ * a_dim1], &c__1, &work[1], &
00320 c__1);
00321
00322
00323
00324
00325
00326
00327 i__2 = *n;
00328 for (jj = *k + i__; jj <= i__2; ++jj) {
00329 i__3 = *n;
00330 for (ii = jj; ii <= i__3; ++ii) {
00331 i__4 = ii + jj * a_dim1;
00332 i__5 = ii + jj * a_dim1;
00333 i__6 = ii + i__ * a_dim1;
00334 i__7 = jj - *k - i__ + 1;
00335 z__3.r = a[i__6].r * work[i__7].r - a[i__6].i * work[i__7].i,
00336 z__3.i = a[i__6].r * work[i__7].i + a[i__6].i * work[
00337 i__7].r;
00338 z__2.r = a[i__5].r - z__3.r, z__2.i = a[i__5].i - z__3.i;
00339 i__8 = ii - *k - i__ + 1;
00340 i__9 = jj + i__ * a_dim1;
00341 z__4.r = work[i__8].r * a[i__9].r - work[i__8].i * a[i__9].i,
00342 z__4.i = work[i__8].r * a[i__9].i + work[i__8].i * a[
00343 i__9].r;
00344 z__1.r = z__2.r - z__4.r, z__1.i = z__2.i - z__4.i;
00345 a[i__4].r = z__1.r, a[i__4].i = z__1.i;
00346
00347 }
00348
00349 }
00350
00351 i__2 = *k + i__ + i__ * a_dim1;
00352 z__1.r = -wa.r, z__1.i = -wa.i;
00353 a[i__2].r = z__1.r, a[i__2].i = z__1.i;
00354 i__2 = *n;
00355 for (j = *k + i__ + 1; j <= i__2; ++j) {
00356 i__3 = j + i__ * a_dim1;
00357 a[i__3].r = 0., a[i__3].i = 0.;
00358
00359 }
00360
00361 }
00362
00363
00364
00365 i__1 = *n;
00366 for (j = 1; j <= i__1; ++j) {
00367 i__2 = *n;
00368 for (i__ = j + 1; i__ <= i__2; ++i__) {
00369 i__3 = j + i__ * a_dim1;
00370 i__4 = i__ + j * a_dim1;
00371 a[i__3].r = a[i__4].r, a[i__3].i = a[i__4].i;
00372
00373 }
00374
00375 }
00376 return 0;
00377
00378
00379
00380 }