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 integer c__5 = 5;
00019 static integer c__2 = 2;
00020 static integer c__1 = 1;
00021 static integer c__4 = 4;
00022 static real c_b93 = 2.f;
00023
00024 int clattp_(integer *imat, char *uplo, char *trans, char *
00025 diag, integer *iseed, integer *n, complex *ap, complex *b, complex *
00026 work, real *rwork, integer *info)
00027 {
00028
00029 integer i__1, i__2, i__3, i__4, i__5;
00030 real r__1, r__2;
00031 doublereal d__1, d__2;
00032 complex q__1, q__2, q__3, q__4, q__5;
00033
00034
00035 int s_copy(char *, char *, ftnlen, ftnlen);
00036 void c_div(complex *, complex *, complex *);
00037 double pow_dd(doublereal *, doublereal *), sqrt(doublereal);
00038 void r_cnjg(complex *, complex *);
00039 double c_abs(complex *);
00040
00041
00042 real c__;
00043 integer i__, j;
00044 complex s;
00045 real t, x, y, z__;
00046 integer jc;
00047 complex ra;
00048 integer jj;
00049 complex rb;
00050 integer jl, kl, jr, ku, iy, jx;
00051 real ulp, sfac;
00052 integer mode;
00053 char path[3], dist[1];
00054 real unfl;
00055 extern int crot_(integer *, complex *, integer *,
00056 complex *, integer *, real *, complex *);
00057 real rexp;
00058 char type__[1];
00059 real texp;
00060 complex star1, plus1, plus2;
00061 real bscal;
00062 extern logical lsame_(char *, char *);
00063 real tscal;
00064 complex ctemp;
00065 real anorm, bnorm, tleft;
00066 extern int crotg_(complex *, complex *, real *, complex *
00067 );
00068 logical upper;
00069 extern int clatb4_(char *, integer *, integer *, integer
00070 *, char *, integer *, integer *, real *, integer *, real *, char *
00071 ), slabad_(real *, real *);
00072 extern integer icamax_(integer *, complex *, integer *);
00073 extern VOID clarnd_(complex *, integer *, integer *);
00074 extern doublereal slamch_(char *);
00075 extern int csscal_(integer *, real *, complex *, integer
00076 *);
00077 char packit[1];
00078 real bignum;
00079 extern int clatms_(integer *, integer *, char *, integer
00080 *, char *, real *, integer *, real *, real *, integer *, integer *
00081 , char *, complex *, integer *, complex *, integer *);
00082 real cndnum;
00083 extern int clarnv_(integer *, integer *, integer *,
00084 complex *);
00085 integer jcnext, jcount;
00086 extern int slarnv_(integer *, integer *, integer *, real
00087 *);
00088 real smlnum;
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 --rwork;
00173 --work;
00174 --b;
00175 --ap;
00176 --iseed;
00177
00178
00179 s_copy(path, "Complex precision", (ftnlen)1, (ftnlen)17);
00180 s_copy(path + 1, "TP", (ftnlen)2, (ftnlen)2);
00181 unfl = slamch_("Safe minimum");
00182 ulp = slamch_("Epsilon") * slamch_("Base");
00183 smlnum = unfl;
00184 bignum = (1.f - ulp) / smlnum;
00185 slabad_(&smlnum, &bignum);
00186 if (*imat >= 7 && *imat <= 10 || *imat == 18) {
00187 *(unsigned char *)diag = 'U';
00188 } else {
00189 *(unsigned char *)diag = 'N';
00190 }
00191 *info = 0;
00192
00193
00194
00195 if (*n <= 0) {
00196 return 0;
00197 }
00198
00199
00200
00201 upper = lsame_(uplo, "U");
00202 if (upper) {
00203 clatb4_(path, imat, n, n, type__, &kl, &ku, &anorm, &mode, &cndnum,
00204 dist);
00205 *(unsigned char *)packit = 'C';
00206 } else {
00207 i__1 = -(*imat);
00208 clatb4_(path, &i__1, n, n, type__, &kl, &ku, &anorm, &mode, &cndnum,
00209 dist);
00210 *(unsigned char *)packit = 'R';
00211 }
00212
00213
00214
00215 if (*imat <= 6) {
00216 clatms_(n, n, dist, &iseed[1], type__, &rwork[1], &mode, &cndnum, &
00217 anorm, &kl, &ku, packit, &ap[1], n, &work[1], info);
00218
00219
00220
00221
00222
00223
00224 } else if (*imat == 7) {
00225 if (upper) {
00226 jc = 1;
00227 i__1 = *n;
00228 for (j = 1; j <= i__1; ++j) {
00229 i__2 = j - 1;
00230 for (i__ = 1; i__ <= i__2; ++i__) {
00231 i__3 = jc + i__ - 1;
00232 ap[i__3].r = 0.f, ap[i__3].i = 0.f;
00233
00234 }
00235 i__2 = jc + j - 1;
00236 ap[i__2].r = (real) j, ap[i__2].i = 0.f;
00237 jc += j;
00238
00239 }
00240 } else {
00241 jc = 1;
00242 i__1 = *n;
00243 for (j = 1; j <= i__1; ++j) {
00244 i__2 = jc;
00245 ap[i__2].r = (real) j, ap[i__2].i = 0.f;
00246 i__2 = *n;
00247 for (i__ = j + 1; i__ <= i__2; ++i__) {
00248 i__3 = jc + i__ - j;
00249 ap[i__3].r = 0.f, ap[i__3].i = 0.f;
00250
00251 }
00252 jc = jc + *n - j + 1;
00253
00254 }
00255 }
00256
00257
00258
00259
00260
00261
00262
00263 } else if (*imat <= 10) {
00264 if (upper) {
00265 jc = 0;
00266 i__1 = *n;
00267 for (j = 1; j <= i__1; ++j) {
00268 i__2 = j - 1;
00269 for (i__ = 1; i__ <= i__2; ++i__) {
00270 i__3 = jc + i__;
00271 ap[i__3].r = 0.f, ap[i__3].i = 0.f;
00272
00273 }
00274 i__2 = jc + j;
00275 ap[i__2].r = (real) j, ap[i__2].i = 0.f;
00276 jc += j;
00277
00278 }
00279 } else {
00280 jc = 1;
00281 i__1 = *n;
00282 for (j = 1; j <= i__1; ++j) {
00283 i__2 = jc;
00284 ap[i__2].r = (real) j, ap[i__2].i = 0.f;
00285 i__2 = *n;
00286 for (i__ = j + 1; i__ <= i__2; ++i__) {
00287 i__3 = jc + i__ - j;
00288 ap[i__3].r = 0.f, ap[i__3].i = 0.f;
00289
00290 }
00291 jc = jc + *n - j + 1;
00292
00293 }
00294 }
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354 clarnd_(&q__2, &c__5, &iseed[1]);
00355 q__1.r = q__2.r * .25f, q__1.i = q__2.i * .25f;
00356 star1.r = q__1.r, star1.i = q__1.i;
00357 sfac = .5f;
00358 clarnd_(&q__2, &c__5, &iseed[1]);
00359 q__1.r = sfac * q__2.r, q__1.i = sfac * q__2.i;
00360 plus1.r = q__1.r, plus1.i = q__1.i;
00361 i__1 = *n;
00362 for (j = 1; j <= i__1; j += 2) {
00363 c_div(&q__1, &star1, &plus1);
00364 plus2.r = q__1.r, plus2.i = q__1.i;
00365 i__2 = j;
00366 work[i__2].r = plus1.r, work[i__2].i = plus1.i;
00367 i__2 = *n + j;
00368 work[i__2].r = star1.r, work[i__2].i = star1.i;
00369 if (j + 1 <= *n) {
00370 i__2 = j + 1;
00371 work[i__2].r = plus2.r, work[i__2].i = plus2.i;
00372 i__2 = *n + j + 1;
00373 work[i__2].r = 0.f, work[i__2].i = 0.f;
00374 c_div(&q__1, &star1, &plus2);
00375 plus1.r = q__1.r, plus1.i = q__1.i;
00376 clarnd_(&q__1, &c__2, &iseed[1]);
00377 rexp = q__1.r;
00378 if (rexp < 0.f) {
00379 d__1 = (doublereal) sfac;
00380 d__2 = (doublereal) (1.f - rexp);
00381 r__1 = -pow_dd(&d__1, &d__2);
00382 clarnd_(&q__2, &c__5, &iseed[1]);
00383 q__1.r = r__1 * q__2.r, q__1.i = r__1 * q__2.i;
00384 star1.r = q__1.r, star1.i = q__1.i;
00385 } else {
00386 d__1 = (doublereal) sfac;
00387 d__2 = (doublereal) (rexp + 1.f);
00388 r__1 = pow_dd(&d__1, &d__2);
00389 clarnd_(&q__2, &c__5, &iseed[1]);
00390 q__1.r = r__1 * q__2.r, q__1.i = r__1 * q__2.i;
00391 star1.r = q__1.r, star1.i = q__1.i;
00392 }
00393 }
00394
00395 }
00396
00397 x = sqrt(cndnum) - 1.f / sqrt(cndnum);
00398 if (*n > 2) {
00399 y = sqrt(2.f / (real) (*n - 2)) * x;
00400 } else {
00401 y = 0.f;
00402 }
00403 z__ = x * x;
00404
00405 if (upper) {
00406
00407
00408
00409
00410 jc = 1;
00411 i__1 = *n;
00412 for (j = 2; j <= i__1; ++j) {
00413 i__2 = jc + 1;
00414 ap[i__2].r = y, ap[i__2].i = 0.f;
00415 if (j > 2) {
00416 i__2 = jc + j - 1;
00417 i__3 = j - 2;
00418 ap[i__2].r = work[i__3].r, ap[i__2].i = work[i__3].i;
00419 }
00420 if (j > 3) {
00421 i__2 = jc + j - 2;
00422 i__3 = *n + j - 3;
00423 ap[i__2].r = work[i__3].r, ap[i__2].i = work[i__3].i;
00424 }
00425 jc += j;
00426
00427 }
00428 jc -= *n;
00429 i__1 = jc + 1;
00430 ap[i__1].r = z__, ap[i__1].i = 0.f;
00431 i__1 = *n - 1;
00432 for (j = 2; j <= i__1; ++j) {
00433 i__2 = jc + j;
00434 ap[i__2].r = y, ap[i__2].i = 0.f;
00435
00436 }
00437 } else {
00438
00439
00440
00441
00442 i__1 = *n - 1;
00443 for (i__ = 2; i__ <= i__1; ++i__) {
00444 i__2 = i__;
00445 ap[i__2].r = y, ap[i__2].i = 0.f;
00446
00447 }
00448 i__1 = *n;
00449 ap[i__1].r = z__, ap[i__1].i = 0.f;
00450 jc = *n + 1;
00451 i__1 = *n - 1;
00452 for (j = 2; j <= i__1; ++j) {
00453 i__2 = jc + 1;
00454 i__3 = j - 1;
00455 ap[i__2].r = work[i__3].r, ap[i__2].i = work[i__3].i;
00456 if (j < *n - 1) {
00457 i__2 = jc + 2;
00458 i__3 = *n + j - 1;
00459 ap[i__2].r = work[i__3].r, ap[i__2].i = work[i__3].i;
00460 }
00461 i__2 = jc + *n - j;
00462 ap[i__2].r = y, ap[i__2].i = 0.f;
00463 jc = jc + *n - j + 1;
00464
00465 }
00466 }
00467
00468
00469
00470 if (upper) {
00471 jc = 1;
00472 i__1 = *n - 1;
00473 for (j = 1; j <= i__1; ++j) {
00474 jcnext = jc + j;
00475 i__2 = jcnext + j - 1;
00476 ra.r = ap[i__2].r, ra.i = ap[i__2].i;
00477 rb.r = 2.f, rb.i = 0.f;
00478 crotg_(&ra, &rb, &c__, &s);
00479
00480
00481
00482 if (*n > j + 1) {
00483 jx = jcnext + j;
00484 i__2 = *n;
00485 for (i__ = j + 2; i__ <= i__2; ++i__) {
00486 i__3 = jx + j;
00487 q__2.r = c__ * ap[i__3].r, q__2.i = c__ * ap[i__3].i;
00488 i__4 = jx + j + 1;
00489 q__3.r = s.r * ap[i__4].r - s.i * ap[i__4].i, q__3.i =
00490 s.r * ap[i__4].i + s.i * ap[i__4].r;
00491 q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
00492 ctemp.r = q__1.r, ctemp.i = q__1.i;
00493 i__3 = jx + j + 1;
00494 r_cnjg(&q__4, &s);
00495 q__3.r = -q__4.r, q__3.i = -q__4.i;
00496 i__4 = jx + j;
00497 q__2.r = q__3.r * ap[i__4].r - q__3.i * ap[i__4].i,
00498 q__2.i = q__3.r * ap[i__4].i + q__3.i * ap[
00499 i__4].r;
00500 i__5 = jx + j + 1;
00501 q__5.r = c__ * ap[i__5].r, q__5.i = c__ * ap[i__5].i;
00502 q__1.r = q__2.r + q__5.r, q__1.i = q__2.i + q__5.i;
00503 ap[i__3].r = q__1.r, ap[i__3].i = q__1.i;
00504 i__3 = jx + j;
00505 ap[i__3].r = ctemp.r, ap[i__3].i = ctemp.i;
00506 jx += i__;
00507
00508 }
00509 }
00510
00511
00512
00513 if (j > 1) {
00514 i__2 = j - 1;
00515 r__1 = -c__;
00516 q__1.r = -s.r, q__1.i = -s.i;
00517 crot_(&i__2, &ap[jcnext], &c__1, &ap[jc], &c__1, &r__1, &
00518 q__1);
00519 }
00520
00521
00522
00523 i__2 = jcnext + j - 1;
00524 i__3 = jcnext + j - 1;
00525 q__1.r = -ap[i__3].r, q__1.i = -ap[i__3].i;
00526 ap[i__2].r = q__1.r, ap[i__2].i = q__1.i;
00527 jc = jcnext;
00528
00529 }
00530 } else {
00531 jc = 1;
00532 i__1 = *n - 1;
00533 for (j = 1; j <= i__1; ++j) {
00534 jcnext = jc + *n - j + 1;
00535 i__2 = jc + 1;
00536 ra.r = ap[i__2].r, ra.i = ap[i__2].i;
00537 rb.r = 2.f, rb.i = 0.f;
00538 crotg_(&ra, &rb, &c__, &s);
00539 r_cnjg(&q__1, &s);
00540 s.r = q__1.r, s.i = q__1.i;
00541
00542
00543
00544 if (*n > j + 1) {
00545 i__2 = *n - j - 1;
00546 q__1.r = -s.r, q__1.i = -s.i;
00547 crot_(&i__2, &ap[jcnext + 1], &c__1, &ap[jc + 2], &c__1, &
00548 c__, &q__1);
00549 }
00550
00551
00552
00553 if (j > 1) {
00554 jx = 1;
00555 i__2 = j - 1;
00556 for (i__ = 1; i__ <= i__2; ++i__) {
00557 r__1 = -c__;
00558 i__3 = jx + j - i__;
00559 q__2.r = r__1 * ap[i__3].r, q__2.i = r__1 * ap[i__3]
00560 .i;
00561 i__4 = jx + j - i__ + 1;
00562 q__3.r = s.r * ap[i__4].r - s.i * ap[i__4].i, q__3.i =
00563 s.r * ap[i__4].i + s.i * ap[i__4].r;
00564 q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
00565 ctemp.r = q__1.r, ctemp.i = q__1.i;
00566 i__3 = jx + j - i__ + 1;
00567 r_cnjg(&q__4, &s);
00568 q__3.r = -q__4.r, q__3.i = -q__4.i;
00569 i__4 = jx + j - i__;
00570 q__2.r = q__3.r * ap[i__4].r - q__3.i * ap[i__4].i,
00571 q__2.i = q__3.r * ap[i__4].i + q__3.i * ap[
00572 i__4].r;
00573 i__5 = jx + j - i__ + 1;
00574 q__5.r = c__ * ap[i__5].r, q__5.i = c__ * ap[i__5].i;
00575 q__1.r = q__2.r - q__5.r, q__1.i = q__2.i - q__5.i;
00576 ap[i__3].r = q__1.r, ap[i__3].i = q__1.i;
00577 i__3 = jx + j - i__;
00578 ap[i__3].r = ctemp.r, ap[i__3].i = ctemp.i;
00579 jx = jx + *n - i__ + 1;
00580
00581 }
00582 }
00583
00584
00585
00586 i__2 = jc + 1;
00587 i__3 = jc + 1;
00588 q__1.r = -ap[i__3].r, q__1.i = -ap[i__3].i;
00589 ap[i__2].r = q__1.r, ap[i__2].i = q__1.i;
00590 jc = jcnext;
00591
00592 }
00593 }
00594
00595
00596
00597
00598
00599 } else if (*imat == 11) {
00600
00601
00602
00603
00604
00605 if (upper) {
00606 jc = 1;
00607 i__1 = *n;
00608 for (j = 1; j <= i__1; ++j) {
00609 i__2 = j - 1;
00610 clarnv_(&c__4, &iseed[1], &i__2, &ap[jc]);
00611 i__2 = jc + j - 1;
00612 clarnd_(&q__2, &c__5, &iseed[1]);
00613 q__1.r = q__2.r * 2.f, q__1.i = q__2.i * 2.f;
00614 ap[i__2].r = q__1.r, ap[i__2].i = q__1.i;
00615 jc += j;
00616
00617 }
00618 } else {
00619 jc = 1;
00620 i__1 = *n;
00621 for (j = 1; j <= i__1; ++j) {
00622 if (j < *n) {
00623 i__2 = *n - j;
00624 clarnv_(&c__4, &iseed[1], &i__2, &ap[jc + 1]);
00625 }
00626 i__2 = jc;
00627 clarnd_(&q__2, &c__5, &iseed[1]);
00628 q__1.r = q__2.r * 2.f, q__1.i = q__2.i * 2.f;
00629 ap[i__2].r = q__1.r, ap[i__2].i = q__1.i;
00630 jc = jc + *n - j + 1;
00631
00632 }
00633 }
00634
00635
00636
00637 clarnv_(&c__2, &iseed[1], n, &b[1]);
00638 iy = icamax_(n, &b[1], &c__1);
00639 bnorm = c_abs(&b[iy]);
00640 bscal = bignum / dmax(1.f,bnorm);
00641 csscal_(n, &bscal, &b[1], &c__1);
00642
00643 } else if (*imat == 12) {
00644
00645
00646
00647
00648
00649 clarnv_(&c__2, &iseed[1], n, &b[1]);
00650
00651 r__1 = 1.f, r__2 = (real) (*n - 1);
00652 tscal = 1.f / dmax(r__1,r__2);
00653 if (upper) {
00654 jc = 1;
00655 i__1 = *n;
00656 for (j = 1; j <= i__1; ++j) {
00657 i__2 = j - 1;
00658 clarnv_(&c__4, &iseed[1], &i__2, &ap[jc]);
00659 i__2 = j - 1;
00660 csscal_(&i__2, &tscal, &ap[jc], &c__1);
00661 i__2 = jc + j - 1;
00662 clarnd_(&q__1, &c__5, &iseed[1]);
00663 ap[i__2].r = q__1.r, ap[i__2].i = q__1.i;
00664 jc += j;
00665
00666 }
00667 i__1 = *n * (*n + 1) / 2;
00668 i__2 = *n * (*n + 1) / 2;
00669 q__1.r = smlnum * ap[i__2].r, q__1.i = smlnum * ap[i__2].i;
00670 ap[i__1].r = q__1.r, ap[i__1].i = q__1.i;
00671 } else {
00672 jc = 1;
00673 i__1 = *n;
00674 for (j = 1; j <= i__1; ++j) {
00675 i__2 = *n - j;
00676 clarnv_(&c__2, &iseed[1], &i__2, &ap[jc + 1]);
00677 i__2 = *n - j;
00678 csscal_(&i__2, &tscal, &ap[jc + 1], &c__1);
00679 i__2 = jc;
00680 clarnd_(&q__1, &c__5, &iseed[1]);
00681 ap[i__2].r = q__1.r, ap[i__2].i = q__1.i;
00682 jc = jc + *n - j + 1;
00683
00684 }
00685 q__1.r = smlnum * ap[1].r, q__1.i = smlnum * ap[1].i;
00686 ap[1].r = q__1.r, ap[1].i = q__1.i;
00687 }
00688
00689 } else if (*imat == 13) {
00690
00691
00692
00693
00694
00695 clarnv_(&c__2, &iseed[1], n, &b[1]);
00696 if (upper) {
00697 jc = 1;
00698 i__1 = *n;
00699 for (j = 1; j <= i__1; ++j) {
00700 i__2 = j - 1;
00701 clarnv_(&c__4, &iseed[1], &i__2, &ap[jc]);
00702 i__2 = jc + j - 1;
00703 clarnd_(&q__1, &c__5, &iseed[1]);
00704 ap[i__2].r = q__1.r, ap[i__2].i = q__1.i;
00705 jc += j;
00706
00707 }
00708 i__1 = *n * (*n + 1) / 2;
00709 i__2 = *n * (*n + 1) / 2;
00710 q__1.r = smlnum * ap[i__2].r, q__1.i = smlnum * ap[i__2].i;
00711 ap[i__1].r = q__1.r, ap[i__1].i = q__1.i;
00712 } else {
00713 jc = 1;
00714 i__1 = *n;
00715 for (j = 1; j <= i__1; ++j) {
00716 i__2 = *n - j;
00717 clarnv_(&c__4, &iseed[1], &i__2, &ap[jc + 1]);
00718 i__2 = jc;
00719 clarnd_(&q__1, &c__5, &iseed[1]);
00720 ap[i__2].r = q__1.r, ap[i__2].i = q__1.i;
00721 jc = jc + *n - j + 1;
00722
00723 }
00724 q__1.r = smlnum * ap[1].r, q__1.i = smlnum * ap[1].i;
00725 ap[1].r = q__1.r, ap[1].i = q__1.i;
00726 }
00727
00728 } else if (*imat == 14) {
00729
00730
00731
00732
00733
00734 if (upper) {
00735 jcount = 1;
00736 jc = (*n - 1) * *n / 2 + 1;
00737 for (j = *n; j >= 1; --j) {
00738 i__1 = j - 1;
00739 for (i__ = 1; i__ <= i__1; ++i__) {
00740 i__2 = jc + i__ - 1;
00741 ap[i__2].r = 0.f, ap[i__2].i = 0.f;
00742
00743 }
00744 if (jcount <= 2) {
00745 i__1 = jc + j - 1;
00746 clarnd_(&q__2, &c__5, &iseed[1]);
00747 q__1.r = smlnum * q__2.r, q__1.i = smlnum * q__2.i;
00748 ap[i__1].r = q__1.r, ap[i__1].i = q__1.i;
00749 } else {
00750 i__1 = jc + j - 1;
00751 clarnd_(&q__1, &c__5, &iseed[1]);
00752 ap[i__1].r = q__1.r, ap[i__1].i = q__1.i;
00753 }
00754 ++jcount;
00755 if (jcount > 4) {
00756 jcount = 1;
00757 }
00758 jc = jc - j + 1;
00759
00760 }
00761 } else {
00762 jcount = 1;
00763 jc = 1;
00764 i__1 = *n;
00765 for (j = 1; j <= i__1; ++j) {
00766 i__2 = *n;
00767 for (i__ = j + 1; i__ <= i__2; ++i__) {
00768 i__3 = jc + i__ - j;
00769 ap[i__3].r = 0.f, ap[i__3].i = 0.f;
00770
00771 }
00772 if (jcount <= 2) {
00773 i__2 = jc;
00774 clarnd_(&q__2, &c__5, &iseed[1]);
00775 q__1.r = smlnum * q__2.r, q__1.i = smlnum * q__2.i;
00776 ap[i__2].r = q__1.r, ap[i__2].i = q__1.i;
00777 } else {
00778 i__2 = jc;
00779 clarnd_(&q__1, &c__5, &iseed[1]);
00780 ap[i__2].r = q__1.r, ap[i__2].i = q__1.i;
00781 }
00782 ++jcount;
00783 if (jcount > 4) {
00784 jcount = 1;
00785 }
00786 jc = jc + *n - j + 1;
00787
00788 }
00789 }
00790
00791
00792
00793 if (upper) {
00794 b[1].r = 0.f, b[1].i = 0.f;
00795 for (i__ = *n; i__ >= 2; i__ += -2) {
00796 i__1 = i__;
00797 b[i__1].r = 0.f, b[i__1].i = 0.f;
00798 i__1 = i__ - 1;
00799 clarnd_(&q__2, &c__5, &iseed[1]);
00800 q__1.r = smlnum * q__2.r, q__1.i = smlnum * q__2.i;
00801 b[i__1].r = q__1.r, b[i__1].i = q__1.i;
00802
00803 }
00804 } else {
00805 i__1 = *n;
00806 b[i__1].r = 0.f, b[i__1].i = 0.f;
00807 i__1 = *n - 1;
00808 for (i__ = 1; i__ <= i__1; i__ += 2) {
00809 i__2 = i__;
00810 b[i__2].r = 0.f, b[i__2].i = 0.f;
00811 i__2 = i__ + 1;
00812 clarnd_(&q__2, &c__5, &iseed[1]);
00813 q__1.r = smlnum * q__2.r, q__1.i = smlnum * q__2.i;
00814 b[i__2].r = q__1.r, b[i__2].i = q__1.i;
00815
00816 }
00817 }
00818
00819 } else if (*imat == 15) {
00820
00821
00822
00823
00824
00825
00826 r__1 = 1.f, r__2 = (real) (*n - 1);
00827 texp = 1.f / dmax(r__1,r__2);
00828 d__1 = (doublereal) smlnum;
00829 d__2 = (doublereal) texp;
00830 tscal = pow_dd(&d__1, &d__2);
00831 clarnv_(&c__4, &iseed[1], n, &b[1]);
00832 if (upper) {
00833 jc = 1;
00834 i__1 = *n;
00835 for (j = 1; j <= i__1; ++j) {
00836 i__2 = j - 2;
00837 for (i__ = 1; i__ <= i__2; ++i__) {
00838 i__3 = jc + i__ - 1;
00839 ap[i__3].r = 0.f, ap[i__3].i = 0.f;
00840
00841 }
00842 if (j > 1) {
00843 i__2 = jc + j - 2;
00844 ap[i__2].r = -1.f, ap[i__2].i = -1.f;
00845 }
00846 i__2 = jc + j - 1;
00847 clarnd_(&q__2, &c__5, &iseed[1]);
00848 q__1.r = tscal * q__2.r, q__1.i = tscal * q__2.i;
00849 ap[i__2].r = q__1.r, ap[i__2].i = q__1.i;
00850 jc += j;
00851
00852 }
00853 i__1 = *n;
00854 b[i__1].r = 1.f, b[i__1].i = 1.f;
00855 } else {
00856 jc = 1;
00857 i__1 = *n;
00858 for (j = 1; j <= i__1; ++j) {
00859 i__2 = *n;
00860 for (i__ = j + 2; i__ <= i__2; ++i__) {
00861 i__3 = jc + i__ - j;
00862 ap[i__3].r = 0.f, ap[i__3].i = 0.f;
00863
00864 }
00865 if (j < *n) {
00866 i__2 = jc + 1;
00867 ap[i__2].r = -1.f, ap[i__2].i = -1.f;
00868 }
00869 i__2 = jc;
00870 clarnd_(&q__2, &c__5, &iseed[1]);
00871 q__1.r = tscal * q__2.r, q__1.i = tscal * q__2.i;
00872 ap[i__2].r = q__1.r, ap[i__2].i = q__1.i;
00873 jc = jc + *n - j + 1;
00874
00875 }
00876 b[1].r = 1.f, b[1].i = 1.f;
00877 }
00878
00879 } else if (*imat == 16) {
00880
00881
00882
00883 iy = *n / 2 + 1;
00884 if (upper) {
00885 jc = 1;
00886 i__1 = *n;
00887 for (j = 1; j <= i__1; ++j) {
00888 clarnv_(&c__4, &iseed[1], &j, &ap[jc]);
00889 if (j != iy) {
00890 i__2 = jc + j - 1;
00891 clarnd_(&q__2, &c__5, &iseed[1]);
00892 q__1.r = q__2.r * 2.f, q__1.i = q__2.i * 2.f;
00893 ap[i__2].r = q__1.r, ap[i__2].i = q__1.i;
00894 } else {
00895 i__2 = jc + j - 1;
00896 ap[i__2].r = 0.f, ap[i__2].i = 0.f;
00897 }
00898 jc += j;
00899
00900 }
00901 } else {
00902 jc = 1;
00903 i__1 = *n;
00904 for (j = 1; j <= i__1; ++j) {
00905 i__2 = *n - j + 1;
00906 clarnv_(&c__4, &iseed[1], &i__2, &ap[jc]);
00907 if (j != iy) {
00908 i__2 = jc;
00909 clarnd_(&q__2, &c__5, &iseed[1]);
00910 q__1.r = q__2.r * 2.f, q__1.i = q__2.i * 2.f;
00911 ap[i__2].r = q__1.r, ap[i__2].i = q__1.i;
00912 } else {
00913 i__2 = jc;
00914 ap[i__2].r = 0.f, ap[i__2].i = 0.f;
00915 }
00916 jc = jc + *n - j + 1;
00917
00918 }
00919 }
00920 clarnv_(&c__2, &iseed[1], n, &b[1]);
00921 csscal_(n, &c_b93, &b[1], &c__1);
00922
00923 } else if (*imat == 17) {
00924
00925
00926
00927
00928
00929
00930 tscal = unfl / ulp;
00931 tscal = (1.f - ulp) / tscal;
00932 i__1 = *n * (*n + 1) / 2;
00933 for (j = 1; j <= i__1; ++j) {
00934 i__2 = j;
00935 ap[i__2].r = 0.f, ap[i__2].i = 0.f;
00936
00937 }
00938 texp = 1.f;
00939 if (upper) {
00940 jc = (*n - 1) * *n / 2 + 1;
00941 for (j = *n; j >= 2; j += -2) {
00942 i__1 = jc;
00943 r__1 = -tscal / (real) (*n + 1);
00944 ap[i__1].r = r__1, ap[i__1].i = 0.f;
00945 i__1 = jc + j - 1;
00946 ap[i__1].r = 1.f, ap[i__1].i = 0.f;
00947 i__1 = j;
00948 r__1 = texp * (1.f - ulp);
00949 b[i__1].r = r__1, b[i__1].i = 0.f;
00950 jc = jc - j + 1;
00951 i__1 = jc;
00952 r__1 = -(tscal / (real) (*n + 1)) / (real) (*n + 2);
00953 ap[i__1].r = r__1, ap[i__1].i = 0.f;
00954 i__1 = jc + j - 2;
00955 ap[i__1].r = 1.f, ap[i__1].i = 0.f;
00956 i__1 = j - 1;
00957 r__1 = texp * (real) (*n * *n + *n - 1);
00958 b[i__1].r = r__1, b[i__1].i = 0.f;
00959 texp *= 2.f;
00960 jc = jc - j + 2;
00961
00962 }
00963 r__1 = (real) (*n + 1) / (real) (*n + 2) * tscal;
00964 b[1].r = r__1, b[1].i = 0.f;
00965 } else {
00966 jc = 1;
00967 i__1 = *n - 1;
00968 for (j = 1; j <= i__1; j += 2) {
00969 i__2 = jc + *n - j;
00970 r__1 = -tscal / (real) (*n + 1);
00971 ap[i__2].r = r__1, ap[i__2].i = 0.f;
00972 i__2 = jc;
00973 ap[i__2].r = 1.f, ap[i__2].i = 0.f;
00974 i__2 = j;
00975 r__1 = texp * (1.f - ulp);
00976 b[i__2].r = r__1, b[i__2].i = 0.f;
00977 jc = jc + *n - j + 1;
00978 i__2 = jc + *n - j - 1;
00979 r__1 = -(tscal / (real) (*n + 1)) / (real) (*n + 2);
00980 ap[i__2].r = r__1, ap[i__2].i = 0.f;
00981 i__2 = jc;
00982 ap[i__2].r = 1.f, ap[i__2].i = 0.f;
00983 i__2 = j + 1;
00984 r__1 = texp * (real) (*n * *n + *n - 1);
00985 b[i__2].r = r__1, b[i__2].i = 0.f;
00986 texp *= 2.f;
00987 jc = jc + *n - j;
00988
00989 }
00990 i__1 = *n;
00991 r__1 = (real) (*n + 1) / (real) (*n + 2) * tscal;
00992 b[i__1].r = r__1, b[i__1].i = 0.f;
00993 }
00994
00995 } else if (*imat == 18) {
00996
00997
00998
00999
01000
01001 if (upper) {
01002 jc = 1;
01003 i__1 = *n;
01004 for (j = 1; j <= i__1; ++j) {
01005 i__2 = j - 1;
01006 clarnv_(&c__4, &iseed[1], &i__2, &ap[jc]);
01007 i__2 = jc + j - 1;
01008 ap[i__2].r = 0.f, ap[i__2].i = 0.f;
01009 jc += j;
01010
01011 }
01012 } else {
01013 jc = 1;
01014 i__1 = *n;
01015 for (j = 1; j <= i__1; ++j) {
01016 if (j < *n) {
01017 i__2 = *n - j;
01018 clarnv_(&c__4, &iseed[1], &i__2, &ap[jc + 1]);
01019 }
01020 i__2 = jc;
01021 ap[i__2].r = 0.f, ap[i__2].i = 0.f;
01022 jc = jc + *n - j + 1;
01023
01024 }
01025 }
01026
01027
01028
01029 clarnv_(&c__2, &iseed[1], n, &b[1]);
01030 iy = icamax_(n, &b[1], &c__1);
01031 bnorm = c_abs(&b[iy]);
01032 bscal = bignum / dmax(1.f,bnorm);
01033 csscal_(n, &bscal, &b[1], &c__1);
01034
01035 } else if (*imat == 19) {
01036
01037
01038
01039
01040
01041
01042
01043 r__1 = 1.f, r__2 = (real) (*n - 1);
01044 tleft = bignum / dmax(r__1,r__2);
01045
01046 r__1 = 1.f, r__2 = (real) (*n);
01047 tscal = bignum * ((real) (*n - 1) / dmax(r__1,r__2));
01048 if (upper) {
01049 jc = 1;
01050 i__1 = *n;
01051 for (j = 1; j <= i__1; ++j) {
01052 clarnv_(&c__5, &iseed[1], &j, &ap[jc]);
01053 slarnv_(&c__1, &iseed[1], &j, &rwork[1]);
01054 i__2 = j;
01055 for (i__ = 1; i__ <= i__2; ++i__) {
01056 i__3 = jc + i__ - 1;
01057 i__4 = jc + i__ - 1;
01058 r__1 = tleft + rwork[i__] * tscal;
01059 q__1.r = r__1 * ap[i__4].r, q__1.i = r__1 * ap[i__4].i;
01060 ap[i__3].r = q__1.r, ap[i__3].i = q__1.i;
01061
01062 }
01063 jc += j;
01064
01065 }
01066 } else {
01067 jc = 1;
01068 i__1 = *n;
01069 for (j = 1; j <= i__1; ++j) {
01070 i__2 = *n - j + 1;
01071 clarnv_(&c__5, &iseed[1], &i__2, &ap[jc]);
01072 i__2 = *n - j + 1;
01073 slarnv_(&c__1, &iseed[1], &i__2, &rwork[1]);
01074 i__2 = *n;
01075 for (i__ = j; i__ <= i__2; ++i__) {
01076 i__3 = jc + i__ - j;
01077 i__4 = jc + i__ - j;
01078 r__1 = tleft + rwork[i__ - j + 1] * tscal;
01079 q__1.r = r__1 * ap[i__4].r, q__1.i = r__1 * ap[i__4].i;
01080 ap[i__3].r = q__1.r, ap[i__3].i = q__1.i;
01081
01082 }
01083 jc = jc + *n - j + 1;
01084
01085 }
01086 }
01087 clarnv_(&c__2, &iseed[1], n, &b[1]);
01088 csscal_(n, &c_b93, &b[1], &c__1);
01089 }
01090
01091
01092
01093
01094 if (! lsame_(trans, "N")) {
01095 if (upper) {
01096 jj = 1;
01097 jr = *n * (*n + 1) / 2;
01098 i__1 = *n / 2;
01099 for (j = 1; j <= i__1; ++j) {
01100 jl = jj;
01101 i__2 = *n - j;
01102 for (i__ = j; i__ <= i__2; ++i__) {
01103 i__3 = jr - i__ + j;
01104 t = ap[i__3].r;
01105 i__3 = jr - i__ + j;
01106 i__4 = jl;
01107 ap[i__3].r = ap[i__4].r, ap[i__3].i = ap[i__4].i;
01108 i__3 = jl;
01109 ap[i__3].r = t, ap[i__3].i = 0.f;
01110 jl += i__;
01111
01112 }
01113 jj = jj + j + 1;
01114 jr -= *n - j + 1;
01115
01116 }
01117 } else {
01118 jl = 1;
01119 jj = *n * (*n + 1) / 2;
01120 i__1 = *n / 2;
01121 for (j = 1; j <= i__1; ++j) {
01122 jr = jj;
01123 i__2 = *n - j;
01124 for (i__ = j; i__ <= i__2; ++i__) {
01125 i__3 = jl + i__ - j;
01126 t = ap[i__3].r;
01127 i__3 = jl + i__ - j;
01128 i__4 = jr;
01129 ap[i__3].r = ap[i__4].r, ap[i__3].i = ap[i__4].i;
01130 i__3 = jr;
01131 ap[i__3].r = t, ap[i__3].i = 0.f;
01132 jr -= i__;
01133
01134 }
01135 jl = jl + *n - j + 1;
01136 jj = jj - j - 1;
01137
01138 }
01139 }
01140 }
01141
01142 return 0;
01143
01144
01145
01146 }