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__1 = 1;
00021 static integer c__0 = 0;
00022 static integer c__5 = 5;
00023
00024 int zlatme_(integer *n, char *dist, integer *iseed,
00025 doublecomplex *d__, integer *mode, doublereal *cond, doublecomplex *
00026 dmax__, char *ei, char *rsign, char *upper, char *sim, doublereal *ds,
00027 integer *modes, doublereal *conds, integer *kl, integer *ku,
00028 doublereal *anorm, doublecomplex *a, integer *lda, doublecomplex *
00029 work, integer *info)
00030 {
00031
00032 integer a_dim1, a_offset, i__1, i__2;
00033 doublereal d__1, d__2;
00034 doublecomplex z__1, z__2;
00035
00036
00037 double z_abs(doublecomplex *);
00038 void d_cnjg(doublecomplex *, doublecomplex *);
00039
00040
00041 integer i__, j, ic, jc, ir, jcr;
00042 doublecomplex tau;
00043 logical bads;
00044 integer isim;
00045 doublereal temp;
00046 doublecomplex alpha;
00047 extern logical lsame_(char *, char *);
00048 integer iinfo;
00049 doublereal tempa[1];
00050 integer icols;
00051 extern int zgerc_(integer *, integer *, doublecomplex *,
00052 doublecomplex *, integer *, doublecomplex *, integer *,
00053 doublecomplex *, integer *);
00054 integer idist;
00055 extern int zscal_(integer *, doublecomplex *,
00056 doublecomplex *, integer *), zgemv_(char *, integer *, integer *,
00057 doublecomplex *, doublecomplex *, integer *, doublecomplex *,
00058 integer *, doublecomplex *, doublecomplex *, integer *);
00059 integer irows;
00060 extern int zcopy_(integer *, doublecomplex *, integer *,
00061 doublecomplex *, integer *), dlatm1_(integer *, doublereal *,
00062 integer *, integer *, integer *, doublereal *, integer *, integer
00063 *), zlatm1_(integer *, doublereal *, integer *, integer *,
00064 integer *, doublecomplex *, integer *, integer *);
00065 doublereal ralpha;
00066 extern int xerbla_(char *, integer *);
00067 extern doublereal zlange_(char *, integer *, integer *, doublecomplex *,
00068 integer *, doublereal *);
00069 extern int zdscal_(integer *, doublereal *,
00070 doublecomplex *, integer *), zlarge_(integer *, doublecomplex *,
00071 integer *, integer *, doublecomplex *, integer *), zlarfg_(
00072 integer *, doublecomplex *, doublecomplex *, integer *,
00073 doublecomplex *), zlacgv_(integer *, doublecomplex *, integer *);
00074 extern VOID zlarnd_(doublecomplex *, integer *,
00075 integer *);
00076 integer irsign;
00077 extern int zlaset_(char *, integer *, integer *,
00078 doublecomplex *, doublecomplex *, doublecomplex *, integer *);
00079 integer iupper;
00080 extern int zlarnv_(integer *, integer *, integer *,
00081 doublecomplex *);
00082 doublecomplex xnorms;
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
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308 --iseed;
00309 --d__;
00310 --ds;
00311 a_dim1 = *lda;
00312 a_offset = 1 + a_dim1;
00313 a -= a_offset;
00314 --work;
00315
00316
00317 *info = 0;
00318
00319
00320
00321 if (*n == 0) {
00322 return 0;
00323 }
00324
00325
00326
00327 if (lsame_(dist, "U")) {
00328 idist = 1;
00329 } else if (lsame_(dist, "S")) {
00330 idist = 2;
00331 } else if (lsame_(dist, "N")) {
00332 idist = 3;
00333 } else if (lsame_(dist, "D")) {
00334 idist = 4;
00335 } else {
00336 idist = -1;
00337 }
00338
00339
00340
00341 if (lsame_(rsign, "T")) {
00342 irsign = 1;
00343 } else if (lsame_(rsign, "F")) {
00344 irsign = 0;
00345 } else {
00346 irsign = -1;
00347 }
00348
00349
00350
00351 if (lsame_(upper, "T")) {
00352 iupper = 1;
00353 } else if (lsame_(upper, "F")) {
00354 iupper = 0;
00355 } else {
00356 iupper = -1;
00357 }
00358
00359
00360
00361 if (lsame_(sim, "T")) {
00362 isim = 1;
00363 } else if (lsame_(sim, "F")) {
00364 isim = 0;
00365 } else {
00366 isim = -1;
00367 }
00368
00369
00370
00371 bads = FALSE_;
00372 if (*modes == 0 && isim == 1) {
00373 i__1 = *n;
00374 for (j = 1; j <= i__1; ++j) {
00375 if (ds[j] == 0.) {
00376 bads = TRUE_;
00377 }
00378
00379 }
00380 }
00381
00382
00383
00384 if (*n < 0) {
00385 *info = -1;
00386 } else if (idist == -1) {
00387 *info = -2;
00388 } else if (abs(*mode) > 6) {
00389 *info = -5;
00390 } else if (*mode != 0 && abs(*mode) != 6 && *cond < 1.) {
00391 *info = -6;
00392 } else if (irsign == -1) {
00393 *info = -9;
00394 } else if (iupper == -1) {
00395 *info = -10;
00396 } else if (isim == -1) {
00397 *info = -11;
00398 } else if (bads) {
00399 *info = -12;
00400 } else if (isim == 1 && abs(*modes) > 5) {
00401 *info = -13;
00402 } else if (isim == 1 && *modes != 0 && *conds < 1.) {
00403 *info = -14;
00404 } else if (*kl < 1) {
00405 *info = -15;
00406 } else if (*ku < 1 || *ku < *n - 1 && *kl < *n - 1) {
00407 *info = -16;
00408 } else if (*lda < max(1,*n)) {
00409 *info = -19;
00410 }
00411
00412 if (*info != 0) {
00413 i__1 = -(*info);
00414 xerbla_("ZLATME", &i__1);
00415 return 0;
00416 }
00417
00418
00419
00420 for (i__ = 1; i__ <= 4; ++i__) {
00421 iseed[i__] = (i__1 = iseed[i__], abs(i__1)) % 4096;
00422
00423 }
00424
00425 if (iseed[4] % 2 != 1) {
00426 ++iseed[4];
00427 }
00428
00429
00430
00431
00432
00433 zlatm1_(mode, cond, &irsign, &idist, &iseed[1], &d__[1], n, &iinfo);
00434 if (iinfo != 0) {
00435 *info = 1;
00436 return 0;
00437 }
00438 if (*mode != 0 && abs(*mode) != 6) {
00439
00440
00441
00442 temp = z_abs(&d__[1]);
00443 i__1 = *n;
00444 for (i__ = 2; i__ <= i__1; ++i__) {
00445
00446 d__1 = temp, d__2 = z_abs(&d__[i__]);
00447 temp = max(d__1,d__2);
00448
00449 }
00450
00451 if (temp > 0.) {
00452 z__1.r = dmax__->r / temp, z__1.i = dmax__->i / temp;
00453 alpha.r = z__1.r, alpha.i = z__1.i;
00454 } else {
00455 *info = 2;
00456 return 0;
00457 }
00458
00459 zscal_(n, &alpha, &d__[1], &c__1);
00460
00461 }
00462
00463 zlaset_("Full", n, n, &c_b1, &c_b1, &a[a_offset], lda);
00464 i__1 = *lda + 1;
00465 zcopy_(n, &d__[1], &c__1, &a[a_offset], &i__1);
00466
00467
00468
00469 if (iupper != 0) {
00470 i__1 = *n;
00471 for (jc = 2; jc <= i__1; ++jc) {
00472 i__2 = jc - 1;
00473 zlarnv_(&idist, &iseed[1], &i__2, &a[jc * a_dim1 + 1]);
00474
00475 }
00476 }
00477
00478
00479
00480
00481
00482
00483
00484
00485 if (isim != 0) {
00486
00487
00488
00489
00490 dlatm1_(modes, conds, &c__0, &c__0, &iseed[1], &ds[1], n, &iinfo);
00491 if (iinfo != 0) {
00492 *info = 3;
00493 return 0;
00494 }
00495
00496
00497
00498 zlarge_(n, &a[a_offset], lda, &iseed[1], &work[1], &iinfo);
00499 if (iinfo != 0) {
00500 *info = 4;
00501 return 0;
00502 }
00503
00504
00505
00506 i__1 = *n;
00507 for (j = 1; j <= i__1; ++j) {
00508 zdscal_(n, &ds[j], &a[j + a_dim1], lda);
00509 if (ds[j] != 0.) {
00510 d__1 = 1. / ds[j];
00511 zdscal_(n, &d__1, &a[j * a_dim1 + 1], &c__1);
00512 } else {
00513 *info = 5;
00514 return 0;
00515 }
00516
00517 }
00518
00519
00520
00521 zlarge_(n, &a[a_offset], lda, &iseed[1], &work[1], &iinfo);
00522 if (iinfo != 0) {
00523 *info = 4;
00524 return 0;
00525 }
00526 }
00527
00528
00529
00530 if (*kl < *n - 1) {
00531
00532
00533
00534 i__1 = *n - 1;
00535 for (jcr = *kl + 1; jcr <= i__1; ++jcr) {
00536 ic = jcr - *kl;
00537 irows = *n + 1 - jcr;
00538 icols = *n + *kl - jcr;
00539
00540 zcopy_(&irows, &a[jcr + ic * a_dim1], &c__1, &work[1], &c__1);
00541 xnorms.r = work[1].r, xnorms.i = work[1].i;
00542 zlarfg_(&irows, &xnorms, &work[2], &c__1, &tau);
00543 d_cnjg(&z__1, &tau);
00544 tau.r = z__1.r, tau.i = z__1.i;
00545 work[1].r = 1., work[1].i = 0.;
00546 zlarnd_(&z__1, &c__5, &iseed[1]);
00547 alpha.r = z__1.r, alpha.i = z__1.i;
00548
00549 zgemv_("C", &irows, &icols, &c_b2, &a[jcr + (ic + 1) * a_dim1],
00550 lda, &work[1], &c__1, &c_b1, &work[irows + 1], &c__1);
00551 z__1.r = -tau.r, z__1.i = -tau.i;
00552 zgerc_(&irows, &icols, &z__1, &work[1], &c__1, &work[irows + 1], &
00553 c__1, &a[jcr + (ic + 1) * a_dim1], lda);
00554
00555 zgemv_("N", n, &irows, &c_b2, &a[jcr * a_dim1 + 1], lda, &work[1],
00556 &c__1, &c_b1, &work[irows + 1], &c__1);
00557 d_cnjg(&z__2, &tau);
00558 z__1.r = -z__2.r, z__1.i = -z__2.i;
00559 zgerc_(n, &irows, &z__1, &work[irows + 1], &c__1, &work[1], &c__1,
00560 &a[jcr * a_dim1 + 1], lda);
00561
00562 i__2 = jcr + ic * a_dim1;
00563 a[i__2].r = xnorms.r, a[i__2].i = xnorms.i;
00564 i__2 = irows - 1;
00565 zlaset_("Full", &i__2, &c__1, &c_b1, &c_b1, &a[jcr + 1 + ic *
00566 a_dim1], lda);
00567
00568 i__2 = icols + 1;
00569 zscal_(&i__2, &alpha, &a[jcr + ic * a_dim1], lda);
00570 d_cnjg(&z__1, &alpha);
00571 zscal_(n, &z__1, &a[jcr * a_dim1 + 1], &c__1);
00572
00573 }
00574 } else if (*ku < *n - 1) {
00575
00576
00577
00578 i__1 = *n - 1;
00579 for (jcr = *ku + 1; jcr <= i__1; ++jcr) {
00580 ir = jcr - *ku;
00581 irows = *n + *ku - jcr;
00582 icols = *n + 1 - jcr;
00583
00584 zcopy_(&icols, &a[ir + jcr * a_dim1], lda, &work[1], &c__1);
00585 xnorms.r = work[1].r, xnorms.i = work[1].i;
00586 zlarfg_(&icols, &xnorms, &work[2], &c__1, &tau);
00587 d_cnjg(&z__1, &tau);
00588 tau.r = z__1.r, tau.i = z__1.i;
00589 work[1].r = 1., work[1].i = 0.;
00590 i__2 = icols - 1;
00591 zlacgv_(&i__2, &work[2], &c__1);
00592 zlarnd_(&z__1, &c__5, &iseed[1]);
00593 alpha.r = z__1.r, alpha.i = z__1.i;
00594
00595 zgemv_("N", &irows, &icols, &c_b2, &a[ir + 1 + jcr * a_dim1], lda,
00596 &work[1], &c__1, &c_b1, &work[icols + 1], &c__1);
00597 z__1.r = -tau.r, z__1.i = -tau.i;
00598 zgerc_(&irows, &icols, &z__1, &work[icols + 1], &c__1, &work[1], &
00599 c__1, &a[ir + 1 + jcr * a_dim1], lda);
00600
00601 zgemv_("C", &icols, n, &c_b2, &a[jcr + a_dim1], lda, &work[1], &
00602 c__1, &c_b1, &work[icols + 1], &c__1);
00603 d_cnjg(&z__2, &tau);
00604 z__1.r = -z__2.r, z__1.i = -z__2.i;
00605 zgerc_(&icols, n, &z__1, &work[1], &c__1, &work[icols + 1], &c__1,
00606 &a[jcr + a_dim1], lda);
00607
00608 i__2 = ir + jcr * a_dim1;
00609 a[i__2].r = xnorms.r, a[i__2].i = xnorms.i;
00610 i__2 = icols - 1;
00611 zlaset_("Full", &c__1, &i__2, &c_b1, &c_b1, &a[ir + (jcr + 1) *
00612 a_dim1], lda);
00613
00614 i__2 = irows + 1;
00615 zscal_(&i__2, &alpha, &a[ir + jcr * a_dim1], &c__1);
00616 d_cnjg(&z__1, &alpha);
00617 zscal_(n, &z__1, &a[jcr + a_dim1], lda);
00618
00619 }
00620 }
00621
00622
00623
00624 if (*anorm >= 0.) {
00625 temp = zlange_("M", n, n, &a[a_offset], lda, tempa);
00626 if (temp > 0.) {
00627 ralpha = *anorm / temp;
00628 i__1 = *n;
00629 for (j = 1; j <= i__1; ++j) {
00630 zdscal_(n, &ralpha, &a[j * a_dim1 + 1], &c__1);
00631
00632 }
00633 }
00634 }
00635
00636 return 0;
00637
00638
00639
00640 }