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__1 = 1;
00021 static integer c__0 = 0;
00022 static integer c__5 = 5;
00023
00024 int clatme_(integer *n, char *dist, integer *iseed, complex *
00025 d__, integer *mode, real *cond, complex *dmax__, char *ei, char *
00026 rsign, char *upper, char *sim, real *ds, integer *modes, real *conds,
00027 integer *kl, integer *ku, real *anorm, complex *a, integer *lda,
00028 complex *work, integer *info)
00029 {
00030
00031 integer a_dim1, a_offset, i__1, i__2;
00032 real r__1, r__2;
00033 complex q__1, q__2;
00034
00035
00036 double c_abs(complex *);
00037 void r_cnjg(complex *, complex *);
00038
00039
00040 integer i__, j, ic, jc, ir, jcr;
00041 complex tau;
00042 logical bads;
00043 integer isim;
00044 real temp;
00045 extern int cgerc_(integer *, integer *, complex *,
00046 complex *, integer *, complex *, integer *, complex *, integer *);
00047 complex alpha;
00048 extern int cscal_(integer *, complex *, complex *,
00049 integer *);
00050 extern logical lsame_(char *, char *);
00051 extern int cgemv_(char *, integer *, integer *, complex *
00052 , complex *, integer *, complex *, integer *, complex *, complex *
00053 , integer *);
00054 integer iinfo;
00055 real tempa[1];
00056 integer icols, idist;
00057 extern int ccopy_(integer *, complex *, integer *,
00058 complex *, integer *);
00059 integer irows;
00060 extern int clatm1_(integer *, real *, integer *, integer
00061 *, integer *, complex *, integer *, integer *), slatm1_(integer *,
00062 real *, integer *, integer *, integer *, real *, integer *,
00063 integer *);
00064 extern doublereal clange_(char *, integer *, integer *, complex *,
00065 integer *, real *);
00066 extern int clarge_(integer *, complex *, integer *,
00067 integer *, complex *, integer *), clarfg_(integer *, complex *,
00068 complex *, integer *, complex *), clacgv_(integer *, complex *,
00069 integer *);
00070 extern VOID clarnd_(complex *, integer *, integer *);
00071 real ralpha;
00072 extern int csscal_(integer *, real *, complex *, integer
00073 *), claset_(char *, integer *, integer *, complex *, complex *,
00074 complex *, integer *), xerbla_(char *, integer *),
00075 clarnv_(integer *, integer *, integer *, complex *);
00076 integer irsign, iupper;
00077 complex xnorms;
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
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 --iseed;
00304 --d__;
00305 --ds;
00306 a_dim1 = *lda;
00307 a_offset = 1 + a_dim1;
00308 a -= a_offset;
00309 --work;
00310
00311
00312 *info = 0;
00313
00314
00315
00316 if (*n == 0) {
00317 return 0;
00318 }
00319
00320
00321
00322 if (lsame_(dist, "U")) {
00323 idist = 1;
00324 } else if (lsame_(dist, "S")) {
00325 idist = 2;
00326 } else if (lsame_(dist, "N")) {
00327 idist = 3;
00328 } else if (lsame_(dist, "D")) {
00329 idist = 4;
00330 } else {
00331 idist = -1;
00332 }
00333
00334
00335
00336 if (lsame_(rsign, "T")) {
00337 irsign = 1;
00338 } else if (lsame_(rsign, "F")) {
00339 irsign = 0;
00340 } else {
00341 irsign = -1;
00342 }
00343
00344
00345
00346 if (lsame_(upper, "T")) {
00347 iupper = 1;
00348 } else if (lsame_(upper, "F")) {
00349 iupper = 0;
00350 } else {
00351 iupper = -1;
00352 }
00353
00354
00355
00356 if (lsame_(sim, "T")) {
00357 isim = 1;
00358 } else if (lsame_(sim, "F")) {
00359 isim = 0;
00360 } else {
00361 isim = -1;
00362 }
00363
00364
00365
00366 bads = FALSE_;
00367 if (*modes == 0 && isim == 1) {
00368 i__1 = *n;
00369 for (j = 1; j <= i__1; ++j) {
00370 if (ds[j] == 0.f) {
00371 bads = TRUE_;
00372 }
00373
00374 }
00375 }
00376
00377
00378
00379 if (*n < 0) {
00380 *info = -1;
00381 } else if (idist == -1) {
00382 *info = -2;
00383 } else if (abs(*mode) > 6) {
00384 *info = -5;
00385 } else if (*mode != 0 && abs(*mode) != 6 && *cond < 1.f) {
00386 *info = -6;
00387 } else if (irsign == -1) {
00388 *info = -9;
00389 } else if (iupper == -1) {
00390 *info = -10;
00391 } else if (isim == -1) {
00392 *info = -11;
00393 } else if (bads) {
00394 *info = -12;
00395 } else if (isim == 1 && abs(*modes) > 5) {
00396 *info = -13;
00397 } else if (isim == 1 && *modes != 0 && *conds < 1.f) {
00398 *info = -14;
00399 } else if (*kl < 1) {
00400 *info = -15;
00401 } else if (*ku < 1 || *ku < *n - 1 && *kl < *n - 1) {
00402 *info = -16;
00403 } else if (*lda < max(1,*n)) {
00404 *info = -19;
00405 }
00406
00407 if (*info != 0) {
00408 i__1 = -(*info);
00409 xerbla_("CLATME", &i__1);
00410 return 0;
00411 }
00412
00413
00414
00415 for (i__ = 1; i__ <= 4; ++i__) {
00416 iseed[i__] = (i__1 = iseed[i__], abs(i__1)) % 4096;
00417
00418 }
00419
00420 if (iseed[4] % 2 != 1) {
00421 ++iseed[4];
00422 }
00423
00424
00425
00426
00427
00428 clatm1_(mode, cond, &irsign, &idist, &iseed[1], &d__[1], n, &iinfo);
00429 if (iinfo != 0) {
00430 *info = 1;
00431 return 0;
00432 }
00433 if (*mode != 0 && abs(*mode) != 6) {
00434
00435
00436
00437 temp = c_abs(&d__[1]);
00438 i__1 = *n;
00439 for (i__ = 2; i__ <= i__1; ++i__) {
00440
00441 r__1 = temp, r__2 = c_abs(&d__[i__]);
00442 temp = dmax(r__1,r__2);
00443
00444 }
00445
00446 if (temp > 0.f) {
00447 q__1.r = dmax__->r / temp, q__1.i = dmax__->i / temp;
00448 alpha.r = q__1.r, alpha.i = q__1.i;
00449 } else {
00450 *info = 2;
00451 return 0;
00452 }
00453
00454 cscal_(n, &alpha, &d__[1], &c__1);
00455
00456 }
00457
00458 claset_("Full", n, n, &c_b1, &c_b1, &a[a_offset], lda);
00459 i__1 = *lda + 1;
00460 ccopy_(n, &d__[1], &c__1, &a[a_offset], &i__1);
00461
00462
00463
00464 if (iupper != 0) {
00465 i__1 = *n;
00466 for (jc = 2; jc <= i__1; ++jc) {
00467 i__2 = jc - 1;
00468 clarnv_(&idist, &iseed[1], &i__2, &a[jc * a_dim1 + 1]);
00469
00470 }
00471 }
00472
00473
00474
00475
00476
00477
00478
00479
00480 if (isim != 0) {
00481
00482
00483
00484
00485 slatm1_(modes, conds, &c__0, &c__0, &iseed[1], &ds[1], n, &iinfo);
00486 if (iinfo != 0) {
00487 *info = 3;
00488 return 0;
00489 }
00490
00491
00492
00493 clarge_(n, &a[a_offset], lda, &iseed[1], &work[1], &iinfo);
00494 if (iinfo != 0) {
00495 *info = 4;
00496 return 0;
00497 }
00498
00499
00500
00501 i__1 = *n;
00502 for (j = 1; j <= i__1; ++j) {
00503 csscal_(n, &ds[j], &a[j + a_dim1], lda);
00504 if (ds[j] != 0.f) {
00505 r__1 = 1.f / ds[j];
00506 csscal_(n, &r__1, &a[j * a_dim1 + 1], &c__1);
00507 } else {
00508 *info = 5;
00509 return 0;
00510 }
00511
00512 }
00513
00514
00515
00516 clarge_(n, &a[a_offset], lda, &iseed[1], &work[1], &iinfo);
00517 if (iinfo != 0) {
00518 *info = 4;
00519 return 0;
00520 }
00521 }
00522
00523
00524
00525 if (*kl < *n - 1) {
00526
00527
00528
00529 i__1 = *n - 1;
00530 for (jcr = *kl + 1; jcr <= i__1; ++jcr) {
00531 ic = jcr - *kl;
00532 irows = *n + 1 - jcr;
00533 icols = *n + *kl - jcr;
00534
00535 ccopy_(&irows, &a[jcr + ic * a_dim1], &c__1, &work[1], &c__1);
00536 xnorms.r = work[1].r, xnorms.i = work[1].i;
00537 clarfg_(&irows, &xnorms, &work[2], &c__1, &tau);
00538 r_cnjg(&q__1, &tau);
00539 tau.r = q__1.r, tau.i = q__1.i;
00540 work[1].r = 1.f, work[1].i = 0.f;
00541 clarnd_(&q__1, &c__5, &iseed[1]);
00542 alpha.r = q__1.r, alpha.i = q__1.i;
00543
00544 cgemv_("C", &irows, &icols, &c_b2, &a[jcr + (ic + 1) * a_dim1],
00545 lda, &work[1], &c__1, &c_b1, &work[irows + 1], &c__1);
00546 q__1.r = -tau.r, q__1.i = -tau.i;
00547 cgerc_(&irows, &icols, &q__1, &work[1], &c__1, &work[irows + 1], &
00548 c__1, &a[jcr + (ic + 1) * a_dim1], lda);
00549
00550 cgemv_("N", n, &irows, &c_b2, &a[jcr * a_dim1 + 1], lda, &work[1],
00551 &c__1, &c_b1, &work[irows + 1], &c__1);
00552 r_cnjg(&q__2, &tau);
00553 q__1.r = -q__2.r, q__1.i = -q__2.i;
00554 cgerc_(n, &irows, &q__1, &work[irows + 1], &c__1, &work[1], &c__1,
00555 &a[jcr * a_dim1 + 1], lda);
00556
00557 i__2 = jcr + ic * a_dim1;
00558 a[i__2].r = xnorms.r, a[i__2].i = xnorms.i;
00559 i__2 = irows - 1;
00560 claset_("Full", &i__2, &c__1, &c_b1, &c_b1, &a[jcr + 1 + ic *
00561 a_dim1], lda);
00562
00563 i__2 = icols + 1;
00564 cscal_(&i__2, &alpha, &a[jcr + ic * a_dim1], lda);
00565 r_cnjg(&q__1, &alpha);
00566 cscal_(n, &q__1, &a[jcr * a_dim1 + 1], &c__1);
00567
00568 }
00569 } else if (*ku < *n - 1) {
00570
00571
00572
00573 i__1 = *n - 1;
00574 for (jcr = *ku + 1; jcr <= i__1; ++jcr) {
00575 ir = jcr - *ku;
00576 irows = *n + *ku - jcr;
00577 icols = *n + 1 - jcr;
00578
00579 ccopy_(&icols, &a[ir + jcr * a_dim1], lda, &work[1], &c__1);
00580 xnorms.r = work[1].r, xnorms.i = work[1].i;
00581 clarfg_(&icols, &xnorms, &work[2], &c__1, &tau);
00582 r_cnjg(&q__1, &tau);
00583 tau.r = q__1.r, tau.i = q__1.i;
00584 work[1].r = 1.f, work[1].i = 0.f;
00585 i__2 = icols - 1;
00586 clacgv_(&i__2, &work[2], &c__1);
00587 clarnd_(&q__1, &c__5, &iseed[1]);
00588 alpha.r = q__1.r, alpha.i = q__1.i;
00589
00590 cgemv_("N", &irows, &icols, &c_b2, &a[ir + 1 + jcr * a_dim1], lda,
00591 &work[1], &c__1, &c_b1, &work[icols + 1], &c__1);
00592 q__1.r = -tau.r, q__1.i = -tau.i;
00593 cgerc_(&irows, &icols, &q__1, &work[icols + 1], &c__1, &work[1], &
00594 c__1, &a[ir + 1 + jcr * a_dim1], lda);
00595
00596 cgemv_("C", &icols, n, &c_b2, &a[jcr + a_dim1], lda, &work[1], &
00597 c__1, &c_b1, &work[icols + 1], &c__1);
00598 r_cnjg(&q__2, &tau);
00599 q__1.r = -q__2.r, q__1.i = -q__2.i;
00600 cgerc_(&icols, n, &q__1, &work[1], &c__1, &work[icols + 1], &c__1,
00601 &a[jcr + a_dim1], lda);
00602
00603 i__2 = ir + jcr * a_dim1;
00604 a[i__2].r = xnorms.r, a[i__2].i = xnorms.i;
00605 i__2 = icols - 1;
00606 claset_("Full", &c__1, &i__2, &c_b1, &c_b1, &a[ir + (jcr + 1) *
00607 a_dim1], lda);
00608
00609 i__2 = irows + 1;
00610 cscal_(&i__2, &alpha, &a[ir + jcr * a_dim1], &c__1);
00611 r_cnjg(&q__1, &alpha);
00612 cscal_(n, &q__1, &a[jcr + a_dim1], lda);
00613
00614 }
00615 }
00616
00617
00618
00619 if (*anorm >= 0.f) {
00620 temp = clange_("M", n, n, &a[a_offset], lda, tempa);
00621 if (temp > 0.f) {
00622 ralpha = *anorm / temp;
00623 i__1 = *n;
00624 for (j = 1; j <= i__1; ++j) {
00625 csscal_(n, &ralpha, &a[j * a_dim1 + 1], &c__1);
00626
00627 }
00628 }
00629 }
00630
00631 return 0;
00632
00633
00634
00635 }